Interface IChunkOrWorld
- All Superinterfaces:
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds anEntityto the world for it to be updated (Entity.update(IGameInstance)and saved and loaded to and from disk.voidaddTileEntity(TileEntity tile) Adds aTileEntityto the world.voidThis method calls all of theIWorldGeneratorobjects that are marked asIWorldGenerator.generatesRetroactively()for retroactive generation, meaning theirIWorldGenerator.generate(IWorld, IChunk)methods will be called again.Gets a list of all of theEntityobjects in the world that are currently within loaded chunks.Gets a list of all of theTileEntityobjects in the world that were marked asTileEntity.doesTick()at the point of being added to the world.Gets a list of all of theTileEntityobjects in the world that are currently within loaded chunks.bytegetArtificialLight(int x, int y) Gets the artificial light, meaning the light that is generated by tiles, at the given position in the world.intgetAverageChunkHeight(TileLayer layer, int x, int bottomY) Gets the average height of the chunk at the given position.getBiome(int x, int y) Gets theBiomein the world at the given position.floatgetChunkFlatness(TileLayer layer, int x, int y) Gets the flatness of the chunk at the given position.intgetChunkHeight(TileLayer layer, int x, int bottomY) Gets the height of the chunk at the given position.bytegetCombinedLight(int x, int y) Gets the combined light at the given position in the world.getEntities(BoundingBox area) Gets a list of all of theEntityobjects that are currently in the givenBoundingBox.getEntities(BoundingBox area, Class<T> type) Gets a list of all of theEntityobjects that are currently in the givenBoundingBoxthat also are objects of or whose classes extend the givenClass.getEntities(BoundingBox area, Class<T> type, Predicate<T> test) Gets a list of all of theEntityobjects that are currently in the givenBoundingBoxthat also are objects of or whose classes extend the givenClassand for which the givenPredicateapplies.getEntities(BoundingBox area, Predicate<Entity> test) Gets a list of all of theEntityobjects that are currently in the givenBoundingBoxand for which the givenPredicateapplies.getEntities(List<BoundingBox> area) Gets a list of all of theEntityobjects that are currently in the given List ofBoundingBox.getEntities(List<BoundingBox> area, Class<T> type) Gets a list of all of theEntityobjects that are currently in the given List ofBoundingBoxthat also are objects of or whose classes extend the givenClass.getEntities(List<BoundingBox> area, Class<T> type, Predicate<T> test) Gets a list of all of theEntityobjects that are currently in the given List ofBoundingBoxthat also are objects of or whose classes extend the givenClassand for which the givenPredicateapplies.getEntities(List<BoundingBox> area, Predicate<Entity> test) Gets a list of all of theEntityobjects that are currently in the given List ofBoundingBoxand for which the givenPredicateapplies.intgetExpectedAverageHeight(TileLayer layer, int startX, int endX) Gets the average height in the given interval in the world without loading the chunk at any position.getExpectedBiome(int x, int y) Gets theBiomeat the given position in the world without loading the chunk at that position.getExpectedBiomeLevel(int x, int y) floatgetExpectedSurfaceFlatness(TileLayer layer, int startX, int endX) Gets the flatness in the given interval in the world without loading the chunk at any position.intgetExpectedSurfaceHeight(TileLayer layer, int x) Gets the height at the given position in the world without loading the chunk at that position.longgetSeed()bytegetSkyLight(int x, int y) Gets the sky light at the given position in the world.getState(int x, int y) Gets the currentTileStateat any given position in the world onTileLayer.MAIN.Gets the currentTileStateat any given position in the world on the given layergetTileEntity(int x, int y) Gets theTileEntityat any given position in the world fromTileLayer.MAIN.<T extends TileEntity>
TgetTileEntity(int x, int y, Class<T> tileClass) Gets theTileEntityat any given position in the world fromTileLayer.MAIN.getTileEntity(TileLayer layer, int x, int y) Gets theTileEntityat any given position in the world from the given layer.<T extends TileEntity>
TgetTileEntity(TileLayer layer, int x, int y, Class<T> tileClass) Gets theTileEntityat any given position in the world from the given layer.booleanisClient()booleanbooleanisLocalPlayer(Entity entity) Returns true if the provided entity is the game's local playerbooleanisServer()voidReevaluates if aTileEntityshould be in the list of ticking tile entities, and should, as such, be updated every tick or not.voidremoveEntity(Entity entity) Removes anEntityfrom the world.voidremoveTileEntity(TileLayer layer, int x, int y) Removes aTileEntityfrom the world.voidscheduleUpdate(int x, int y, TileLayer layer, int time) Schedules an update to be done after the given time has passed at the given position.voidscheduleUpdate(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.voidsetArtificialLight(int x, int y, byte light) Set the artificial light at the given position in the world to the given value.voidSets theBiomein the world at the given position to the given biome.voidsetDirty(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.voidsetSkyLight(int x, int y, byte light) Set the sky light at the given position in the world to the given value.voidSets theTileStateat any given position in the world onTileLayer.MAINto the given state.voidSets theTileStateat any given position in the world on the given layer to the given state.Methods inherited from interface de.ellpeck.rockbottom.api.data.set.IAdditionalDataProvider
getAdditionalData, getOrCreateAdditionalData, hasAdditionalData, setAdditionalData
-
Method Details
-
getState
Gets the currentTileStateat any given position in the world onTileLayer.MAIN.- Parameters:
x- The x world coordinatey- The y world coordinate- Returns:
- The state
-
getState
Gets the currentTileStateat any given position in the world on the given layer- Parameters:
layer- The layerx- The x world coordinatey- The y world coordinate- Returns:
- The state
-
setState
Sets theTileStateat any given position in the world onTileLayer.MAINto the given state.- Parameters:
x- The x world coordinatey- The y word coordinatetile- The state to set
-
setState
Sets theTileStateat any given position in the world on the given layer to the given state.- Parameters:
layer- The layerx- The x world coordinatey- The y world coordinatetile- The state to set
-
addEntity
Adds anEntityto 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.- Parameters:
entity- The entity to add
-
addTileEntity
Adds aTileEntityto the world. This method is marked as internal, as usingTile.provideTileEntity(IWorld, int, int, TileLayer)ifTile.canProvideTileEntity()is true will make it automatically be added to the world. Do not manually add tile entities to the world.- Parameters:
tile- The tile entity to add
-
removeEntity
Removes anEntityfrom the world.- Parameters:
entity- The entity to remove
-
removeTileEntity
Removes aTileEntityfrom the world. This method is marked as internal, as usingTile.provideTileEntity(IWorld, int, int, TileLayer)ifTile.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.- Parameters:
layer- The layerx- The world xy- The world y
-
getTileEntity
Gets theTileEntityat 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 aninstanceofcheck yourself, you can usegetTileEntity(TileLayer, int, int, Class).- Parameters:
layer- The layerx- The world xy- The world y- Returns:
- The tile entity at that position, or null if there is none
- See Also:
-
getTileEntity
Gets theTileEntityat any given position in the world fromTileLayer.MAIN. Note that this will return a generic tile entity. If you want to get a specific type and don't want to do aninstanceofcheck yourself, you can usegetTileEntity(int, int, Class).- Parameters:
x- The world xy- The world y- Returns:
- The tile entity at that position, or null if there is none
- See Also:
-
getTileEntity
Gets theTileEntityat 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.- Type Parameters:
T- The generic type representing the type of tile entity that will be returned- Parameters:
layer- The layerx- The world xy- The world ytileClass- The class that the tile entity should be extending or an object of- Returns:
- The tile entity at that position, or null if there is none or it is not of the provided type
-
getTileEntity
Gets theTileEntityat any given position in the world fromTileLayer.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.- Type Parameters:
T- The generic type representing the type of tile entity that will be returned- Parameters:
x- The world xy- The world ytileClass- The class that the tile entity should be extending or an object of- Returns:
- The tile entity at that position, or null if there is none or it is not of the provided type
-
reevaluateTickBehavior
Reevaluates if aTileEntityshould be in the list of ticking tile entities, and should, as such, be updated every tick or not. This method re-callsTileEntity.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.- Parameters:
tile- The tile entitiy to reevaluate the ticking behavior for- See Also:
-
getAllEntities
Gets a list of all of theEntityobjects in the world that are currently within loaded chunks. Note that directly adding or removing to or from this list will throw anUnsupportedOperationException.- Returns:
- All entities
- See Also:
-
getAllTileEntities
List<TileEntity> getAllTileEntities()Gets a list of all of theTileEntityobjects in the world that are currently within loaded chunks. Note that directly adding or removing to or from this list will throw anUnsupportedOperationException.- Returns:
- All tile entites
- See Also:
-
getAllTickingTileEntities
List<TileEntity> getAllTickingTileEntities()Gets a list of all of theTileEntityobjects in the world that were marked asTileEntity.doesTick()at the point of being added to the world. Note that directly adding or removing to or from this list will throw anUnsupportedOperationException.- Returns:
- All ticking tile entities
- See Also:
-
getEntity
- Parameters:
id- The unique id- Returns:
- The entity, or null if there is none
- See Also:
-
getEntities
Gets a list of all of theEntityobjects that are currently in the givenBoundingBox.- Parameters:
area- The area to check for entities- Returns:
- All of the entities
-
getEntities
Gets a list of all of theEntityobjects that are currently in the givenBoundingBoxand for which the givenPredicateapplies.- Parameters:
area- The area to check for entitiestest- The predicate that needs to apply for them to be added to the list- Returns:
- All of the entities
-
getEntities
Gets a list of all of theEntityobjects that are currently in the givenBoundingBoxthat also are objects of or whose classes extend the givenClass.- Type Parameters:
T- A generic type representing the type of entities that are being looked for- Parameters:
area- The area to check for entitiestype- The type that they need to be- Returns:
- All of the entities
-
getEntities
Gets a list of all of theEntityobjects that are currently in the givenBoundingBoxthat also are objects of or whose classes extend the givenClassand for which the givenPredicateapplies.- Type Parameters:
T- A generic type representing the type of entities that are being looked for- Parameters:
area- 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 list- Returns:
- All of the entities
-
getEntities
Gets a list of all of theEntityobjects that are currently in the given List ofBoundingBox.- Parameters:
area- The area to check for entities- Returns:
- All of the entities
-
getEntities
Gets a list of all of theEntityobjects that are currently in the given List ofBoundingBoxand for which the givenPredicateapplies.- Parameters:
area- The area to check for entitiestest- The predicate that needs to apply for them to be added to the list- Returns:
- All of the entities
-
getEntities
Gets a list of all of theEntityobjects that are currently in the given List ofBoundingBoxthat also are objects of or whose classes extend the givenClass.- Type Parameters:
T- A generic type representing the type of entities that are being looked for- Parameters:
area- The area to check for entitiestype- The type that they need to be- Returns:
- All of the entities
-
getEntities
Gets a list of all of theEntityobjects that are currently in the given List ofBoundingBoxthat also are objects of or whose classes extend the givenClassand for which the givenPredicateapplies.- Type Parameters:
T- A generic type representing the type of entities that are being looked for- Parameters:
area- 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 list- Returns:
- All of the entities
-
getCombinedLight
byte getCombinedLight(int x, int y) Gets the combined light at the given position in the world. The combined light is a combination ofgetSkyLight(int, int),getArtificialLight(int, int)and the givenIWorld.getCurrentTime().- Parameters:
x- The world x coordinatey- The world y coordinate- Returns:
- The light at the given position
-
getSkyLight
byte getSkyLight(int x, int y) Gets the sky light at the given position in the world.- Parameters:
x- The world x coordinatey- The world y coordinate- Returns:
- The sky light
-
getArtificialLight
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.- Parameters:
x- The world x coordinatey- The world y coordinate- Returns:
- The artificial light
-
setSkyLight
Set the sky light at the given position in the world to the given value. This method is marked as internal as you should useTile.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.- Parameters:
x- The world x coordinatey- The world y coordinatelight- The light
-
setArtificialLight
Set the artificial light at the given position in the world to the given value. This method is marked as internal as you should useTile.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.- Parameters:
x- The world x coordinatey- The world y coordinatelight- The light
-
scheduleUpdate
Schedules an update to be done after the given time has passed at the given position with the given metadata. After the time has passed, theTile.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.
- Parameters:
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 happen- See Also:
-
scheduleUpdate
Schedules an update to be done after the given time has passed at the given position. After the time has passed, theTile.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.
- Parameters:
x- The world x coordinatey- The world y coordinatelayer- The layertime- The time it should take in ticks for the update to happen- See Also:
-
setDirty
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.- Parameters:
x- The world x coordinatey- The world y coordinate
-
getChunkHeight
Gets the height of the chunk at the given position. First of all, the chunk at the given position is queried and then the height of the terrain at the given x coordinate is returned. Note thatbottomYdoes 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.- Parameters:
layer- The layerx- The world x coordinatebottomY- The world y coordiate whose chunk should be queried for the height- Returns:
- The height of the chunk at the given x coordinate
-
getAverageChunkHeight
Gets the average height of the chunk at the given position. First of all, the chunk at the given position is queried and then the average hight of the chunk at that position is returned. Note that neitherxnorbottomYhave a direct influence on the actual flatness of the position, just the chunk at the position.- Parameters:
layer- The layerx- The world x coordinatebottomY- The world y coordiate whose chunk should be queried for the height- Returns:
- The height of the chunk at the given x coordinate
-
getChunkFlatness
Gets the flatness of the chunk at the given position. First of all, the chunk at the given position is queried and then the flatness of the chunk at that position is returned. Note that neitherxnoryhave a direct influence on the actual flatness of the position, just the chunk at the position.- Parameters:
layer- The layerx- The world x coordinate of the chunk to queryy- The world y coordinate of the chunk to query- Returns:
- The flatness of the chunk. This will be a number between 0 and 1, where 1 means that all of the heights in the chunk are the same, and 0 means that none of the heights in the chunk are the same.
-
getBiome
Gets theBiomein the world at the given position.- Parameters:
x- The world x coordinatey- The world y coordinate- Returns:
- The biome
- See Also:
-
setBiome
Sets theBiomein 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.- Parameters:
x- The world x coordinatey- The world y coordinatebiome- The biome to set
-
isClient
boolean isClient()- Returns:
- If the game is currently in client mode
- See Also:
-
isServer
boolean isServer()- Returns:
- If the game is currently in server mode
- See Also:
-
isDedicatedServer
boolean isDedicatedServer()- Returns:
- If the game is acting as a dedicated server
- See Also:
-
isLocalPlayer
Returns true if the provided entity is the game's local player- Parameters:
entity- The entity- Returns:
- If the entity is the local player
- See Also:
-
callRetroactiveGeneration
void callRetroactiveGeneration()This method calls all of theIWorldGeneratorobjects that are marked asIWorldGenerator.generatesRetroactively()for retroactive generation, meaning theirIWorldGenerator.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
IChunkis loaded from disk. -
getSeed
long getSeed() -
getExpectedBiome
Gets theBiomeat 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 overgetBiome(int, int)during world generation greatly increases performance.- Parameters:
x- The world x coordinatey- The world y coordinate- Returns:
- The expected biome for that position
-
getExpectedBiomeLevel
-
getExpectedSurfaceHeight
Gets the height at the given position in the world without loading the chunk at that position. The height of the world is calculated independently of biomes or any other world generation features.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.- Parameters:
layer- The layerx- The world x coordinate- Returns:
- The expected height for that position
-
getExpectedAverageHeight
Gets the average height in the given interval in the world without loading the chunk at any position. The height of the world is calculated independently of biomes or any other world generation features.Note that, if caves or structures generate at any given position, the
getAverageChunkHeight(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.- Parameters:
layer- The layerstartX- The leftmost world x coordinate, inclusiveendX- The rightmost world x coordinate, exclusive- Returns:
- The expected average height for that interval
-
getExpectedSurfaceFlatness
Gets the flatness in the given interval in the world without loading the chunk at any position. The height of the world is calculated independently of biomes or any other world generation features.Note that, if caves or structures generate at any given position, the
getChunkFlatness(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.- Parameters:
layer- The layerstartX- The leftmost world x coordinate, inclusiveendX- The rightmost world x coordinate, exclusive- Returns:
- The flatness in the interval. This will be a number between 0 and 1, where 1 means that all of the heights in the interval are the same, and 0 means that none of the heights in the interval are the same.
-