Record Class DirectoryPalettedPermutations

java.lang.Object
java.lang.Record
net.neoforged.neoforge.client.textures.DirectoryPalettedPermutations
All Implemented Interfaces:
SpriteSource, SpriteSourceExtension

public record DirectoryPalettedPermutations(String texturePath, Identifier paletteKey, String palettePath) extends Record implements SpriteSource

An implementation of vanilla's PalettedPermutations loader that uses a whole directory instead of just a list of contents. If you wish to use the PalettedPermutations system for something, using this would be preferred as it allows other mods to also utilize your system to its fullest extent.

The problem with vanilla's system is that if Mod A adds a texture and Mod B adds a palette, the game will not recognize the additions of both and won't generate files for Mod A's texture using mod B's palette. Because Mod A doesn't list Mod B's materials in their atlas JSON, and Mod B doesn't list Mod A's pattern in their atlas JSON, the 2 don't work together.

This system makes it so only the owner of the atlas needs to create a JSON file, all other mods will be supported by default if they put their textures in the proper directory.

  • Field Details

    • texturePath

      private final String texturePath
      The field for the texturePath record component.
    • paletteKey

      private final Identifier paletteKey
      The field for the paletteKey record component.
    • palettePath

      private final String palettePath
      The field for the palettePath record component.
    • ID

      public static final Identifier ID
    • CODEC

      public static final com.mojang.serialization.MapCodec<DirectoryPalettedPermutations> CODEC
  • Constructor Details

    • DirectoryPalettedPermutations

      public DirectoryPalettedPermutations(String texturePath, Identifier paletteKey, String palettePath)
      Creates an instance of a DirectoryPalettedPermutations record class.
      Parameters:
      texturePath - the value for the texturePath record component
      paletteKey - the value for the paletteKey record component
      palettePath - the value for the palettePath record component
  • Method Details

    • run

      public void run(ResourceManager manager, SpriteSource.Output output)
      Specified by:
      run in interface SpriteSource
    • codec

      public com.mojang.serialization.MapCodec<? extends SpriteSource> codec()
      Specified by:
      codec in interface SpriteSource
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • texturePath

      public String texturePath()
      Returns the value of the texturePath record component.
      Returns:
      the value of the texturePath record component
    • paletteKey

      public Identifier paletteKey()
      Returns the value of the paletteKey record component.
      Returns:
      the value of the paletteKey record component
    • palettePath

      public String palettePath()
      Returns the value of the palettePath record component.
      Returns:
      the value of the palettePath record component