Interface ChunkSection

  • All Known Implementing Classes:
    ChunkSectionImpl

    public interface ChunkSection
    • Field Detail

      • SIZE

        static final int SIZE
        Size (dimensions) of blocks in a chunks section.
        See Also:
        Constant Field Values
    • Method Detail

      • index

        static int index​(int x,
                         int y,
                         int z)
        Returns the block index of the given coordinates within a section.
        Parameters:
        x - section x
        y - section y
        z - section z
        Returns:
        section block index
      • getFlatBlock

        int getFlatBlock​(int idx)
        Returns the block state of the given index.
        Parameters:
        idx - block index within the section
        Returns:
        block state of the given index
      • getFlatBlock

        default int getFlatBlock​(int x,
                                 int y,
                                 int z)
        Returns the block state of the section coordinate.
        Parameters:
        x - section x
        y - section y
        z - section z
        Returns:
        block state of the given section coordinate
      • setFlatBlock

        void setFlatBlock​(int idx,
                          int id)
        Set a block state in the chunk section. This method will not update non-air blocks count.
        Parameters:
        idx - block index within the section
        id - raw or flat id of the block state
      • setFlatBlock

        default void setFlatBlock​(int x,
                                  int y,
                                  int z,
                                  int id)
        Set a block state in the chunk section. This method will not update non-air blocks count.
        Parameters:
        x - section x
        y - section y
        z - section z
        id - raw or flat id of the block state
      • getBlockWithoutData

        default int getBlockWithoutData​(int x,
                                        int y,
                                        int z)
      • getBlockData

        default int getBlockData​(int x,
                                 int y,
                                 int z)
      • setBlockWithData

        default void setBlockWithData​(int x,
                                      int y,
                                      int z,
                                      int type,
                                      int data)
        Set a block in the chunks. This method will not update non-air blocks count.
        Parameters:
        x - Block X
        y - Block Y
        z - Block Z
        type - The type of the block
        data - The data value of the block
      • setBlockWithData

        default void setBlockWithData​(int idx,
                                      int type,
                                      int data)
      • setPaletteIndex

        void setPaletteIndex​(int idx,
                             int index)
        Sets a block to the given palette index.
        Parameters:
        idx - block index
        index - palette index
      • getPaletteIndex

        int getPaletteIndex​(int idx)
        Returns the palette index of the given block index.
        Parameters:
        idx - block index
        Returns:
        palette index of the given block index
      • getPaletteSize

        int getPaletteSize()
        Returns the size of the palette.
        Returns:
        palette size
      • getPaletteEntry

        int getPaletteEntry​(int index)
        Returns the block state assigned to the given palette index.
        Parameters:
        index - palette index
        Returns:
        block state assigned to the given palette index
      • setPaletteEntry

        void setPaletteEntry​(int index,
                             int id)
        Assigns a block state assigned to the given palette index.
        Parameters:
        index - palette index
        id - block state
      • replacePaletteEntry

        void replacePaletteEntry​(int oldId,
                                 int newId)
        Replaces a block state in the palette.
        Parameters:
        oldId - old block state
        newId - new block state
      • addPaletteEntry

        void addPaletteEntry​(int id)
        Adds a new block state to the palette.
        Parameters:
        id - block state
      • clearPalette

        void clearPalette()
        Clears the palette.
      • getNonAirBlocksCount

        int getNonAirBlocksCount()
        Returns the number of non-air blocks in this section.
        Returns:
        non-air blocks in this section
      • setNonAirBlocksCount

        void setNonAirBlocksCount​(int nonAirBlocksCount)
      • hasLight

        default boolean hasLight()
        Returns whether this section holds light data. Only true for < 1.14 chunks.
        Returns:
        whether this section holds light data
      • getLight

        @Nullable ChunkSectionLight getLight()
        Returns the light of the chunk section. Only present for < 1.14 chunks, otherwise sent separately.
        Returns:
        chunk section light if present