Class ChunkSectionImpl

  • All Implemented Interfaces:
    ChunkSection

    public class ChunkSectionImpl
    extends java.lang.Object
    implements ChunkSection
    • Constructor Detail

      • ChunkSectionImpl

        public ChunkSectionImpl​(boolean holdsLight)
      • ChunkSectionImpl

        public ChunkSectionImpl​(boolean holdsLight,
                                int expectedPaletteLength)
    • Method Detail

      • getFlatBlock

        public int getFlatBlock​(int idx)
        Description copied from interface: ChunkSection
        Returns the block state of the given index.
        Specified by:
        getFlatBlock in interface ChunkSection
        Parameters:
        idx - block index within the section
        Returns:
        block state of the given index
      • setFlatBlock

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

        public int getPaletteIndex​(int idx)
        Description copied from interface: ChunkSection
        Returns the palette index of the given block index.
        Specified by:
        getPaletteIndex in interface ChunkSection
        Parameters:
        idx - block index
        Returns:
        palette index of the given block index
      • setPaletteIndex

        public void setPaletteIndex​(int idx,
                                    int index)
        Description copied from interface: ChunkSection
        Sets a block to the given palette index.
        Specified by:
        setPaletteIndex in interface ChunkSection
        Parameters:
        idx - block index
        index - palette index
      • getPaletteSize

        public int getPaletteSize()
        Description copied from interface: ChunkSection
        Returns the size of the palette.
        Specified by:
        getPaletteSize in interface ChunkSection
        Returns:
        palette size
      • getPaletteEntry

        public int getPaletteEntry​(int index)
        Description copied from interface: ChunkSection
        Returns the block state assigned to the given palette index.
        Specified by:
        getPaletteEntry in interface ChunkSection
        Parameters:
        index - palette index
        Returns:
        block state assigned to the given palette index
      • setPaletteEntry

        public void setPaletteEntry​(int index,
                                    int id)
        Description copied from interface: ChunkSection
        Assigns a block state assigned to the given palette index.
        Specified by:
        setPaletteEntry in interface ChunkSection
        Parameters:
        index - palette index
        id - block state
      • replacePaletteEntry

        public void replacePaletteEntry​(int oldId,
                                        int newId)
        Description copied from interface: ChunkSection
        Replaces a block state in the palette.
        Specified by:
        replacePaletteEntry in interface ChunkSection
        Parameters:
        oldId - old block state
        newId - new block state
      • addPaletteEntry

        public void addPaletteEntry​(int id)
        Description copied from interface: ChunkSection
        Adds a new block state to the palette.
        Specified by:
        addPaletteEntry in interface ChunkSection
        Parameters:
        id - block state
      • getNonAirBlocksCount

        public int getNonAirBlocksCount()
        Description copied from interface: ChunkSection
        Returns the number of non-air blocks in this section.
        Specified by:
        getNonAirBlocksCount in interface ChunkSection
        Returns:
        non-air blocks in this section
      • getLight

        public @Nullable ChunkSectionLight getLight()
        Description copied from interface: ChunkSection
        Returns the light of the chunk section. Only present for < 1.14 chunks, otherwise sent separately.
        Specified by:
        getLight in interface ChunkSection
        Returns:
        chunk section light if present