Interface DataPalette
- All Known Implementing Classes:
DataPaletteImpl
public interface DataPalette
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddId(int id) Adds a new id to the palette.voidclear()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.voidforEachMatchingCoordinate(IntPredicate idPredicate, IntConsumer coordinateConsumer) Runs over all section coordinate indices that match the given predicate.intidAt(int sectionCoordinate) Returns the value of the given chunk coordinate.default intidAt(int sectionX, int sectionY, int sectionZ) Returns the value of the section coordinate.intidByIndex(int index) Returns the id assigned to the given palette index.intindex(int x, int y, int z) Returns the packet section index of the given coordinates.intpaletteIndexAt(int packedCoordinate) Returns the palette index of the given section index.default voidreplaceId(int oldId, int newId) Replaces an id in the palette.default voidreplaceIds(IntUnaryOperator mapper) Replaces every id in the palette by applying the given mapper.voidsetIdAt(int sectionCoordinate, int id) Set a value in the chunk section.default voidsetIdAt(int sectionX, int sectionY, int sectionZ, int id) Set a value in the chunk section.voidsetIdByIndex(int index, int id) Assigns an id assigned to the given palette index.voidsetPaletteIndexAt(int sectionCoordinate, int index) Sets the index of the given section coordinate.intsize()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- xy- yz- 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 xsectionY- section ysectionZ- 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 sectionid- 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 xsectionY- section ysectionZ- section zid- 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 indexid- 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 indexindex- palette index
-
replaceIds
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 idnewId- new id
-
forEachMatchingCoordinate
Runs over all section coordinate indices that match the given predicate.- Parameters:
idPredicate- predicate to test idscoordinateConsumer- 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 valueentries- number of valuesrawIds- 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.
-