Interface Chunk
- All Superinterfaces:
PersistentDataHolder
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
An enum to specify the load level of a chunk. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addPluginChunkTicket
(@NotNull Plugin plugin) Adds a plugin ticket for this chunk, loading this chunk if it is not already loaded.boolean
Tests if this chunk contains the specified biome.boolean
Tests if this chunk contains the specified block.getBlock
(int x, int y, int z) Gets a block from this chunkdefault long
static long
getChunkKey
(int x, int z) static long
getChunkKey
(@NotNull Location loc) Capture thread-safe read-only snapshot of chunk datagetChunkSnapshot
(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain) Capture thread-safe read-only snapshot of chunk datagetChunkSnapshot
(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain, boolean includeLightData) Capture thread-safe read-only snapshot of chunk dataGet a list of all entities in the chunk.long
Gets the amount of time in ticks that this chunk has been inhabited.Gets the load level of this chunk, which determines what game logic is processed.Get a list of all players who are can view the chunk from their clientRetrieves a collection specifying which plugins have tickets for this chunk.Gets all generated structures that intersect this chunk.getStructures
(@NotNull Structure structure) Gets all generated structures of a givenStructure
that intersect this chunk.default @NotNull BlockState[]
Get a list of all tile entities in the chunk.getTileEntities
(boolean useSnapshot) Get a list of all tile entities in the chunk.getTileEntities
(@NotNull Predicate<? super Block> blockPredicate, boolean useSnapshot) Get a list of all tile entities that match a given predicate in the chunk.getWorld()
Gets the world containing this chunkint
getX()
Gets the X-coordinate of this chunkint
getZ()
Gets the Z-coordinate of this chunkboolean
Checks if entities in this chunk are loaded.boolean
Gets whether the chunk at the specified chunk coordinates is force loaded.boolean
Checks if the chunk is fully generated.boolean
isLoaded()
Checks if the chunk is loaded.boolean
Checks if this chunk can spawn slimes without being a swamp biome.boolean
load()
Loads the chunk.boolean
load
(boolean generate) Loads the chunk.boolean
removePluginChunkTicket
(@NotNull Plugin plugin) Removes the specified plugin's ticket for this chunkvoid
setForceLoaded
(boolean forced) Sets whether the chunk at the specified chunk coordinates is force loaded.void
setInhabitedTime
(long ticks) Sets the amount of time in ticks that this chunk has been inhabited.boolean
unload()
Unloads and optionally saves the Chunkboolean
unload
(boolean save) Unloads and optionally saves the ChunkMethods inherited from interface org.bukkit.persistence.PersistentDataHolder
getPersistentDataContainer
-
Method Details
-
getX
int getX()Gets the X-coordinate of this chunk- Returns:
- X-coordinate
-
getZ
int getZ()Gets the Z-coordinate of this chunk- Returns:
- Z-coordinate
-
getChunkKey
default long getChunkKey()- Returns:
- The Chunks X and Z coordinates packed into a long
-
getChunkKey
- Parameters:
loc
- Location to get chunk key- Returns:
- Location's chunk coordinates packed into a long
-
getChunkKey
static long getChunkKey(int x, int z) - Parameters:
x
- X Coordinatez
- Z Coordinate- Returns:
- Chunk coordinates packed into a long
-
getWorld
Gets the world containing this chunk- Returns:
- Parent World
-
getBlock
Gets a block from this chunk- Parameters:
x
- 0-15y
- world minHeight (inclusive) - world maxHeight (exclusive)z
- 0-15- Returns:
- the Block
-
getChunkSnapshot
Capture thread-safe read-only snapshot of chunk data- Returns:
- ChunkSnapshot
-
getChunkSnapshot
@NotNull @NotNull ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain) Capture thread-safe read-only snapshot of chunk data- Parameters:
includeMaxblocky
- - if true, snapshot includes per-coordinate maximum Y valuesincludeBiome
- - if true, snapshot includes per-coordinate biome typeincludeBiomeTempRain
- - if true, snapshot includes per-coordinate raw biome temperature and rainfall- Returns:
- ChunkSnapshot
-
getChunkSnapshot
@NotNull @NotNull ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain, boolean includeLightData) Capture thread-safe read-only snapshot of chunk data- Parameters:
includeMaxblocky
- if true, snapshot includes per-coordinate maximum Y valuesincludeBiome
- if true, snapshot includes per-coordinate biome typeincludeBiomeTempRain
- if true, snapshot includes per-coordinate raw biome temperature and rainfallincludeLightData
- Whether to include per-coordinate light emitted by blocks and sky light data- Returns:
- ChunkSnapshot
-
isEntitiesLoaded
boolean isEntitiesLoaded()Checks if entities in this chunk are loaded.- Returns:
- True if entities are loaded.
-
getEntities
Get a list of all entities in the chunk. This will force load any entities, which are not loaded.- Returns:
- The entities.
-
getTileEntities
Get a list of all tile entities in the chunk.- Returns:
- The tile entities.
-
getTileEntities
Get a list of all tile entities in the chunk.- Parameters:
useSnapshot
- Take snapshots or direct references- Returns:
- The tile entities.
-
getTileEntities
@NotNull @NotNull Collection<BlockState> getTileEntities(@NotNull Predicate<? super Block> blockPredicate, boolean useSnapshot) Get a list of all tile entities that match a given predicate in the chunk.- Parameters:
blockPredicate
- The predicate of blocks to return tile entities foruseSnapshot
- Take snapshots or direct references- Returns:
- The tile entities.
-
isGenerated
boolean isGenerated()Checks if the chunk is fully generated.- Returns:
- True if it is fully generated.
-
isLoaded
boolean isLoaded()Checks if the chunk is loaded.- Returns:
- True if it is loaded.
-
load
boolean load(boolean generate) Loads the chunk.- Parameters:
generate
- Whether or not to generate a chunk if it doesn't already exist- Returns:
- true if the chunk has loaded successfully, otherwise false
-
load
boolean load()Loads the chunk.- Returns:
- true if the chunk has loaded successfully, otherwise false
-
unload
boolean unload(boolean save) Unloads and optionally saves the Chunk- Parameters:
save
- Controls whether the chunk is saved- Returns:
- true if the chunk has unloaded successfully, otherwise false
-
unload
boolean unload()Unloads and optionally saves the Chunk- Returns:
- true if the chunk has unloaded successfully, otherwise false
-
isSlimeChunk
boolean isSlimeChunk()Checks if this chunk can spawn slimes without being a swamp biome.- Returns:
- true if slimes are able to spawn in this chunk
-
isForceLoaded
boolean isForceLoaded()Gets whether the chunk at the specified chunk coordinates is force loaded.A force loaded chunk will not be unloaded due to lack of player activity.
- Returns:
- force load status
- See Also:
-
setForceLoaded
void setForceLoaded(boolean forced) Sets whether the chunk at the specified chunk coordinates is force loaded.A force loaded chunk will not be unloaded due to lack of player activity.
- Parameters:
forced
- force load status- See Also:
-
addPluginChunkTicket
Adds a plugin ticket for this chunk, loading this chunk if it is not already loaded.A plugin ticket will prevent a chunk from unloading until it is explicitly removed. A plugin instance may only have one ticket per chunk, but each chunk can have multiple plugin tickets.
- Parameters:
plugin
- Plugin which owns the ticket- Returns:
true
if a plugin ticket was added,false
if the ticket already exists for the plugin- Throws:
IllegalStateException
- If the specified plugin is not enabled- See Also:
-
removePluginChunkTicket
Removes the specified plugin's ticket for this chunkA plugin ticket will prevent a chunk from unloading until it is explicitly removed. A plugin instance may only have one ticket per chunk, but each chunk can have multiple plugin tickets.
- Parameters:
plugin
- Plugin which owns the ticket- Returns:
true
if the plugin ticket was removed,false
if there is no plugin ticket for the chunk- See Also:
-
getPluginChunkTickets
Retrieves a collection specifying which plugins have tickets for this chunk. This collection is not updated when plugin tickets are added or removed to this chunk.A plugin ticket will prevent a chunk from unloading until it is explicitly removed. A plugin instance may only have one ticket per chunk, but each chunk can have multiple plugin tickets.
- Returns:
- unmodifiable collection containing which plugins have tickets for this chunk
- See Also:
-
getInhabitedTime
long getInhabitedTime()Gets the amount of time in ticks that this chunk has been inhabited. Note that the time is incremented once per tick per player within mob spawning distance of this chunk.- Returns:
- inhabited time
-
setInhabitedTime
void setInhabitedTime(long ticks) Sets the amount of time in ticks that this chunk has been inhabited.- Parameters:
ticks
- new inhabited time
-
contains
Tests if this chunk contains the specified block.- Parameters:
block
- block to test- Returns:
- if the block is contained within
-
contains
Tests if this chunk contains the specified biome.- Parameters:
biome
- biome to test- Returns:
- if the biome is contained within
-
getLoadLevel
Gets the load level of this chunk, which determines what game logic is processed.- Returns:
- the load level
-
getStructures
Gets all generated structures that intersect this chunk.
If no structures are present an empty collection will be returned.- Returns:
- a collection of placed structures in this chunk
-
getStructures
@NotNull @NotNull Collection<GeneratedStructure> getStructures(@NotNull @NotNull Structure structure) Gets all generated structures of a givenStructure
that intersect this chunk.
If no structures are present an empty collection will be returned.- Parameters:
structure
- the structure to find- Returns:
- a collection of placed structures in this chunk
-
getPlayersSeeingChunk
Get a list of all players who are can view the chunk from their clientThis list will be empty if no players are viewing the chunk, or the chunk is unloaded.
- Returns:
- collection of players who can see the chunk
-