Package net.risingworld.api
Class World
java.lang.Object
net.risingworld.api.World
Represents the current server world. In provides some information about the
world state, but is also used for any kind of modification you want to do.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConstructionElement
createConstructionElement
(int shape, int texture, float textureScale, int color, Vector3f worldPosition, Quaternion rotation, Vector3f scale) Spawns a new construction element (i.e a block) at a given position.static ConstructionElement
createConstructionElement
(int shape, int texture, float textureScale, int color, Vector3f worldPosition, Quaternion rotation, Vector3f scale, Vector3f surfaceOffset, Vector3f surfaceScale) Spawns a new construction element (i.e a block) at a given position.static ConstructionElement
createConstructionElement
(int shape, int texture, float textureScale, int color, Vector3i chunkPosition, Vector3i blockPosition, Quaternion rotation, Vector3f scale) Spawns a new construction element (i.e a block) at a given position.static void
Performs a construction element place batch, i.e places multiple construction elements at once.static ObjectElement
createObject
(int typeID, int variant, int color, Vector3f worldPosition, Quaternion rotation, Vector3f scale) Spawns a new object (e.g doors, furniture, lamps etc) at a given position.static Plant
createPlant
(int typeID, Vector3f worldPosition, Quaternion rotation, Vector3f scale) static void
createPlants
(PlantPlaceBatch batch) Performs a vegetation place batch, i.e places multiple plants at once.static Storage
createStorage
(int slots, boolean temporary) Creates a new storage in the database.static void
Performs a world edit batch, i.e multiple world edits at once.static WorldItem
findNearestItem
(short itemID, Vector3f position) static WorldItem
findNearestItem
(Vector3f position) Gets the world item which has the shortest distance to a position.static Npc
findNearestNpc
(float x, float y, float z) Gets the npc (any npc) which has the shortest distance to a world position.static Npc
findNearestNpc
(short typeID, float x, float y, float z) Gets the npc (with a certain type id) which has the shortest distance to a world position.static Npc
findNearestNpc
(short typeID, Vector3f position) Gets the npc (with a certain type id) which has the shortest distance to a world position.static Npc
findNearestNpc
(Vector3f position) Gets the npc (any npc) which has the shortest distance to a world position.static Vehicle
findNearestVehicle
(float x, float y, float z) Gets the vehicle (any vehicle) which has the shortest distance to a world position.static Vehicle
findNearestVehicle
(short typeID, float x, float y, float z) Gets the vehicle (with a certain type id) which has the shortest distance to a world position.static Vehicle
findNearestVehicle
(short typeID, Vector3f position) Gets the vehicle (with a certain type id) which has the shortest distance to a world position.static Vehicle
findNearestVehicle
(Vector3f position) Gets the vehicle (any vehicle) which has the shortest distance to a world position.static WorldItem[]
Gets all world items (i.e items that were either spawned through thespawnItem()
method or items that have been dropped by players).static WorldItem[]
getAllItemsInArea
(Area area) static WorldItem[]
getAllItemsInRange
(Vector3f position, float range) Gets all world items (i.e items that were either spawned through thespawnItem()
method or items that have been dropped by players) which are in range to a specific world position.static Npc[]
Gets all npcs which are spawned in this world.static Npc[]
getAllNpcs
(short typeID) Gets all npcs in the world with the provided type ID.static Npc[]
getAllNpcsInArea
(Area area) Gets all npcs which are inside an area.static Npc[]
getAllNpcsInRange
(short typeID, Vector3f position, float range) Gets all npcs with the provided type ID which are in range to a specific world position.static Npc[]
getAllNpcsInRange
(Vector3f position, float range) Gets all npcs which are in range to a specific world position.static Storage[]
Gets all storages in this world.static Vehicle[]
Gets all vehicles which are spawned in this world.static Vehicle[]
getAllVehiclesInArea
(Area area) Gets all vehicles which are inside an area.static Vehicle[]
getAllVehiclesInRange
(Vector3f position, float range) Gets all vehicles which are in range to a specific world position.static Chunk
getChunk
(int cx, int cz) Gets a chunk.static ChunkPart
getChunkPart
(int cx, int cy, int cz) Gets a chunk part.static ConstructionElement
getConstructionElement
(long globalID, int cx, int cy, int cz) Gets a construction element that is placed in the world.static long
Gets the creation date of the world as a timestamp (millis).static float
Gets the default world gravity, which is -9.81static String[]
Gets an array of all disabled npc, i.e npcs which were disabled upon world creation (preventing them from spawning naturally).static WorldItem
getItem
(long globalID) static MetaObject
getMetaObject
(long globalID) Gets a meta object.static String
getName()
Gets the world name.static int
Gets the next "free" (unused) group ID for npcs.static Npc
getNpc
(long globalID) Gets the npc with the provided id.static int
Gets the current amount of global world items (i.e items that have either been spawned by callingspawnItem(short, int, int, net.risingworld.api.utils.Vector3f, net.risingworld.api.utils.Quaternion, boolean)
, or items that have been dropped by players).static int
Gets the current amount of npcs in the world.static int
Gets the total amount of storages in the world.static int
Gets the current amount of vehicles in the world.static ObjectElement
getObject
(long globalID, int cx, int cy, int cz) Gets an object element that is placed in the world.static int
Gets the ore amount (0-4).static Plant
getPlant
(long globalID, int cx, int cy, int cz) static String
getSeed()
Gets the world seed, as a string.static Sign
getSign
(long globalID) Gets a sign instance.static Storage
getStorage
(long globalID) Gets the storage with the provided id (i.e the content of the storage).static int
getTemperature
(float x, float y, float z) Gets the current environment temperature at a given location.static Vehicle
getVehicle
(long globalID) Gets the vehicle with the provided id.static File
Gets the world folder, i.e the folder of the currently loaded world, e.g/Rising World/Worlds/New World/
static File
Gets the main worlds folder, i.e the folder where all worlds are located.static String
Gets the world type (e.g "Superflat").static boolean
Gets whether the world is already initialized or not.
Note: If the world isn't fully initialized yet, the world-functions may return invalid data.static boolean
isNpcDisabled
(short typeID) Checks whether or not this npc is disabled on this world (i.e if this npc was disabled upon world creation).static void
removeConstructionElement
(long globalID, int cx, int cy, int cz, boolean destroy) static void
removeObject
(long globalID, int cx, int cy, int cz, boolean destroy) static void
removePlant
(long globalID, int cx, int cy, int cz, boolean cutOnly, boolean destroy) static void
setSkyRotation
(float rot) Sets the sky rotation.static void
setTerrainData
(int terrainID, int cx, int cy, int cz, int bx, int by, int bz, EditRestriction restriction) Changes the terrain ID at a given position.static void
setTerrainDataInArea
(int terrainID, Area area, EditRestriction restriction) Modifies terrain within a given area.static void
setTerrainDataInArea
(int terrainID, Vector3i startChunk, Vector3i startBlock, Vector3i endChunk, Vector3i endBlock, EditRestriction restriction) Modifies terrain within a given area.static void
setTerrainDataInRadius
(int terrainID, int cx, int cy, int cz, int bx, int by, int bz, int radius, EditRestriction restriction) Modifies terrain at a given position within a certain radius (spherical).static WorldItem
spawnClothingItem
(short clothingID, int variant, int stack, int color, long infoID, Vector3f position, Quaternion rotation, boolean physical) Spawns a global clothing item in the world, i.e an item which represents a garment.static WorldItem
spawnConstructionItem
(byte constructionID, int texture, int stack, int color, Vector3f position, Quaternion rotation, boolean physical) static WorldItem
spawnItem
(short itemID, int texture, int stack, Vector3f position, Quaternion rotation, boolean physical) Spawns an item in the world.static Npc
spawnNpc
(short typeID, int variant, Vector3f position, Quaternion rotation) Spawns a new npc in the world.static Npc
spawnNpc
(short typeID, int variant, Vector3f position, Quaternion rotation, boolean temporary) Spawns a new npc in the world.static Npc
spawnNpc
(short typeID, Vector3f position, Quaternion rotation) Spawns a new npc in the world.static WorldItem
spawnObjectItem
(short objectID, int variant, int stack, Vector3f position, Quaternion rotation, boolean physical) Spawns an object item in the world, i.e an item which represents an object.static Vehicle
spawnVehicle
(short typeID, int constructionStage, int color, Vector3f position, Quaternion rotation) Spawns a new vehicle in the world.static void
triggerExplosion
(Vector3f position, Quaternion rotation, Vector3f scale, float damageFactor) Creates an explosion in the world.
-
Method Details
-
getName
Gets the world name.- Returns:
- the world name.
-
getSeed
Gets the world seed, as a string.- Returns:
- the world seed.
-
getCreationDate
public static long getCreationDate()Gets the creation date of the world as a timestamp (millis).- Returns:
- the creation date.
-
getWorldType
Gets the world type (e.g "Superflat").- Returns:
- the world type.
-
getOreAmount
public static int getOreAmount()Gets the ore amount (0-4).- Returns:
- the ore amount.
-
getDisabledNpcs
Gets an array of all disabled npc, i.e npcs which were disabled upon world creation (preventing them from spawning naturally). Returns null if no npcs are disabled.- Returns:
- an array containing all disabled npc names, or null if all npcs are enabled.
-
getWorldFolder
Gets the world folder, i.e the folder of the currently loaded world, e.g/Rising World/Worlds/New World/
- Returns:
- the folder to the currently loaded world.
-
getWorldsFolder
Gets the main worlds folder, i.e the folder where all worlds are located. Typically/Rising World/Worlds/
.
To get the folder to the currently loaded world, usegetWorldFolder()
instead.- Returns:
- the worlds directory.
-
isInitialized
public static boolean isInitialized()Gets whether the world is already initialized or not.
Note: If the world isn't fully initialized yet, the world-functions may return invalid data.- Returns:
- true if the the world is initialized (i.e the server has fully loaded it), false if not.
-
getTemperature
public static int getTemperature(float x, float y, float z) Gets the current environment temperature at a given location.- Parameters:
x
- the world x position.y
- the world y position.z
- the world z position.- Returns:
- the current temperature (taking biome, weather and daytime into account) at a given location.
-
getDefaultGravity
public static float getDefaultGravity()Gets the default world gravity, which is -9.81- Returns:
- the default gravity (-9.81)
- See Also:
-
setSkyRotation
public static void setSkyRotation(float rot) Sets the sky rotation. More precisely, this affects the sun and moon position. For instance, when setting a sky rotation of 90, the sun rises in the south (instead of east) and sets in the north (instead of west). When setting a rotation of 180, the sun rises in the west and sets in the east etc.
Default sky rotation is 0.- Parameters:
rot
- the sky rotation.
-
spawnItem
public static WorldItem spawnItem(short itemID, int texture, int stack, Vector3f position, Quaternion rotation, boolean physical) Spawns an item in the world.- Parameters:
itemID
- the item type id.texture
- the texture/variant of the item. Typicall it's 0 for most items.stack
- the stack size (i.e amount of items, but still represented by a single item instance).position
- the world position of the item.rotation
- the rotation of the item.physical
- determines if the item should have physical behaviour, e.g fall to the ground etc. If false, the item will be static and immobile. Please note that it's necessary that a player is close to the item in order to provide accurate physical behaviour.- Returns:
- a WorldItem representing the item.
-
spawnObjectItem
public static WorldItem spawnObjectItem(short objectID, int variant, int stack, Vector3f position, Quaternion rotation, boolean physical) Spawns an object item in the world, i.e an item which represents an object.- Parameters:
objectID
- the object type id.variant
- the object variant. By default 0stack
- the stack size (i.e amount of items, but still represented by a single item instance).position
- the world position of the item.rotation
- the rotation of the item.physical
- determines if the item should have physical behaviour, e.g fall to the ground etc. If false, the item will be static and immobile. Please note that it's necessary that a player is close to the item in order to provide accurate physical behaviour.- Returns:
- a WorldItem representing the object item.
-
spawnConstructionItem
public static WorldItem spawnConstructionItem(byte constructionID, int texture, int stack, int color, Vector3f position, Quaternion rotation, boolean physical) -
spawnClothingItem
public static WorldItem spawnClothingItem(short clothingID, int variant, int stack, int color, long infoID, Vector3f position, Quaternion rotation, boolean physical) Spawns a global clothing item in the world, i.e an item which represents a garment.- Parameters:
clothingID
- the clothing type id.variant
- the clothing variant. By default 0stack
- the stack size (i.e amount of items, but still represented by a single item instance).color
- optional rgba color for the clothing piece.infoID
- optional info id for the clothing piece.position
- the world position of the item.rotation
- the rotation of the item.physical
- determines if the item should have physical behaviour, e.g fall to the ground etc. If false, the item will be static and immobile. Please note that it's necessary that a player is close to the item in order to provide accurate physical behaviour.- Returns:
- a WorldItem representing the clothing item.
- Example: Spawn aviator sunglasses in front of a player
-
getItem
-
getAllItems
Gets all world items (i.e items that were either spawned through thespawnItem()
method or items that have been dropped by players). The result is returned as a new array.- Returns:
- a new array containing all world items. Never null.
- Example: Get all items and delete every item that is close to the player
-
getAllItemsInRange
Gets all world items (i.e items that were either spawned through thespawnItem()
method or items that have been dropped by players) which are in range to a specific world position. The result is returned as a new array.- Parameters:
position
- the world position where you want to look for items.range
- the max range (only items within this range will be taken into account).- Returns:
- a new array containing all world items which are in range to the given world position. Never null.
- Example: Apply impulse to all items close to the player
-
getAllItemsInArea
-
findNearestItem
Gets the world item which has the shortest distance to a position.- Parameters:
position
- the world position.- Returns:
- the closest item, or null if no world item exists.
-
findNearestItem
-
getNumItems
public static int getNumItems()Gets the current amount of global world items (i.e items that have either been spawned by callingspawnItem(short, int, int, net.risingworld.api.utils.Vector3f, net.risingworld.api.utils.Quaternion, boolean)
, or items that have been dropped by players).- Returns:
- the current amount of global world items.
-
spawnNpc
Spawns a new npc in the world.- Parameters:
typeID
- the npc type id.position
- the global npc position.rotation
- the rotation of the npc.- Returns:
- the newly spawned npc.
- Example: Spawn npc by using definitions
-
spawnNpc
Spawns a new npc in the world.- Parameters:
typeID
- the npc type id.variant
- the variant of the npc. Only certain npc have different variants. Default is 0.position
- the global npc position.rotation
- the rotation of the npc.- Returns:
- the newly spawned npc.
-
spawnNpc
public static Npc spawnNpc(short typeID, int variant, Vector3f position, Quaternion rotation, boolean temporary) Spawns a new npc in the world.- Parameters:
typeID
- the npc type id.variant
- the variant of the npc. Only certain npc have different variants. Default is 0.position
- the global npc position.rotation
- the rotation of the npc.temporary
- if set to true, the npc will not be stored in the world database. This means the npc will despawn if the server restarts.- Returns:
- the newly spawned npc.
-
getNpc
Gets the npc with the provided id.- Parameters:
globalID
- the global id of the npc.- Returns:
- the npc with the provided id, or null if this id does not belong to a npc.
-
getAllNpcs
Gets all npcs which are spawned in this world. The result is returned as a new array.- Returns:
- a newly created array containing all npcs in the world. Never null.
- Example: Kill all npcs if their health is lower than 10 hp
-
getAllNpcs
Gets all npcs in the world with the provided type ID. The result is returned as a new array.- Parameters:
typeID
- the type of the npc you want to incldue in the search.- Returns:
- a newly created array containing all npcs with the provided type ID in the world. Never null.
-
getAllNpcsInRange
Gets all npcs which are in range to a specific world position. The result is returned as a new array.- Parameters:
position
- the world position where you want to look for npcs.range
- the max range (only npcs within this range will be taken into account).- Returns:
- a new array containing all npcs which are in range to the given world position. Never null.
-
getAllNpcsInRange
Gets all npcs with the provided type ID which are in range to a specific world position. The result is returned as a new array.- Parameters:
typeID
- the type ID you want to restrict the search to.position
- the world position where you want to look for npcs.range
- the max range (only npcs within this range will be taken into account).- Returns:
- a new array containing all npcs which are in range to the given world position. Never null.
- Example: Alert all chicken in range of 50 blocks
-
getAllNpcsInArea
Gets all npcs which are inside an area. The result is returned as a new array.- Parameters:
area
- the area.- Returns:
- a new array containing all npcs which are inside the provided area. Never null.
-
getNumNpcs
public static int getNumNpcs()Gets the current amount of npcs in the world.- Returns:
- the current amount of npcs.
-
getNextNpcGroupID
public static int getNextNpcGroupID()Gets the next "free" (unused) group ID for npcs. Call this method to get an ID which hasn't been used.- Returns:
- the next unuused group ID.
-
findNearestNpc
Gets the npc (any npc) which has the shortest distance to a world position.- Parameters:
position
- the world position.- Returns:
- the closest npc, or null if no npc exists.
- See Also:
-
findNearestNpc
Gets the npc (any npc) which has the shortest distance to a world position.- Parameters:
x
- the world x position.y
- the world y position.z
- the world z position.- Returns:
- the closest npc, or null if no npc exists.
- See Also:
-
findNearestNpc
Gets the npc (with a certain type id) which has the shortest distance to a world position.- Parameters:
typeID
- the npc type id.position
- the world position.- Returns:
- the closest npc, or null if no npc exists.
- See Also:
-
findNearestNpc
Gets the npc (with a certain type id) which has the shortest distance to a world position.- Parameters:
typeID
- the npc type id.x
- the world x position.y
- the world y position.z
- the world z position.- Returns:
- the closest npc, or null if no npc exists.
- See Also:
-
isNpcDisabled
public static boolean isNpcDisabled(short typeID) Checks whether or not this npc is disabled on this world (i.e if this npc was disabled upon world creation). Please note: Even if an npc is disabled, this only affects natural spawns. It can still be spawned via command or through the API.- Parameters:
typeID
- the npc type id.- Returns:
- true if the npc was disabled on this world (which only prevents the npc from spawning naturally), false if not.
-
spawnVehicle
public static Vehicle spawnVehicle(short typeID, int constructionStage, int color, Vector3f position, Quaternion rotation) Spawns a new vehicle in the world.- Parameters:
typeID
- the vehicle type id.constructionStage
- the construction stage of the vehicle. Set to -1 for a ready-to-use vehicle.color
- optional rgba color of the vehicle. Set to 0 for no color.position
- the vehicle world position.rotation
- the rotation of the vehicle.- Returns:
- the newly spawned vehicle.
-
getVehicle
Gets the vehicle with the provided id.- Parameters:
globalID
- the global id of the vehicle.- Returns:
- the vehicle with the provided id, or null if this id does not belong to a vehicle.
-
getAllVehicles
Gets all vehicles which are spawned in this world. The result is returned as a new array.- Returns:
- an array containing all vehicles in the world. Never null.
-
getAllVehiclesInRange
Gets all vehicles which are in range to a specific world position. The result is returned as a new array.- Parameters:
position
- the world position where you want to look for vehicles.range
- the max range (only vehicles within this range will be taken into account).- Returns:
- an array containing all vehicles which are in range to the given world position. Never null.
-
getAllVehiclesInArea
Gets all vehicles which are inside an area. The result is returned as a new array.- Parameters:
area
- the area.- Returns:
- an array containing all vehicles which are inside the provided area. Never null.
-
getNumVehicles
public static int getNumVehicles()Gets the current amount of vehicles in the world.- Returns:
- the current amount of vehicles.
-
findNearestVehicle
Gets the vehicle (any vehicle) which has the shortest distance to a world position.- Parameters:
position
- the world position.- Returns:
- the closest vehicle, or null if no vehicle exists.
-
findNearestVehicle
Gets the vehicle (any vehicle) which has the shortest distance to a world position.- Parameters:
x
- the world x position.y
- the world y position.z
- the world z position.- Returns:
- the closest vehicle, or null if no vehicle exists.
-
findNearestVehicle
Gets the vehicle (with a certain type id) which has the shortest distance to a world position.- Parameters:
typeID
- the vehicle type id.position
- the world position.- Returns:
- the closest vehicle, or null if no such vehicle exists.
-
findNearestVehicle
Gets the vehicle (with a certain type id) which has the shortest distance to a world position.- Parameters:
typeID
- the vehicle type id.x
- the world x position.y
- the world y position.z
- the world z position.- Returns:
- the closest vehicle, or null if no such vehicle exists.
-
createStorage
Creates a new storage in the database. This storage is not bound to a specific item or an object in the world. This could be used for personal player storages, backpacks, custom chests etc.- Parameters:
slots
- the amount of slots the new storage should have.temporary
- if true, the storage will only be valid during this session. Otherwise it gets stored to the database (persistently).- Returns:
- the newly created storage.
-
getStorage
Gets the storage with the provided id (i.e the content of the storage).- Parameters:
globalID
- the global id of the storage.- Returns:
- the storage with the specified id, or null if no such storage exists.
-
getAllStorages
Gets all storages in this world. The storages are returned as array.- Returns:
- a new array containing all storages. Never null.
-
getNumStorages
public static int getNumStorages()Gets the total amount of storages in the world.- Returns:
- the total amount of storages.
-
createObject
public static ObjectElement createObject(int typeID, int variant, int color, Vector3f worldPosition, Quaternion rotation, Vector3f scale) Spawns a new object (e.g doors, furniture, lamps etc) at a given position. The newly created object instance is returned.- Parameters:
typeID
- the object type id.variant
- the optional object variant. By default 0.color
- an optional rgba color for the object. Set to 0 for no color.worldPosition
- the world position where you want to spawn the object.rotation
- the object rotation. Set to Quaternion.IDENTITY for no rotation.scale
- an optional scale for the object. By default 1 1 1 (or Vector3f.ONE).- Returns:
- the newly created object instance (or null if the object could not be created).
- Example: Spawn a workbench at the player position
-
getObject
Gets an object element that is placed in the world. Objects are elements like furniture, doors, lamps etc. They are typically placed by players, but could also be naturally spawned (e.g in dungeons).- Parameters:
globalID
- the unique global ID of the object.cx
- the x coordinate of the chunk which holds the object.cy
- the y coordinate of the chunk which holds the object.cz
- the z coordinate of the chunk which holds the object.- Returns:
- an object instance representing the object element in the world, or null if this object does not exist.
-
getMetaObject
Gets a meta object. This is typically any kind of processing station, like a furnace, a grinder, paper press etc. Usually a meta object is bound to an actual ObjectElement - in this case, the ID of the meta object is the global ID of the object.- Parameters:
globalID
- the unique object ID.- Returns:
- the meta object, or null if no such meta object was found.
- Example: Check the fuel level of a furnace
-
removeObject
public static void removeObject(long globalID, int cx, int cy, int cz, boolean destroy) -
getSign
Gets a sign instance. It's typically bound to an ObjectElement (i.e an actual sign object in the world).- Parameters:
globalID
- the unique ID of the sign object (i.e the object global ID).- Returns:
- a sign instance, or null if no such sign exists.
-
createConstructionElement
public static ConstructionElement createConstructionElement(int shape, int texture, float textureScale, int color, Vector3f worldPosition, Quaternion rotation, Vector3f scale) Spawns a new construction element (i.e a block) at a given position. The newly created element instance is returned.- Parameters:
shape
- the shape / type id you want to spawn.texture
- the texture id for the construction element.textureScale
- an optional scale factor for the texture. Default 1.color
- an optional rgba color for the element. Set to 0 for no color.worldPosition
- the world position where you want to spawn the element.rotation
- the element rotation. Set to Quaternion.IDENTITY for no rotation.scale
- an optional scale for the element. By default 1 1 1 (or Vector3f.ONE).- Returns:
- the newly created construction element instance (or null if the element could not be created).
-
createConstructionElement
public static ConstructionElement createConstructionElement(int shape, int texture, float textureScale, int color, Vector3f worldPosition, Quaternion rotation, Vector3f scale, Vector3f surfaceOffset, Vector3f surfaceScale) Spawns a new construction element (i.e a block) at a given position. The newly created element instance is returned.- Parameters:
shape
- the shape / type id you want to spawn.texture
- the texture id for the construction element.textureScale
- an optional scale factor for the texture. Default 1.color
- an optional rgba color for the element. Set to 0 for no color.worldPosition
- the world position where you want to spawn the element.rotation
- the element rotation. Set to Quaternion.IDENTITY for no rotation.scale
- an optional scale for the element. By default 1 1 1 (or Vector3f.ONE).surfaceOffset
- an optional offset for the upper surface. By default 0 0 0 (or Vector3f.ZERO).surfaceScale
- an optional scale factor for the upper surface. By default 1 1 1 (or Vector3f.ONE).- Returns:
- the newly created construction element instance (or null if the element could not be created).
-
createConstructionElement
public static ConstructionElement createConstructionElement(int shape, int texture, float textureScale, int color, Vector3i chunkPosition, Vector3i blockPosition, Quaternion rotation, Vector3f scale) Spawns a new construction element (i.e a block) at a given position. The newly created element instance is returned.- Parameters:
shape
- the shape / type id you want to spawn.texture
- the texture id for the construction element.textureScale
- an optional scale factor for the texture. Default 1.color
- an optional rgba color for the element. Set to 0 for no color.chunkPosition
- the coordinates of the chunk where you want to place the element.blockPosition
- the block position inside that chunk where you want to place the element.rotation
- the element rotation. Set to Quaternion.IDENTITY for no rotation.scale
- an optional scale for the element. By default 1 1 1 (or Vector3f.ONE).- Returns:
- the newly created construction element instance (or null if the element could not be created).
-
createConstructionElements
Performs a construction element place batch, i.e places multiple construction elements at once. If you want to place multiple construction elements, this method is usually much more performant compared to callingcreateConstructionElement()
for each element.- Parameters:
batch
- theConstructionPlaceBatch
object containing the batch data.- Example: Create multiple construction elements efficiently
-
getConstructionElement
Gets a construction element that is placed in the world. This covers all type of building elements like blocks, glass panes, window frames etc. Construction elements are typically placed by players, but could also be naturally spawned (e.g as dungeons).- Parameters:
globalID
- the unique global ID of the construction element.cx
- the x coordinate of the chunk which holds the construction element.cy
- the y coordinate of the chunk which holds the construction element.cz
- the z coordinate of the chunk which holds the construction element.- Returns:
- an instance representing the construction element in the world, or null if this element does not exist.
-
removeConstructionElement
public static void removeConstructionElement(long globalID, int cx, int cy, int cz, boolean destroy) -
createPlant
public static Plant createPlant(int typeID, Vector3f worldPosition, Quaternion rotation, Vector3f scale) -
createPlants
Performs a vegetation place batch, i.e places multiple plants at once. If you want to place multiple plants, this method is usually much more performant compared to callingcreatePlant()
for each plants.- Parameters:
batch
- thePlantPlaceBatch
object containing the batch data.
-
getPlant
-
removePlant
public static void removePlant(long globalID, int cx, int cy, int cz, boolean cutOnly, boolean destroy) -
setTerrainData
public static void setTerrainData(int terrainID, int cx, int cy, int cz, int bx, int by, int bz, EditRestriction restriction) Changes the terrain ID at a given position.- Parameters:
terrainID
- the new terrain ID you want to set. Air is 0.cx
- the chunk x coordinate.cy
- the chunk y coordinate.cz
- the chunk z coordinate.bx
- the block x coordinate within the chunk (0-32).by
- the block y coordinate within the chunk (0-64).bz
- the block z coordinate within the chunk (0-32).restriction
- an optional edit restriction. This allows you to modify certain terrain materials only (e.g only water or only solid materials etc). Set to null or None for no restriction.
-
setTerrainDataInArea
Modifies terrain within a given area.- Parameters:
terrainID
- the new terrain ID you want to set. Air is 0.area
- the area you want to modify.restriction
- an optional edit restriction. This allows you to modify certain terrain materials only (e.g only water or only solid materials etc). Set to null or None for no restriction.
-
setTerrainDataInArea
public static void setTerrainDataInArea(int terrainID, Vector3i startChunk, Vector3i startBlock, Vector3i endChunk, Vector3i endBlock, EditRestriction restriction) Modifies terrain within a given area.- Parameters:
terrainID
- the new terrain ID you want to set. Air is 0.startChunk
- the start chunk position.startBlock
- the start block position (within the start chunk).endChunk
- the end chunk position.endBlock
- the end block position (within the end chunk).restriction
- an optional edit restriction. This allows you to modify certain terrain materials only (e.g only water or only solid materials etc). Set to null or None for no restriction.
-
setTerrainDataInRadius
public static void setTerrainDataInRadius(int terrainID, int cx, int cy, int cz, int bx, int by, int bz, int radius, EditRestriction restriction) Modifies terrain at a given position within a certain radius (spherical). Note: If the block coordinates exceed the chunk bounds, the chunk coordinates will be recalculated.- Parameters:
terrainID
- the new terrain ID you want to set. Air is 0.cx
- the chunk x coordinate.cy
- the chunk y coordinate.cz
- the chunk z coordinate.bx
- the block x coordinate within the chunk (0-32).by
- the block y coordinate within the chunk (0-64).bz
- the block z coordinate within the chunk (0-32).radius
- the radius (in blocks) of the affected area.restriction
- an optional edit restriction. This allows you to modify certain terrain materials only (e.g only water or only solid materials etc). Set to null or None for no restriction.- Example: Create a hole around the player
- Example: Turn water around player into ice
-
executeWorldEditBatch
Performs a world edit batch, i.e multiple world edits at once. If you want to perform multiple edits, this method is usually much more performant compared to single terrain edits.- Parameters:
batch
- theWorldEditBatch
object containing the batch data.- Example: Clear a whole chunk (fill with air, id 0)
- Example: Create a hole with size 16x16x16 around the player
-
getChunk
Gets a chunk.- Parameters:
cx
- the chunk x offset.cz
- the chunk z offset.- Returns:
- the chunk object. Never null.
-
getChunkPart
Gets a chunk part.- Parameters:
cx
- the chunk part x offset.cy
- the chunk part y offset (vertical).cz
- the chunk part z offset.- Returns:
- the chunk object.
-
triggerExplosion
public static void triggerExplosion(Vector3f position, Quaternion rotation, Vector3f scale, float damageFactor) Creates an explosion in the world.- Parameters:
position
- the global world position (center of the explosion).rotation
- rotation of the explosion.scale
- explosion scale. Default is 1 1 1 (e.g Vector3f.ONE).damageFactor
- explosion damage factor (i.e multiplier for damage applied to players, npcs etc). Default: 1
-