Interface DataPalette

All Known Implementing Classes:
DataPaletteImpl

public interface DataPalette
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addId(int id)
    Adds a new id to the palette.
    void
    Clears the palette.
    default long[]
    createPackedValues(int bitsPerValue, int entries, boolean rawIds)
    Packs the section values into a compact long array as used by the protocol.
    void
    forEachMatchingCoordinate(IntPredicate idPredicate, IntConsumer coordinateConsumer)
    Runs over all section coordinate indices that match the given predicate.
    int
    idAt(int sectionCoordinate)
    Returns the value of the given chunk coordinate.
    default int
    idAt(int sectionX, int sectionY, int sectionZ)
    Returns the value of the section coordinate.
    int
    idByIndex(int index)
    Returns the id assigned to the given palette index.
    int
    index(int x, int y, int z)
    Returns the packet section index of the given coordinates.
    int
    paletteIndexAt(int packedCoordinate)
    Returns the palette index of the given section index.
    default void
    replaceId(int oldId, int newId)
    Replaces an id in the palette.
    default void
    Replaces every id in the palette by applying the given mapper.
    void
    setIdAt(int sectionCoordinate, int id)
    Set a value in the chunk section.
    default void
    setIdAt(int sectionX, int sectionY, int sectionZ, int id)
    Set a value in the chunk section.
    void
    setIdByIndex(int index, int id)
    Assigns an id assigned to the given palette index.
    void
    setPaletteIndexAt(int sectionCoordinate, int index)
    Sets the index of the given section coordinate.
    int
    Returns the size of the palette.
  • Method Details

    • index

      int index(int x, int y, int z)
      Returns the packet section index of the given coordinates.
      Parameters:
      x - x
      y - y
      z - z
      Returns:
      packed section index of the given coordinates
    • idAt

      int idAt(int sectionCoordinate)
      Returns the value of the given chunk coordinate.
      Parameters:
      sectionCoordinate - section index within the section
      Returns:
      section state of the given index
    • idAt

      default int idAt(int sectionX, int sectionY, int sectionZ)
      Returns the value of the section coordinate.
      Parameters:
      sectionX - section x
      sectionY - section y
      sectionZ - section z
      Returns:
      id of the given section coordinate
    • setIdAt

      void setIdAt(int sectionCoordinate, int id)
      Set a value in the chunk section. This method does not update non-air blocks count.
      Parameters:
      sectionCoordinate - section index within the section
      id - id value
    • setIdAt

      default void setIdAt(int sectionX, int sectionY, int sectionZ, int id)
      Set a value in the chunk section. This method does not update non-air blocks count.
      Parameters:
      sectionX - section x
      sectionY - section y
      sectionZ - section z
      id - id value
    • idByIndex

      int idByIndex(int index)
      Returns the id assigned to the given palette index.
      Parameters:
      index - palette index
      Returns:
      id assigned to the given palette index
    • setIdByIndex

      void setIdByIndex(int index, int id)
      Assigns an id assigned to the given palette index.
      Parameters:
      index - palette index
      id - id value
    • paletteIndexAt

      int paletteIndexAt(int packedCoordinate)
      Returns the palette index of the given section index.
      Parameters:
      packedCoordinate - section index
      Returns:
      palette index of the given section index
    • setPaletteIndexAt

      void setPaletteIndexAt(int sectionCoordinate, int index)
      Sets the index of the given section coordinate.
      Parameters:
      sectionCoordinate - section index
      index - palette index
    • replaceIds

      default void replaceIds(IntUnaryOperator mapper)
      Replaces every id in the palette by applying the given mapper.
      Parameters:
      mapper - function from old id to new id
    • addId

      void addId(int id)
      Adds a new id to the palette.
      Parameters:
      id - id value
    • replaceId

      default void replaceId(int oldId, int newId)
      Replaces an id in the palette.
      Parameters:
      oldId - old id
      newId - new id
    • forEachMatchingCoordinate

      void forEachMatchingCoordinate(IntPredicate idPredicate, IntConsumer coordinateConsumer)
      Runs over all section coordinate indices that match the given predicate.
      Parameters:
      idPredicate - predicate to test ids
      coordinateConsumer - consumer to run over applicable coordinate indices (not ids!)
      See Also:
    • createPackedValues

      default long[] createPackedValues(int bitsPerValue, int entries, boolean rawIds)
      Packs the section values into a compact long array as used by the protocol.
      Parameters:
      bitsPerValue - bits used per value
      entries - number of values
      rawIds - whether to pack raw ids instead of palette indexes (direct palette)
      Returns:
      compact long array of the values
    • size

      int size()
      Returns the size of the palette.
      Returns:
      palette size
    • clear

      void clear()
      Clears the palette.