Class DataAsset

java.lang.Object
mindustry.mod.data.DataAsset
All Implemented Interfaces:
Comparable<DataAsset>
Direct Known Subclasses:
BundleAsset, ContentAsset, ImageAsset, MusicAsset, PatchAsset, SoundAsset

public abstract class DataAsset extends Object implements Comparable<DataAsset>
Abstract class for a kind of asset used in a data asset modification.
  • Field Details

    • path

      public String path
      File path, including name and extension, but excluding base folder prefix.
    • name

      public String name
      File name, excluding extension. This is taken from the path.
    • byteHash

      @Nullable public byte[] byteHash
      sha256 of the internal data. this is null for non-external assets.
    • stringHash

      @Nullable public String stringHash
  • Constructor Details

    • DataAsset

      public DataAsset()
  • Method Details

    • updateData

      public void updateData(byte[] data)
      Caches this asset in the asset folder, and updates its hash to correspond to the appropriate cache file.
    • setHash

      public void setHash(byte[] value)
    • setPath

      public void setPath(String path)
    • getType

      public abstract DataAssetType getType()
    • getFullPath

      public String getFullPath()
    • getData

      public byte[] getData()
      Returns:
      for embedded assets, the data. Not implemented for non-embedded assets (use the cache file).
    • isAlwaysEmbedded

      public boolean isAlwaysEmbedded()
    • isCached

      public boolean isCached()
    • getCacheFileNoNull

      public arc.files.Fi getCacheFileNoNull()
    • getCacheFile

      @Nullable public arc.files.Fi getCacheFile()
    • readFromZip

      public void readFromZip(String path, arc.files.Fi file)
    • readOverride

      public void readOverride(String path, arc.files.Fi file) throws IOException
      Reads this asset in from a file on disk, and makes its hash point to the specified file, instead of a new one in the cache folder. Only used on the server.
      Throws:
      IOException
    • read

      public void read(DataInput stream) throws IOException
      Throws:
      IOException
    • write

      public void write(DataOutput stream) throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(DataAsset asset)
      Specified by:
      compareTo in interface Comparable<DataAsset>