IAdditionalDataProviderpublic interface IChunkOrWorld extends IAdditionalDataProvider
world is mentioned in the documentation of this class, it can
also refer to the chunk that is being accessed when callilng this
method. As such, some behavior might be different or unexpected and it might
cause crashes if you're not careful with how you use this class.
For instance, calling getState(int, int) in an IWorld will
always return a valid TileState, however, calling the same method for
an IChunk will cause a crash if the position is outside of the
chunk's boundaries, as calling it from a chunk will still result in
world-level coordinates being used. For that reason, IChunk provides
a mulitude of methods like IChunk.getStateInner(int, int) that will
allow you to get properties of a chunk without needing to know its position
within the world.
To access the game's current world object, use IGameInstance.getWorld(). See IWorld and IChunk for greater
documentation on the seperate behavior of chunks and worlds.
| Modifier and Type | Method | Description |
|---|---|---|
void |
addEntity(Entity entity) |
Adds an
Entity to the world for it to be updated (Entity.update(IGameInstance) and saved and loaded to and from disk. |
void |
addTileEntity(TileEntity tile) |
Adds a
TileEntity to the world. |
void |
callRetroactiveGeneration() |
This method calls all of the
IWorldGenerator objects that are
marked as IWorldGenerator.generatesRetroactively() for
retroactive generation, meaning their IWorldGenerator.generate(IWorld,
IChunk) methods will be called again. |
java.util.List<Entity> |
getAllEntities() |
Gets a list of all of the
Entity objects in the world that are
currently within loaded chunks. |
java.util.List<TileEntity> |
getAllTickingTileEntities() |
Gets a list of all of the
TileEntity objects in the world that
were marked as TileEntity.doesTick() at the point of being added
to the world. |
java.util.List<TileEntity> |
getAllTileEntities() |
Gets a list of all of the
TileEntity objects in the world that
are currently within loaded chunks. |
byte |
getArtificialLight(int x,
int y) |
Gets the artificial light, meaning the light that is generated by tiles,
at the given position in the world.
|
Biome |
getBiome(int x,
int y) |
Gets the
Biome in the world at the given position. |
int |
getChunkHeight(TileLayer layer,
int x,
int bottomY) |
Gets the height of the chunk at the given position.
|
byte |
getCombinedLight(int x,
int y) |
Gets the combined light at the given position in the world.
|
java.util.List<Entity> |
getEntities(BoundBox area) |
|
<T extends Entity> |
getEntities(BoundBox area,
java.lang.Class<T> type) |
|
<T extends Entity> |
getEntities(BoundBox area,
java.lang.Class<T> type,
java.util.function.Predicate<T> test) |
|
java.util.List<Entity> |
getEntities(BoundBox area,
java.util.function.Predicate<Entity> test) |
|
Entity |
getEntity(java.util.UUID id) |
Gets an
Entity that is currently in the world by its UUID. |
Biome |
getExpectedBiome(int x,
int y) |
Gets the
Biome at the given position in the world without loading
the chunk at that position. |
int |
getExpectedSurfaceHeight(TileLayer layer,
int x) |
Gets the height at the given position in the world without loading the
chunk at that position.
|
INoiseGen |
getNoiseGenForBiome(Biome biome) |
Returns the
INoiseGen from the biome generator. |
long |
getSeed() |
|
byte |
getSkyLight(int x,
int y) |
Gets the sky light at the given position in the world.
|
TileState |
getState(int x,
int y) |
Gets the current
TileState at any given position in the world on
TileLayer.MAIN. |
TileState |
getState(TileLayer layer,
int x,
int y) |
Gets the current
TileState at any given position in the world on
the given layer |
TileEntity |
getTileEntity(int x,
int y) |
Gets the
TileEntity at any given position in the world from
TileLayer.MAIN. |
<T extends TileEntity> |
getTileEntity(int x,
int y,
java.lang.Class<T> tileClass) |
Gets the
TileEntity at any given position in the world from
TileLayer.MAIN. |
TileEntity |
getTileEntity(TileLayer layer,
int x,
int y) |
Gets the
TileEntity at any given position in the world from the
given layer. |
<T extends TileEntity> |
getTileEntity(TileLayer layer,
int x,
int y,
java.lang.Class<T> tileClass) |
Gets the
TileEntity at any given position in the world from the
given layer. |
boolean |
isClient() |
|
boolean |
isDedicatedServer() |
|
boolean |
isLocalPlayer(Entity entity) |
Returns true if the provided entity is the game's local player
|
boolean |
isServer() |
|
void |
reevaluateTickBehavior(TileEntity tile) |
Reevaluates if a
TileEntity should be in the list of ticking tile
entities, and should, as such, be updated every tick or not. |
void |
removeEntity(Entity entity) |
Removes an
Entity from the world. |
void |
removeTileEntity(TileLayer layer,
int x,
int y) |
Removes a
TileEntity from the world. |
void |
scheduleUpdate(int x,
int y,
TileLayer layer,
int time) |
Schedules an update to be done after the given time has passed at the
given position.
|
void |
scheduleUpdate(int x,
int y,
TileLayer layer,
int scheduledMeta,
int time) |
Schedules an update to be done after the given time has passed at the
given position with the given metadata.
|
void |
setArtificialLight(int x,
int y,
byte light) |
Set the artificial light at the given position in the world to the given
value.
|
void |
setBiome(int x,
int y,
Biome biome) |
Sets the
Biome in the world at the given position to the given
biome. |
void |
setDirty(int x,
int y) |
Sets the chunk at the given world position dirty, meaning that it will be
guaranteed to be saved to disk the next time the world will be saved.
|
void |
setSkyLight(int x,
int y,
byte light) |
Set the sky light at the given position in the world to the given value.
|
void |
setState(int x,
int y,
TileState tile) |
Sets the
TileState at any given position in the world on TileLayer.MAIN to the given state. |
void |
setState(TileLayer layer,
int x,
int y,
TileState tile) |
Sets the
TileState at any given position in the world on the
given layer to the given state. |
getAdditionalData, getOrCreateAdditionalData, hasAdditionalData, setAdditionalDataTileState getState(int x, int y)
TileState at any given position in the world on
TileLayer.MAIN.x - The x world coordinatey - The y world coordinateTileState getState(TileLayer layer, int x, int y)
TileState at any given position in the world on
the given layerlayer - The layerx - The x world coordinatey - The y world coordinatevoid setState(int x,
int y,
TileState tile)
TileState at any given position in the world on TileLayer.MAIN to the given state.x - The x world coordinatey - The y word coordinatetile - The state to setvoid setState(TileLayer layer, int x, int y, TileState tile)
TileState at any given position in the world on the
given layer to the given state.layer - The layerx - The x world coordinatey - The y world coordinatetile - The state to setvoid addEntity(Entity entity)
Entity to the world for it to be updated (Entity.update(IGameInstance) and saved and loaded to and from disk. If
this operation isn't done, an entity also will not render.entity - The entity to add@ApiInternal void addTileEntity(TileEntity tile)
TileEntity to the world. This method is marked as
internal, as using Tile.provideTileEntity(IWorld, int, int,
TileLayer) if Tile.canProvideTileEntity() is true will make it
automatically be added to the world. Do not manually add tile entities to
the world.tile - The tile entity to addvoid removeEntity(Entity entity)
Entity from the world.entity - The entity to remove@ApiInternal void removeTileEntity(TileLayer layer, int x, int y)
TileEntity from the world. This method is marked as
internal, as using Tile.provideTileEntity(IWorld, int, int,
TileLayer) if Tile.canProvideTileEntity() is true will make it
automatically be removed from the world as the tile is broken. Do not
manually remove tile entities from the world.layer - The layerx - The world xy - The world yTileEntity getTileEntity(TileLayer layer, int x, int y)
TileEntity at any given position in the world from the
given layer. Note that this will return a generic tile entity. If you
want to get a specific type and don't want to do an instanceof
check yourself, you can use getTileEntity(TileLayer, int, int,
Class).layer - The layerx - The world xy - The world ygetTileEntity(TileLayer, int, int, Class)TileEntity getTileEntity(int x, int y)
TileEntity at any given position in the world from
TileLayer.MAIN. Note that this will return a generic tile entity.
If you want to get a specific type and don't want to do an
instanceof check yourself, you can use getTileEntity(int, int,
Class).x - The world xy - The world ygetTileEntity(int, int, Class)<T extends TileEntity> T getTileEntity(TileLayer layer, int x, int y, java.lang.Class<T> tileClass)
TileEntity at any given position in the world from the
given layer. If the tile entity at that position is either null or it
does not have the given class as a super class, this method will return
null.T - The generic type representing the type of tile entity
that will be returnedlayer - The layerx - The world xy - The world ytileClass - The class that the tile entity should be extending or an
object of<T extends TileEntity> T getTileEntity(int x, int y, java.lang.Class<T> tileClass)
TileEntity at any given position in the world from
TileLayer.MAIN. If the tile entity at that position is either
null or it does not have the given class as a super class, this method
will return null.T - The generic type representing the type of tile entity
that will be returnedx - The world xy - The world ytileClass - The class that the tile entity should be extending or an
object ofvoid reevaluateTickBehavior(TileEntity tile)
TileEntity should be in the list of ticking tile
entities, and should, as such, be updated every tick or not. This method
re-calls TileEntity.doesTick() and adds or removes it from or to
the list of ticking tile entities as needed. Note that this very action
is automatically done when adding a tile entity to the world and this
method should not be needed to be called unless you want your tile entity
to have very specific ticking and performance behavior.tile - The tile entitiy to reevaluate the ticking behavior forTileEntity.doesTick()java.util.List<Entity> getAllEntities()
Entity objects in the world that are
currently within loaded chunks. Note that directly adding or removing to
or from this list will throw an UnsupportedOperationException.addEntity(Entity),
removeEntity(Entity)java.util.List<TileEntity> getAllTileEntities()
TileEntity objects in the world that
are currently within loaded chunks. Note that directly adding or removing
to or from this list will throw an UnsupportedOperationException.addTileEntity(TileEntity),
removeTileEntity(TileLayer, int, int)java.util.List<TileEntity> getAllTickingTileEntities()
TileEntity objects in the world that
were marked as TileEntity.doesTick() at the point of being added
to the world. Note that directly adding or removing to or from this list
will throw an UnsupportedOperationException.addTileEntity(TileEntity),
removeTileEntity(TileLayer, int, int)Entity getEntity(java.util.UUID id)
Entity that is currently in the world by its UUID.id - The unique idEntity.getUniqueId()java.util.List<Entity> getEntities(BoundBox area)
area - The area to check for entitiesjava.util.List<Entity> getEntities(BoundBox area, java.util.function.Predicate<Entity> test)
Entity objects that are currently in
the given BoundBox and for which the given Predicate
applies.area - The area to check for entitiestest - The predicate that needs to apply for them to be added to the
list<T extends Entity> java.util.List<T> getEntities(BoundBox area, java.lang.Class<T> type)
Entity objects that are currently in
the given BoundBox that also are objects of or whose classes
extend the given Class.T - A generic type representing the type of entities that are
being looked forarea - The area to check for entitiestype - The type that they need to be<T extends Entity> java.util.List<T> getEntities(BoundBox area, java.lang.Class<T> type, java.util.function.Predicate<T> test)
Entity objects that are currently in
the given BoundBox that also are objects of or whose classes
extend the given Class and for which the given Predicate
applies.T - A generic type representing the type of entities that are
being looked forarea - The area to check for entitiestype - The type that they need to betest - The predicate that needs to apply for them to be added to the
listbyte getCombinedLight(int x,
int y)
getSkyLight(int, int), getArtificialLight(int, int) and the given IWorld.getCurrentTime().x - The world x coordinatey - The world y coordinatebyte getSkyLight(int x,
int y)
x - The world x coordinatey - The world y coordinatebyte getArtificialLight(int x,
int y)
x - The world x coordinatey - The world y coordinate@ApiInternal void setSkyLight(int x, int y, byte light)
Tile.getLight(IWorld, int, int, TileLayer) to actually provide light to
the world. If you just set light to any given position in the world, it
will cause it to be uneven and non-dynamic.x - The world x coordinatey - The world y coordinatelight - The light@ApiInternal void setArtificialLight(int x, int y, byte light)
Tile.getLight(IWorld, int, int, TileLayer) to actually provide light to
the world. If you just set light to any given position in the world, it
will cause it to be uneven and non-dynamic.x - The world x coordinatey - The world y coordinatelight - The lightvoid scheduleUpdate(int x,
int y,
TileLayer layer,
int scheduledMeta,
int time)
Tile.onScheduledUpdate(IWorld, int, int, TileLayer, int) method
of the tile at the given position will be called. Note that scheduled
updates get saved when the chunk gets saved, so that, when reloading the
world, a scheduled update whose time has not yet run out will continue to
tick down its timer.
Note that calling this method when the tile at the passed position is not your own tile can cause unexpected behavior and is, as such, highly discouraged.
x - The world x coordinatey - The world y coordinatelayer - The layerscheduledMeta - The metadata to pass to the tile's method to
distinguish between different kinds of updatestime - The time it should take in ticks for the update to
happenTile.onScheduledUpdate(IWorld, int, int, TileLayer, int)void scheduleUpdate(int x,
int y,
TileLayer layer,
int time)
Tile.onScheduledUpdate(IWorld, int, int, TileLayer, int) method of the
tile at the given position will be called. Note that scheduled updates
get saved when the chunk gets saved, so that, when reloading the world, a
scheduled update whose time has not yet run out will continue to tick
down its timer.
Note that calling this method when the tile at the passed position is not your own tile can cause unexpected behavior and is, as such, highly discouraged.
x - The world x coordinatey - The world y coordinatelayer - The layertime - The time it should take in ticks for the update to happenTile.onScheduledUpdate(IWorld, int, int, TileLayer, int)void setDirty(int x,
int y)
x - The world x coordinatey - The world y coordinateint getChunkHeight(TileLayer layer, int x, int bottomY)
bottomY does not
have any direct influence on the actual height returned but that it is
merely used to get the chunk to query the height of.layer - The layerx - The world x coordinatebottomY - The world y coordiate whose chunk should be queried for
the heightBiome getBiome(int x, int y)
Biome in the world at the given position.x - The world x coordinatey - The world y coordinategetExpectedBiome(int, int)@ApiInternal void setBiome(int x, int y, Biome biome)
Biome in the world at the given position to the given
biome. This method is marked as internal as biomes should only be set by
their generation rather than directly. If you add a biome, you should use
its class' methods to determine where the biome should spawn in the
world.x - The world x coordinatey - The world y coordinatebiome - The biome to setboolean isClient()
INetHandler.isClient()boolean isServer()
INetHandler.isServer()boolean isDedicatedServer()
IGameInstance.isDedicatedServer()boolean isLocalPlayer(Entity entity)
entity - The entityINetHandler.isThePlayer(Entity)void callRetroactiveGeneration()
IWorldGenerator objects that are
marked as IWorldGenerator.generatesRetroactively() for
retroactive generation, meaning their IWorldGenerator.generate(IWorld,
IChunk) methods will be called again. Note that most retroactive
generators can only generate once, so calling this method should
generally have little impact.
Note that retroactive generation is automatically done when a IChunk is loaded from disk.
long getSeed()
Random
generators and INoiseGen objects for world generation. The seed
of the world is persistent, meaning that two worlds with the same seed
should also have the exact same terrain generation.Biome getExpectedBiome(int x, int y)
Biome at the given position in the world without loading
the chunk at that position. This is useful in that, if you want to see
which biome would be at which position in a chunk that might not be
loaded or generated yet, you don't have to make it generate just to find
out the biome. Using this method over getBiome(int, int) during
world generation greatly increases performance.x - The world x coordinatey - The world y coordinateint getExpectedSurfaceHeight(TileLayer layer, int x)
Note that, if caves or structures generate at any given position, the
getChunkHeight(TileLayer, int, int) will be different from this
method's return value. The same will be true if a player places tiles in
the world.
layer - The layerx - The world x coordinateINoiseGen getNoiseGenForBiome(Biome biome)
INoiseGen from the biome generator. This noise generator is the one given to Biome.getState(IWorld, IChunk, int, int, TileLayer, INoiseGen, int) and it is influenced by Biome.getBiomeSeed(IWorld).biome - The biome whose noise generator to get