mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-09-28 14:37:42 +02:00
Add more jd to Chunk, ChunkSection, and ChunkSectionLight
This commit is contained in:
parent
cf2adab728
commit
1fe76dbb77
@ -134,7 +134,7 @@ public class BaseChunk implements Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getHeightMap() {
|
public @Nullable CompoundTag getHeightMap() {
|
||||||
return heightMap;
|
return heightMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,18 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface Chunk {
|
public interface Chunk {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the chunk x coordinate.
|
||||||
|
*
|
||||||
|
* @return chunk x coordinate
|
||||||
|
*/
|
||||||
int getX();
|
int getX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the chunk z coordinate.
|
||||||
|
*
|
||||||
|
* @return chunk z coordinate
|
||||||
|
*/
|
||||||
int getZ();
|
int getZ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,17 +82,37 @@ public interface Chunk {
|
|||||||
|
|
||||||
void setChunkMask(BitSet chunkSectionMask);
|
void setChunkMask(BitSet chunkSectionMask);
|
||||||
|
|
||||||
ChunkSection[] getSections();
|
/**
|
||||||
|
* Returns an array of nullable chunk section entries.
|
||||||
|
*
|
||||||
|
* @return array of nullable chunk sections
|
||||||
|
*/
|
||||||
|
@Nullable ChunkSection[] getSections();
|
||||||
|
|
||||||
void setSections(ChunkSection[] sections);
|
void setSections(ChunkSection[] sections);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the chunk's raw biome data. The format the biomes are stored may vary.
|
||||||
|
*
|
||||||
|
* @return raw biome data
|
||||||
|
*/
|
||||||
int @Nullable [] getBiomeData();
|
int @Nullable [] getBiomeData();
|
||||||
|
|
||||||
void setBiomeData(int @Nullable [] biomeData);
|
void setBiomeData(int @Nullable [] biomeData);
|
||||||
|
|
||||||
CompoundTag getHeightMap();
|
/**
|
||||||
|
* Returns a compoundtag containing the chunk's heightmaps if present.
|
||||||
|
*
|
||||||
|
* @return compoundtag containing heightmaps if present
|
||||||
|
*/
|
||||||
|
@Nullable CompoundTag getHeightMap();
|
||||||
|
|
||||||
void setHeightMap(CompoundTag heightMap);
|
void setHeightMap(@Nullable CompoundTag heightMap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of block entities.
|
||||||
|
*
|
||||||
|
* @return list of block entities
|
||||||
|
*/
|
||||||
List<CompoundTag> getBlockEntities();
|
List<CompoundTag> getBlockEntities();
|
||||||
}
|
}
|
||||||
|
@ -43,21 +43,46 @@ public interface ChunkSection {
|
|||||||
return y << 8 | z << 4 | x;
|
return y << 8 | z << 4 | x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the block state of the given index.
|
||||||
|
*
|
||||||
|
* @param idx block index within the section
|
||||||
|
* @return block state of the given index
|
||||||
|
*/
|
||||||
int getFlatBlock(int idx);
|
int getFlatBlock(int idx);
|
||||||
|
|
||||||
int getFlatBlock(int x, int y, int z);
|
/**
|
||||||
|
* Returns the block state of the section coordinate.
|
||||||
|
*
|
||||||
|
* @param x section x
|
||||||
|
* @param y section y
|
||||||
|
* @param z section z
|
||||||
|
* @return block state of the given section coordinate
|
||||||
|
*/
|
||||||
|
default int getFlatBlock(int x, int y, int z) {
|
||||||
|
return getFlatBlock(index(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a block state in the chunk
|
* Set a block state in the chunk section.
|
||||||
* This method will not update non-air blocks count
|
* This method will not update non-air blocks count.
|
||||||
*
|
*
|
||||||
* @param idx Index
|
* @param idx block index within the section
|
||||||
* @param id The raw or flat id of the block
|
* @param id raw or flat id of the block state
|
||||||
*/
|
*/
|
||||||
void setFlatBlock(int idx, int id);
|
void setFlatBlock(int idx, int id);
|
||||||
|
|
||||||
default void setFlatBlock(int x, int y, int z, int type) {
|
/**
|
||||||
setFlatBlock(index(x, y, z), type);
|
* Set a block state in the chunk section.
|
||||||
|
* This method will not update non-air blocks count.
|
||||||
|
*
|
||||||
|
* @param x section x
|
||||||
|
* @param y section y
|
||||||
|
* @param z section z
|
||||||
|
* @param id raw or flat id of the block state
|
||||||
|
*/
|
||||||
|
default void setFlatBlock(int x, int y, int z, int id) {
|
||||||
|
setFlatBlock(index(x, y, z), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
default int getBlockWithoutData(int x, int y, int z) {
|
default int getBlockWithoutData(int x, int y, int z) {
|
||||||
@ -69,8 +94,8 @@ public interface ChunkSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a block in the chunks
|
* Set a block in the chunks.
|
||||||
* This method will not update non-air blocks count
|
* This method will not update non-air blocks count.
|
||||||
*
|
*
|
||||||
* @param x Block X
|
* @param x Block X
|
||||||
* @param y Block Y
|
* @param y Block Y
|
||||||
@ -86,26 +111,80 @@ public interface ChunkSection {
|
|||||||
setFlatBlock(idx, type << 4 | (data & 0xF));
|
setFlatBlock(idx, type << 4 | (data & 0xF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a block to the given palette index.
|
||||||
|
*
|
||||||
|
* @param idx block index
|
||||||
|
* @param index palette index
|
||||||
|
*/
|
||||||
void setPaletteIndex(int idx, int index);
|
void setPaletteIndex(int idx, int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the palette index of the given block index.
|
||||||
|
*
|
||||||
|
* @param idx block index
|
||||||
|
* @return palette index of the given block index
|
||||||
|
*/
|
||||||
int getPaletteIndex(int idx);
|
int getPaletteIndex(int idx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of the palette.
|
||||||
|
*
|
||||||
|
* @return palette size
|
||||||
|
*/
|
||||||
int getPaletteSize();
|
int getPaletteSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the block state assigned to the given palette index.
|
||||||
|
*
|
||||||
|
* @param index palette index
|
||||||
|
* @return block state assigned to the given palette index
|
||||||
|
*/
|
||||||
int getPaletteEntry(int index);
|
int getPaletteEntry(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigns a block state assigned to the given palette index.
|
||||||
|
*
|
||||||
|
* @param index palette index
|
||||||
|
* @param id block state
|
||||||
|
*/
|
||||||
void setPaletteEntry(int index, int id);
|
void setPaletteEntry(int index, int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces a block state in the palette.
|
||||||
|
*
|
||||||
|
* @param oldId old block state
|
||||||
|
* @param newId new block state
|
||||||
|
*/
|
||||||
void replacePaletteEntry(int oldId, int newId);
|
void replacePaletteEntry(int oldId, int newId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new block state to the palette.
|
||||||
|
*
|
||||||
|
* @param id block state
|
||||||
|
*/
|
||||||
void addPaletteEntry(int id);
|
void addPaletteEntry(int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the palette.
|
||||||
|
*/
|
||||||
void clearPalette();
|
void clearPalette();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of non-air blocks in this section.
|
||||||
|
*
|
||||||
|
* @return non-air blocks in this section
|
||||||
|
*/
|
||||||
int getNonAirBlocksCount();
|
int getNonAirBlocksCount();
|
||||||
|
|
||||||
void setNonAirBlocksCount(int nonAirBlocksCount);
|
void setNonAirBlocksCount(int nonAirBlocksCount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this section holds light data.
|
||||||
|
* Only true for < 1.14 clients.
|
||||||
|
*
|
||||||
|
* @return whether this section holds light data
|
||||||
|
*/
|
||||||
default boolean hasLight() {
|
default boolean hasLight() {
|
||||||
return getLight() != null;
|
return getLight() != null;
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,6 @@ public class ChunkSectionImpl implements ChunkSection {
|
|||||||
return palette.getInt(index);
|
return palette.getInt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getFlatBlock(int x, int y, int z) {
|
|
||||||
int index = blocks[ChunkSection.index(x, y, z)];
|
|
||||||
return palette.getInt(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFlatBlock(int idx, int id) {
|
public void setFlatBlock(int idx, int id) {
|
||||||
int index = inversePalette.get(id);
|
int index = inversePalette.get(id);
|
||||||
|
@ -33,36 +33,66 @@ public interface ChunkSectionLight {
|
|||||||
int LIGHT_LENGTH = 16 * 16 * 16 / 2; // Dimensions / 2 (nibble bit count)
|
int LIGHT_LENGTH = 16 * 16 * 16 / 2; // Dimensions / 2 (nibble bit count)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if sky light is present
|
* Returns whether the section has sky light.
|
||||||
*
|
*
|
||||||
* @return True if skylight is present
|
* @return true if skylight is present
|
||||||
*/
|
*/
|
||||||
boolean hasSkyLight();
|
boolean hasSkyLight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the section has block light.
|
||||||
|
* This returns true unless specifically set to null.
|
||||||
|
*
|
||||||
|
* @return true if skylight is present
|
||||||
|
*/
|
||||||
boolean hasBlockLight();
|
boolean hasBlockLight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the nibblearray's raw sky light byte array if present.
|
||||||
|
*
|
||||||
|
* @return the nibblearray's raw sky light byte array if present
|
||||||
|
* @see #hasSkyLight()
|
||||||
|
*/
|
||||||
byte @Nullable [] getSkyLight();
|
byte @Nullable [] getSkyLight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the nibblearray's raw block light byte array if present.
|
||||||
|
*
|
||||||
|
* @return the nibblearray's raw block light byte array if present
|
||||||
|
* @see #hasBlockLight()
|
||||||
|
*/
|
||||||
byte @Nullable [] getBlockLight();
|
byte @Nullable [] getBlockLight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the sky light array
|
* Set the sky light array.
|
||||||
*
|
*
|
||||||
* @param data The value to set the sky light to
|
* @param data raw sky light data
|
||||||
*/
|
*/
|
||||||
void setSkyLight(byte[] data);
|
void setSkyLight(byte[] data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the block light array
|
* Set the block light array.
|
||||||
*
|
*
|
||||||
* @param data The value to set the block light to
|
* @param data raw block light data
|
||||||
*/
|
*/
|
||||||
void setBlockLight(byte[] data);
|
void setBlockLight(byte[] data);
|
||||||
|
|
||||||
@Nullable NibbleArray getBlockLightNibbleArray();
|
/**
|
||||||
|
* Returns the sky light nibblearray.
|
||||||
|
*
|
||||||
|
* @return sky light nibblearray
|
||||||
|
* @see #hasSkyLight()
|
||||||
|
*/
|
||||||
@Nullable NibbleArray getSkyLightNibbleArray();
|
@Nullable NibbleArray getSkyLightNibbleArray();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the block light nibblearray.
|
||||||
|
*
|
||||||
|
* @return block light nibblearray
|
||||||
|
* @see #hasBlockLight()
|
||||||
|
*/
|
||||||
|
@Nullable NibbleArray getBlockLightNibbleArray();
|
||||||
|
|
||||||
void readSkyLight(ByteBuf input);
|
void readSkyLight(ByteBuf input);
|
||||||
|
|
||||||
void readBlockLight(ByteBuf input);
|
void readBlockLight(ByteBuf input);
|
||||||
@ -70,14 +100,14 @@ public interface ChunkSectionLight {
|
|||||||
/**
|
/**
|
||||||
* Write the sky light to a buffer.
|
* Write the sky light to a buffer.
|
||||||
*
|
*
|
||||||
* @param output The buffer to write to
|
* @param output buffer to write to
|
||||||
*/
|
*/
|
||||||
void writeSkyLight(ByteBuf output);
|
void writeSkyLight(ByteBuf output);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the block light to a buffer.
|
* Write the block light to a buffer.
|
||||||
*
|
*
|
||||||
* @param output The buffer to write to
|
* @param output buffer to write to
|
||||||
*/
|
*/
|
||||||
void writeBlockLight(ByteBuf output);
|
void writeBlockLight(ByteBuf output);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user