Interface World
- All Superinterfaces:
Audience, ForwardingAudience, Keyed, Pointered
A loaded world, identified by its key.
As a ForwardingAudience, a world forwards anything sent to it to the players it
currently holds. Block reads may be issued from any thread; block writes are queued on the
region thread owning the position and complete asynchronously.
- Since:
- 0.1.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ForwardingAudience
ForwardingAudience.Single -
Method Summary
Modifier and TypeMethodDescriptionblockKeyAt(BlockPos pos) Gets the type of the block at a position.intblockLight(BlockPos pos) Returns the block light level at a position, between0and15.intblockStateId(BlockPos pos) Gets the block state at a position, loading the chunk when needed.chunkAsync(int chunkX, int chunkZ) Gets a chunk, loading or generating it when needed.default CompletableFuture<Chunk> chunkAsync(ChunkPos pos) Gets a chunk, loading or generating it when needed.chunkIfLoaded(int chunkX, int chunkZ) Gets a chunk only if it is already loaded, without triggering any load.chunkIfLoaded(ChunkPos pos) Gets a chunk only if it is already loaded, without triggering any load.Returns the clock driving the time of day of this world.Returns this world's dimension type.Collection<? extends Entity> entities()Returns the entities currently in this world, players included.entity(int entityId) Looks up an entity of this world by network identifier.Looks up an entity of this world by identity.Returns an immutable snapshot of the force-loaded chunks of this world.The game rules in effect in this world: the base values held by the overworld, except for the rules this world overrides.intheight()Returns the number of block layers of this world, starting atminY().booleanisChunkForceLoaded(int chunkX, int chunkZ) Whether a chunk is force-loaded.default booleanWhether a chunk is force-loaded.default booleanisChunkLoaded(int chunkX, int chunkZ) Checks whether a chunk is currently loaded.intlightLevel(BlockPos pos) Returns the effective light level at a position, the highest of block and sky light.intminY()Returns the lowest block Y coordinate of this world, inclusive.Returns the scheduler responsible for running tasks against positions in this world.setBlockStateId(BlockPos pos, int stateId) Replaces the block state at a position, on the region thread owning it.booleansetChunkForceLoaded(int chunkX, int chunkZ, boolean forced) Sets the force-loaded state of a chunk.intReturns the sky light level at a position, between0and15.unloadChunkAsync(int chunkX, int chunkZ) Unloads a chunk, saving it first.default CompletableFuture<Boolean> unloadChunkAsync(ChunkPos pos) Unloads a chunk, saving it first.weather()The weather of this world.Methods inherited from interface Audience
deleteMessage, openBook, openBook, removeResourcePacks, removeResourcePacks, removeResourcePacks, sendActionBar, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, showTitle, stopSoundMethods inherited from interface ForwardingAudience
audiences, clearResourcePacks, clearTitle, closeDialog, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, playSound, playSound, playSound, pointers, removeResourcePacks, removeResourcePacks, resetTitle, sendActionBar, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendTitlePart, showBossBar, showDialog, stopSoundMethods inherited from interface Pointered
get, getOrDefault, getOrDefaultFrom
-
Method Details
-
minY
int minY()Returns the lowest block Y coordinate of this world, inclusive.- Returns:
- the lowest block Y coordinate of this world, inclusive
- Since:
- 0.1.0
-
height
-
dimensionType
DimensionTypeDefinition dimensionType()Returns this world's dimension type.- Returns:
- this world's dimension type
- Since:
- 0.1.0
-
dayNightCycle
DayNightCycle dayNightCycle()Returns the clock driving the time of day of this world.- Returns:
- the clock driving the time of day of this world
- Since:
- 0.1.0
-
gameRules
WorldGameRules gameRules()The game rules in effect in this world: the base values held by the overworld, except for the rules this world overrides.- Returns:
- the game rules of this world
- Since:
- 0.1.0
-
weather
WeatherManager weather()The weather of this world. Every world has its own weather; it only changes on its own in worlds whose dimension type has a skylight, while theadvance_weathergame rule allows it.- Returns:
- the weather of this world
- Since:
- 0.1.0
-
scheduler
RegionizedScheduler scheduler()Returns the scheduler responsible for running tasks against positions in this world.- Returns:
- the scheduler responsible for running tasks against positions in this world
- Since:
- 0.1.0
-
chunkAsync
Gets a chunk, loading or generating it when needed.- Parameters:
chunkX- the chunk X coordinatechunkZ- the chunk Z coordinate- Returns:
- a future completing with the chunk, or exceptionally if it could not be read
- Since:
- 0.1.0
-
chunkAsync
Gets a chunk, loading or generating it when needed.- Parameters:
pos- the chunk position- Returns:
- a future completing with the chunk, or exceptionally if it could not be read
- Since:
- 0.1.0
-
chunkIfLoaded
-
chunkIfLoaded
-
isChunkLoaded
default boolean isChunkLoaded(int chunkX, int chunkZ) Checks whether a chunk is currently loaded.- Parameters:
chunkX- the chunk X coordinatechunkZ- the chunk Z coordinate- Returns:
trueif the chunk is loaded- Since:
- 0.1.0
-
unloadChunkAsync
Unloads a chunk, saving it first.The request is refused when the chunk is not loaded, is force-loaded, or is still viewed by a player.
- Parameters:
chunkX- the chunk X coordinatechunkZ- the chunk Z coordinate- Returns:
- a future completing with
trueonce the chunk is unloaded, orfalseif the request was refused - Since:
- 0.1.0
-
unloadChunkAsync
Unloads a chunk, saving it first.- Parameters:
pos- the chunk position- Returns:
- a future completing with
trueonce the chunk is unloaded, orfalseif the request was refused - Since:
- 0.1.0
- See Also:
-
isChunkForceLoaded
boolean isChunkForceLoaded(int chunkX, int chunkZ) Whether a chunk is force-loaded.- Parameters:
chunkX- the chunk X coordinatechunkZ- the chunk Z coordinate- Returns:
trueif the chunk is force-loaded- Since:
- 0.1.0
-
isChunkForceLoaded
Whether a chunk is force-loaded.- Parameters:
pos- the chunk position- Returns:
trueif the chunk is force-loaded- Since:
- 0.1.0
- See Also:
-
setChunkForceLoaded
boolean setChunkForceLoaded(int chunkX, int chunkZ, boolean forced) Sets the force-loaded state of a chunk. A force-loaded chunk is loaded right away and stays loaded, across restarts, until it is released.- Parameters:
chunkX- the chunk X coordinatechunkZ- the chunk Z coordinateforced-trueto force-load the chunk,falseto release it- Returns:
trueif the force-loaded state changed- Since:
- 0.1.0
-
forceLoadedChunks
-
blockKeyAt
-
blockStateId
Gets the block state at a position, loading the chunk when needed.- Parameters:
pos- the block position- Returns:
- the network identifier of the block state
- Throws:
UncheckedIOException- if the chunk could not be read- Since:
- 0.1.0
- See Also:
-
setBlockStateId
Replaces the block state at a position, on the region thread owning it.- Parameters:
pos- the block positionstateId- the network identifier of the new block state- Returns:
- a future completing with
trueif the block changed,falseif it already held that state or the write could not be scheduled - Since:
- 0.1.0
-
blockLight
Returns the block light level at a position, between0and15.- Parameters:
pos- the block position- Returns:
- the block light level at a position, between
0and15 - Since:
- 0.1.0
-
skyLight
Returns the sky light level at a position, between0and15.- Parameters:
pos- the block position- Returns:
- the sky light level at a position, between
0and15 - Since:
- 0.1.0
-
lightLevel
Returns the effective light level at a position, the highest of block and sky light.- Parameters:
pos- the block position- Returns:
- the effective light level at a position, the highest of block and sky light
- Since:
- 0.1.0
-
entities
Collection<? extends Entity> entities()Returns the entities currently in this world, players included.- Returns:
- the entities currently in this world, players included
- Since:
- 0.1.0
-
entity
-
entity
Looks up an entity of this world by network identifier.- Parameters:
entityId- the network identifier, as returned byEntity.entityId()- Returns:
- the entity, or empty if this world holds no entity with that identifier
- Since:
- 0.1.0
-