Interface Palette


public sealed interface Palette
Represents a palette used to store blocks and biomes.

0 is the default value.

  • Field Details

  • Method Details

    • blocks

      static Palette blocks(int bitsPerEntry)
    • biomes

      static Palette biomes(int bitsPerEntry)
    • blocks

      static Palette blocks()
    • biomes

      static Palette biomes()
    • empty

      static Palette empty(int dimension, int minBitsPerEntry, int maxBitsPerEntry, int directBits)
    • sized

      static Palette sized(int dimension, int minBitsPerEntry, int maxBitsPerEntry, int directBits, int bitsPerEntry)
    • get

      int get(int x, int y, int z)
    • getAll

      void getAll(@NotNull @NotNull Palette.EntryConsumer consumer)
    • getAllPresent

      void getAllPresent(@NotNull @NotNull Palette.EntryConsumer consumer)
    • set

      void set(int x, int y, int z, int value)
    • fill

      void fill(int value)
    • offset

      void offset(int offset)
    • replace

      void replace(int oldValue, int newValue)
    • setAll

      void setAll(@NotNull @NotNull Palette.EntrySupplier supplier)
    • replace

      void replace(int x, int y, int z, @NotNull @NotNull IntUnaryOperator operator)
    • replaceAll

      void replaceAll(@NotNull @NotNull Palette.EntryFunction function)
    • copyFrom

      void copyFrom(@NotNull @NotNull Palette source, int offsetX, int offsetY, int offsetZ)
      Efficiently copies values from another palette with the given offset.

      Both palettes must have the same dimension.

      Parameters:
      source - the source palette to copy from
      offsetX - the X offset to apply when copying
      offsetY - the Y offset to apply when copying
      offsetZ - the Z offset to apply when copying
    • copyFrom

      void copyFrom(@NotNull @NotNull Palette source)
      Efficiently copies values from another palette starting at position (0, 0, 0).

      Both palettes must have the same dimension.

      This is a convenience method equivalent to calling copyFrom(source, 0, 0, 0).

      Parameters:
      source - the source palette to copy from
    • count

      int count()
      Returns the number of entries in this palette.
    • count

      int count(int value)
      Returns the number of entries in this palette that match the given value.
      Parameters:
      value - the value to count
      Returns:
      the number of entries matching the value
    • any

      boolean any(int value)
      Checks if the palette contains the given value.
      Parameters:
      value - the value to check
      Returns:
      true if the palette contains the value, false otherwise
    • bitsPerEntry

      int bitsPerEntry()
      Returns the number of bits used per entry.
    • dimension

      int dimension()
    • maxSize

      default int maxSize()
      Returns the maximum number of entries in this palette.
    • optimize

      void optimize(Palette.Optimization focus)
    • compare

      boolean compare(@NotNull @NotNull Palette palette)
      Compare palettes content independently of their storage format.
      Parameters:
      palette - the palette to compare with
      Returns:
      true if the palettes are equivalent, false otherwise
    • clone

      @NotNull @NotNull Palette clone()
    • paletteIndexToValue

      @Internal int paletteIndexToValue(int value)
    • valueToPaletteIndex

      @Internal int valueToPaletteIndex(int value)
    • singleValue

      @Internal int singleValue()
      Gets the single value of this palette if it is a single value palette, otherwise returns -1.
    • indexedValues

      @Internal long @Nullable [] indexedValues()
      Gets the value array if it has one, otherwise returns null (i.e. single value palette).
    • biomeSerializer

      static NetworkBuffer.Type<Palette> biomeSerializer(int biomeCount)
    • serializer

      static NetworkBuffer.Type<Palette> serializer(int dimension, int minIndirect, int maxIndirect, int directBits)