@ThreadSafe @ParametersAreNonnullByDefault public final class Chunk extends Object implements IChunk, Closeable
| Modifier and Type | Field and Description |
|---|---|
static int |
SECTION_COUNT |
STATE_FINISHED, STATE_GENERATED, STATE_NEW, STATE_POPULATED| Modifier and Type | Method and Description |
|---|---|
void |
addBlockEntity(BlockEntity blockEntity) |
void |
addEntity(Entity entity) |
void |
addLoader(ChunkLoader chunkLoader) |
static short |
blockKey(int x,
int y,
int z) |
static int |
blockKey(int x,
int y,
int z,
int layer) |
static short |
blockKey(com.nukkitx.math.vector.Vector3i vector) |
void |
clear()
Clear chunk to a state as if it was not generated.
|
boolean |
clearDirty()
Atomically resets this chunk's dirty status.
|
void |
close() |
com.nukkitx.protocol.bedrock.packet.LevelChunkPacket |
createChunkPacket() |
static com.nukkitx.math.vector.Vector4i |
fromKey(long chunkKey,
int blockKey) |
static com.nukkitx.math.vector.Vector3i |
fromKey(long chunkKey,
short blockKey) |
static int |
fromKeyX(long key) |
static int |
fromKeyZ(long key) |
BlockState |
getAndSetBlock(int x,
int y,
int z,
int layer,
BlockState blockState) |
int |
getBiome(int x,
int z) |
byte[] |
getBiomeArray()
Get the copy of the biome array.
|
BlockState |
getBlock(int x,
int y,
int z,
int layer) |
Set<BlockEntity> |
getBlockEntities()
Gets an immutable copy of all block entities within the current chunk.
|
BlockEntity |
getBlockEntity(int x,
int y,
int z) |
byte |
getBlockLight(int x,
int y,
int z) |
Set<Entity> |
getEntities()
Gets an immutable copy of entities currently in this chunk
|
int[] |
getHeightMapArray()
Get a copy of the height map array.
|
int |
getHighestBlock(int x,
int z) |
Level |
getLevel()
Get the level the chunk was loaded in.
|
Set<ChunkLoader> |
getLoaders() |
ChunkSection |
getOrCreateSection(int y) |
Set<Player> |
getPlayerLoaders() |
Set<Player> |
getPlayers()
Gets an immutable copy of players currently in this chunk
|
ChunkSection |
getSection(int y) |
ChunkSection[] |
getSections() |
byte |
getSkyLight(int x,
int y,
int z) |
int |
getState()
Gets this chunk's current state.
|
int |
getX()
Get the chunk's X coordinate in the level it was loaded.
|
int |
getZ()
Get the chunk's Z coordinate in the level it was loaded.
|
void |
init() |
boolean |
isDirty()
Whether the chunk has changed since it was last loaded or saved.
|
static long |
key(int x,
int z) |
LockableChunk |
readLockable() |
void |
removeBlockEntity(BlockEntity blockEntity) |
void |
removeEntity(Entity entity) |
void |
removeLoader(ChunkLoader chunkLoader) |
void |
setBiome(int x,
int z,
int biome) |
void |
setBlock(int x,
int y,
int z,
int layer,
BlockState blockState) |
void |
setBlockLight(int x,
int y,
int z,
int level) |
void |
setDirty(boolean dirty)
Sets the chunk's dirty status.
|
void |
setSkyLight(int x,
int y,
int z,
int level) |
int |
setState(int next)
Atomically updates this chunk's state.
|
void |
tick(int tick) |
LockableChunk |
writeLockable() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompareTo, getAndSetBlock, getBlock, isFinished, isGenerated, isPopulated, key, setBlock, setDirtypublic static final int SECTION_COUNT
public Chunk(int x,
int z,
Level level)
public void init()
@Nonnull public ChunkSection getOrCreateSection(int y)
getOrCreateSection in interface IChunk@Nullable public ChunkSection getSection(int y)
getSection in interface IChunk@Nonnull public ChunkSection[] getSections()
getSections in interface IChunk@Nonnull public BlockState getBlock(int x, int y, int z, int layer)
@Nonnull public BlockState getAndSetBlock(int x, int y, int z, int layer, BlockState blockState)
getAndSetBlock in interface IChunkpublic void setBlock(int x,
int y,
int z,
int layer,
BlockState blockState)
public byte getSkyLight(int x,
int y,
int z)
getSkyLight in interface IChunkpublic void setSkyLight(int x,
int y,
int z,
int level)
setSkyLight in interface IChunkpublic byte getBlockLight(int x,
int y,
int z)
getBlockLight in interface IChunkpublic void setBlockLight(int x,
int y,
int z,
int level)
setBlockLight in interface IChunkpublic int getHighestBlock(int x,
int z)
getHighestBlock in interface IChunkpublic void removeEntity(Entity entity)
removeEntity in interface IChunkpublic static short blockKey(com.nukkitx.math.vector.Vector3i vector)
public static short blockKey(int x,
int y,
int z)
public static com.nukkitx.math.vector.Vector3i fromKey(long chunkKey,
short blockKey)
public int getX()
IChunkpublic int getZ()
IChunk@Nonnull public Level getLevel()
IChunk@Nonnull public byte[] getBiomeArray()
IChunkgetBiomeArray in interface IChunk@Nonnull public int[] getHeightMapArray()
IChunkgetHeightMapArray in interface IChunk@Nonnull public Set<Player> getPlayers()
IChunkgetPlayers in interface IChunk@Nonnull public Set<Entity> getEntities()
IChunkgetEntities in interface IChunkpublic static com.nukkitx.math.vector.Vector4i fromKey(long chunkKey,
int blockKey)
public int getState()
IChunkpublic int setState(int next)
IChunkpublic boolean isDirty()
IChunkpublic boolean clearDirty()
IChunkclearDirty in interface IChunkpublic void addLoader(ChunkLoader chunkLoader)
public void removeLoader(ChunkLoader chunkLoader)
@Nonnull public Set<ChunkLoader> getLoaders()
public void tick(int tick)
public LockableChunk readLockable()
public LockableChunk writeLockable()
public void clear()
IChunkpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic void addBlockEntity(BlockEntity blockEntity)
addBlockEntity in interface IChunkpublic void removeBlockEntity(BlockEntity blockEntity)
removeBlockEntity in interface IChunkpublic static int blockKey(int x,
int y,
int z,
int layer)
public BlockEntity getBlockEntity(int x, int y, int z)
getBlockEntity in interface IChunk@Nonnull public Set<BlockEntity> getBlockEntities()
IChunkgetBlockEntities in interface IChunkpublic static long key(int x,
int z)
public static int fromKeyX(long key)
public static int fromKeyZ(long key)
public void setDirty(boolean dirty)
IChunk@Nonnull public com.nukkitx.protocol.bedrock.packet.LevelChunkPacket createChunkPacket()
Copyright © 2020. All rights reserved.