Klasse World

java.lang.Object
net.risingworld.api.World

public final class World extends Object
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.
  • Methodendetails

    • getName

      public static String getName()
      Gets the world name.
      Gibt zurück:
      the world name.
    • getSeed

      public static String getSeed()
      Gets the world seed, as a string.
      Gibt zurück:
      the world seed.
    • getCreationDate

      public static long getCreationDate()
      Gets the creation date of the world as a timestamp (millis).
      Gibt zurück:
      the creation date.
    • getWorldType

      public static String getWorldType()
      Gets the world type (e.g "Superflat").
      Gibt zurück:
      the world type.
    • getOreAmount

      public static int getOreAmount()
      Gets the ore amount (0-4).
      Gibt zurück:
      the ore amount.
    • getDisabledNpcs

      public static String[] 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.
      Gibt zurück:
      an array containing all disabled npc names, or null if all npcs are enabled.
    • getWorldFolder

      public static File getWorldFolder()
    • getWorldsFolder

      public static File getWorldsFolder()
    • 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.
      Gibt zurück:
      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.
      Parameter:
      x - the world x position.
      y - the world y position.
      z - the world z position.
      Gibt zurück:
      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
      Gibt zurück:
      the default gravity (-9.81)
      Siehe auch:
    • 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.
      Parameter:
      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.
      Parameter:
      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.
      Gibt zurück:
      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.
      Parameter:
      objectID - the object type id.
      variant - the object variant. By default 0
      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.
      Gibt zurück:
      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.
      Parameter:
      clothingID - the clothing type id.
      variant - the clothing variant. By default 0
      stack - 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.
      Gibt zurück:
      a WorldItem representing the clothing item.
      Example: Spawn aviator sunglasses in front of a player
      1//Get position 10 blocks in front of player
      2Vector3f position = Utils.VectorUtils.getXYZInFrontOfPlayer(player, 10f);
      3
      4//Get def of aviator sunglasses (internally called "aviators")
      5Clothing.ClothingDefinition def = Definitions.getClothingDefinition("aviators");
      6
      7//Spawn item
      8World.spawnClothingItem(def.id, 0, 1, 0, 0, position, Quaternion.IDENTITY, true);
    • getItem

      public static WorldItem getItem(long globalID)
    • getAllItems

      public static WorldItem[] getAllItems()
      Gets all world items (i.e items that were either spawned through the spawnItem() method or items that have been dropped by players). The result is returned as a new array.
      Gibt zurück:
      a new array containing all world items. Never null.
      Example: Get all items and delete every item that is close to the player
      1//The player (delete all items in his proximity)
      2Player player = Server.findPlayer("Playername");
      3
      4//Continue only if we have an actual player object (i.e player != null)
      5if(player != null){
      6 //Get array of all world items
      7 WorldItem[] items = getAllItems();
      8
      9 //Iterate over array
      10 for(WorldItem item : items){
      11 //If distance between player and item is less than 10 units,
      12 //delete the item by calling "item.destroy()"
      13 if(item.getPosition().distance(player.getPosition()) <= 10){
      14 item.destroy();
      15 }
      16 }
      17}
    • getAllItemsInRange

      public static WorldItem[] getAllItemsInRange(Vector3f position, float range)
      Gets all world items (i.e items that were either spawned through the spawnItem() 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.
      Parameter:
      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).
      Gibt zurück:
      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
      1//Get all items close to the player
      2Vector3f position = player.getPosition();
      3WorldItem[] items = World.getAllItemsInRange(position, 20f);
      4
      5//Iterate through the array
      6for(WorldItem item : items){
      7 //Get item position
      8 Vector3f itemPosition = item.getPosition();
      9
      10 //Calculate vector from item pos to our world pos
      11 Vector3f impulse = position.subtract(itemPosition).normalizeLocal();
      12
      13 //Set impulse strength to 10 (by multiplying the vector)
      14 impulse.multLocal(10);
      15
      16 //Apply impulse to item
      17 item.applyPhysicalImpulse(impulse);
      18}
    • getAllItemsInArea

      public static WorldItem[] getAllItemsInArea(Area area)
    • findNearestItem

      public static WorldItem findNearestItem(Vector3f position)
      Gets the world item which has the shortest distance to a position.
      Parameter:
      position - the world position.
      Gibt zurück:
      the closest item, or null if no world item exists.
    • findNearestItem

      public static WorldItem findNearestItem(short itemID, Vector3f position)
    • getNumItems

      public static int getNumItems()
      Gets the current amount of global world items (i.e items that have either been spawned by calling spawnItem(short, int, int, net.risingworld.api.utils.Vector3f, net.risingworld.api.utils.Quaternion, boolean), or items that have been dropped by players).
      Gibt zurück:
      the current amount of global world items.
    • spawnNpc

      public static Npc spawnNpc(short typeID, Vector3f position, Quaternion rotation)
      Spawns a new npc in the world.
      Parameter:
      typeID - the npc type id.
      position - the global npc position.
      rotation - the rotation of the npc.
      Gibt zurück:
      the newly spawned npc.
      Example: Spawn npc by using definitions
      1//Get npc definition of a cow
      2Npcs.NpcDefinition npcDef = Definitions.getNpcDefinition("cow");
      3
      4//Get position in front of player
      5Vector3f position = Utils.VectorUtils.getXYZInFrontOfPlayer(player, 5f);
      6
      7//We want the npc to look towards the player. First we have to calculate the
      8//direction to the player (target - origin)
      9Vector3f playerPos = player.getPosition();
      10Vector3f direction = playerPos.subtract(position).normalizeLocal();
      11
      12//Calculate rotation (quaternion)
      13Quaternion rotation = new Quaternion();
      14rotation.lookAt(direction);
      15
      16//Spawn the npc
      17World.spawnNpc(npcDef.id, position, rotation);
    • spawnNpc

      public static Npc spawnNpc(short typeID, int variant, Vector3f position, Quaternion rotation)
      Spawns a new npc in the world.
      Parameter:
      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.
      Gibt zurück:
      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.
      Parameter:
      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.
      Gibt zurück:
      the newly spawned npc.
    • getNpc

      public static Npc getNpc(long globalID)
      Gets the npc with the provided id.
      Parameter:
      globalID - the global id of the npc.
      Gibt zurück:
      the npc with the provided id, or null if this id does not belong to a npc.
    • getAllNpcs

      public static Npc[] getAllNpcs()
      Gets all npcs which are spawned in this world. The result is returned as a new array.
      Gibt zurück:
      a newly created array containing all npcs in the world. Never null.
      Example: Kill all npcs if their health is lower than 10 hp
      1Npc[] npcs = World.getAllNpcs();
      2for(Npc npc : npcs){
      3 if(npc.getHealth() < 10){
      4 npc.kill();
      5 }
      6}
    • getAllNpcs

      public static Npc[] getAllNpcs(short typeID)
      Gets all npcs in the world with the provided type ID. The result is returned as a new array.
      Parameter:
      typeID - the type of the npc you want to incldue in the search.
      Gibt zurück:
      a newly created array containing all npcs with the provided type ID in the world. Never null.
    • getAllNpcsInRange

      public static Npc[] getAllNpcsInRange(Vector3f position, float range)
      Gets all npcs which are in range to a specific world position. The result is returned as a new array.
      Parameter:
      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).
      Gibt zurück:
      a new array containing all npcs which are in range to the given world position. Never null.
    • getAllNpcsInRange

      public 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. The result is returned as a new array.
      Parameter:
      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).
      Gibt zurück:
      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
      1//Get chicken definition
      2Npcs.NpcDefinition def = Definitions.getNpcDefinition("chicken");
      3
      4//Get all chickens in range (using type id from definition)
      5Npc[] npcs = World.getAllNpcsInRange(def.typeid, player.getPosition(), 50);
      6
      7//Go through array (never null) and set alert flag
      8for (Npc npc : npcs) {
      9 npc.setAlerted(true);
      10}
    • getAllNpcsInArea

      public static Npc[] getAllNpcsInArea(Area area)
      Gets all npcs which are inside an area. The result is returned as a new array.
      Parameter:
      area - the area.
      Gibt zurück:
      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.
      Gibt zurück:
      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.
      Gibt zurück:
      the next unuused group ID.
    • findNearestNpc

      public static Npc findNearestNpc(Vector3f position)
      Gets the npc (any npc) which has the shortest distance to a world position.
      Parameter:
      position - the world position.
      Gibt zurück:
      the closest npc, or null if no npc exists.
      Siehe auch:
    • findNearestNpc

      public static Npc findNearestNpc(float x, float y, float z)
      Gets the npc (any npc) which has the shortest distance to a world position.
      Parameter:
      x - the world x position.
      y - the world y position.
      z - the world z position.
      Gibt zurück:
      the closest npc, or null if no npc exists.
      Siehe auch:
    • findNearestNpc

      public static Npc findNearestNpc(short typeID, Vector3f position)
      Gets the npc (with a certain type id) which has the shortest distance to a world position.
      Parameter:
      typeID - the npc type id.
      position - the world position.
      Gibt zurück:
      the closest npc, or null if no npc exists.
      Siehe auch:
    • findNearestNpc

      public 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.
      Parameter:
      typeID - the npc type id.
      x - the world x position.
      y - the world y position.
      z - the world z position.
      Gibt zurück:
      the closest npc, or null if no npc exists.
      Siehe auch:
    • 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.
      Parameter:
      typeID - the npc type id.
      Gibt zurück:
      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.
      Parameter:
      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.
      Gibt zurück:
      the newly spawned vehicle.
    • getVehicle

      public static Vehicle getVehicle(long globalID)
      Gets the vehicle with the provided id.
      Parameter:
      globalID - the global id of the vehicle.
      Gibt zurück:
      the vehicle with the provided id, or null if this id does not belong to a vehicle.
    • getAllVehicles

      public static Vehicle[] getAllVehicles()
      Gets all vehicles which are spawned in this world. The result is returned as a new array.
      Gibt zurück:
      an array containing all vehicles in the world. Never null.
    • getAllVehiclesInRange

      public static Vehicle[] getAllVehiclesInRange(Vector3f position, float range)
      Gets all vehicles which are in range to a specific world position. The result is returned as a new array.
      Parameter:
      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).
      Gibt zurück:
      an array containing all vehicles which are in range to the given world position. Never null.
    • getAllVehiclesInArea

      public static Vehicle[] getAllVehiclesInArea(Area area)
      Gets all vehicles which are inside an area. The result is returned as a new array.
      Parameter:
      area - the area.
      Gibt zurück:
      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.
      Gibt zurück:
      the current amount of vehicles.
    • findNearestVehicle

      public static Vehicle findNearestVehicle(Vector3f position)
      Gets the vehicle (any vehicle) which has the shortest distance to a world position.
      Parameter:
      position - the world position.
      Gibt zurück:
      the closest vehicle, or null if no vehicle exists.
    • findNearestVehicle

      public static Vehicle findNearestVehicle(float x, float y, float z)
      Gets the vehicle (any vehicle) which has the shortest distance to a world position.
      Parameter:
      x - the world x position.
      y - the world y position.
      z - the world z position.
      Gibt zurück:
      the closest vehicle, or null if no vehicle exists.
    • findNearestVehicle

      public static Vehicle findNearestVehicle(short typeID, Vector3f position)
      Gets the vehicle (with a certain type id) which has the shortest distance to a world position.
      Parameter:
      typeID - the vehicle type id.
      position - the world position.
      Gibt zurück:
      the closest vehicle, or null if no such vehicle exists.
    • findNearestVehicle

      public 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.
      Parameter:
      typeID - the vehicle type id.
      x - the world x position.
      y - the world y position.
      z - the world z position.
      Gibt zurück:
      the closest vehicle, or null if no such vehicle exists.
    • createStorage

      public static Storage createStorage(int slots, boolean temporary)
      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.
      Parameter:
      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).
      Gibt zurück:
      the newly created storage.
    • getStorage

      public static Storage getStorage(long globalID)
      Gets the storage with the provided id (i.e the content of the storage).
      Parameter:
      globalID - the global id of the storage.
      Gibt zurück:
      the storage with the specified id, or null if no such storage exists.
    • getAllStorages

      public static Storage[] getAllStorages()
      Gets all storages in this world. The storages are returned as array.
      Gibt zurück:
      a new array containing all storages. Never null.
    • getNumStorages

      public static int getNumStorages()
      Gets the total amount of storages in the world.
      Gibt zurück:
      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.
      Parameter:
      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).
      Gibt zurück:
      the newly created object instance (or null if the object could not be created).
      Example: Spawn a workbench at the player position
      1//Target position for our object
      2Vector3f pos = player.getPosition();
      3
      4//Get object definition
      5Objects.ObjectDefinition def = Definitions.getObjectDefinition("workbench");
      6
      7//Spawn object
      8World.createObject(def.id, 0, 0, pos, Quaternion.IDENTITY, Vector3f.ONE);
    • getObject

      public static ObjectElement getObject(long globalID, int cx, int cy, int cz)
      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).
      Parameter:
      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.
      Gibt zurück:
      an object instance representing the object element in the world, or null if this object does not exist.
    • getMetaObject

      public static MetaObject getMetaObject(long globalID)
      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.
      Parameter:
      globalID - the unique object ID.
      Gibt zurück:
      the meta object, or null if no such meta object was found.
      Example: Check the fuel level of a furnace
      1//Get any object
      2ObjectElement o = World.getObject(...);
      3
      4//Check if object is a furnace (which is a meta object)
      5Objects.ObjectDefinition def = o.getDefinition();
      6if(def.type == Type.Furnace){
      7 //Get meta object
      8 MetaObject furnace = World.getMetaObject(o.globalID);
      9
      10 //Check if meta object is not null and if this furnace requires fuel
      11 if(furnace != null && furnace.requiresFuel()){
      12 //Get fuel lvl
      13 int fuel = furnace.getFuel();
      14 }
      15}
    • removeObject

      public static void removeObject(long globalID, int cx, int cy, int cz, boolean destroy)
    • getSign

      public static Sign getSign(long globalID)
      Gets a sign instance. It's typically bound to an ObjectElement (i.e an actual sign object in the world).
      Parameter:
      globalID - the unique ID of the sign object (i.e the object global ID).
      Gibt zurück:
      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.
      Parameter:
      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).
      Gibt zurück:
      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.
      Parameter:
      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).
      Gibt zurück:
      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.
      Parameter:
      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).
      Gibt zurück:
      the newly created construction element instance (or null if the element could not be created).
    • createConstructionElements

      public static void createConstructionElements(ConstructionPlaceBatch batch)
      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 calling createConstructionElement() for each element.
      Parameter:
      batch - the ConstructionPlaceBatch object containing the batch data.
      Example: Create multiple construction elements efficiently
      1//Create a batch with an initial size of 400
      2ConstructionPlaceBatch batch = new ConstructionPlaceBatch(400);
      3
      4//Get player position (where we want to spawn the elements)
      5Vector3f pos = player.getPosition();
      6
      7//We want to create 400 construction elements (20x20)
      8for (int dx = -10; dx < 10; dx++) {
      9 for (int dz = -10; dz < 10; dz++) {
      10 //Create cylinder (id 1) with texture 200
      11 batch.add(1, 200, 1f, 0, pos.add(dx * 0.5f, 0f, dz * 0.5f), Quaternion.IDENTITY, new Vector3f(0.1f, 2f, 0.1f), Vector3f.ZERO, Vector3f.ONE);
      12 }
      13}
      14
      15//Create construction elements (execute the batch)
      16World.createConstructionElements(batch);
    • getConstructionElement

      public static ConstructionElement getConstructionElement(long globalID, int cx, int cy, int cz)
      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).
      Parameter:
      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.
      Gibt zurück:
      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

      public static void createPlants(PlantPlaceBatch batch)
      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 calling createPlant() for each plants.
      Parameter:
      batch - the PlantPlaceBatch object containing the batch data.
    • getPlant

      public static Plant getPlant(long globalID, int cx, int cy, int cz)
    • 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.
      Parameter:
      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

      public static void setTerrainDataInArea(int terrainID, Area area, EditRestriction restriction)
      Modifies terrain within a given area.
      Parameter:
      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.
      Parameter:
      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.
      Parameter:
      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
      1//Get player chunk and block position
      2Vector3i chunkPos = player.getChunkPosition();
      3Vector3i blockPos = player.getBlockPosition();
      4
      5//Fill radius (16) around player with air (id 0)
      6World.setTerrainDataInRadius(0, chunkPos.x, chunkPos.y, chunkPos.z, blockPos.x, blockPos.y, blockPos.z, 16, EditRestriction.None);

      Example: Turn water around player into ice
      1//Get player chunk and block position
      2Vector3i chunkPos = player.getChunkPosition();
      3Vector3i blockPos = player.getBlockPosition();
      4
      5//Fill radius (32) around player with ice (id 26). Set EditRestriction to WaterOnly
      6World.setTerrainDataInRadius(26, chunkPos.x, chunkPos.y, chunkPos.z, blockPos.x, blockPos.y, blockPos.z, 32, EditRestriction.WaterOnly);
    • executeWorldEditBatch

      public static void executeWorldEditBatch(WorldEditBatch batch)
      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.
      Parameter:
      batch - the WorldEditBatch object containing the batch data.
      Example: Clear a whole chunk (fill with air, id 0)
      1Vector3i c = player.getChunkPosition();
      2
      3//Create a batch object (it is reusable btw)
      4WorldEditBatch batch = new WorldEditBatch();
      5
      6//Populate the batch object with data
      7for (int x = 0; x < Chunk.SIZE_X; x++) {
      8 for (int y = 0; y < ChunkPart.SIZE_Y; y++) {
      9 for (int z = 0; z < Chunk.SIZE_Z; z++) {
      10 //Add the edit data to the batch (id 0, chunk and block pos)
      11 batch.add(0, c.x, c.y, c.z, x, y, z);
      12 }
      13 }
      14}
      15
      16//Execute the batch
      17World.executeWorldEditBatch(batch);

      Example: Create a hole with size 16x16x16 around the player
      1Vector3i c = player.getChunkPosition();
      2Vector3i b = player.getBlockPosition();
      3
      4//Create a batch object with optional initial capacity
      5WorldEditBatch batch = new WorldEditBatch(16 * 16 * 16);
      6
      7//Populate the batch object with data
      8for(int dx = -8; dx < 8; dx++) {
      9 for(int dy = -8; dy < 8; dy++) {
      10 for(int dz = -8; dz < 8; dz++) {
      11 //Check if delta is within 8 block radius
      12 if(Utils.MathUtils.length(dx, dy, dz) <= 8) {
      13 //Add to batch. We don't have to recalculate the chunk pos, that's done automatically
      14 batch.add(0, c.x, c.y, c.z, b.x + dx, b.y + dy, b.z + dz);
      15 }
      16 }
      17 }
      18}
      19
      20//Execute the batch
      21World.executeWorldEditBatch(batch);
    • getChunk

      public static Chunk getChunk(int cx, int cz)
      Gets a chunk.
      Parameter:
      cx - the chunk x offset.
      cz - the chunk z offset.
      Gibt zurück:
      the chunk object. Never null.
    • getChunkPart

      public static ChunkPart getChunkPart(int cx, int cy, int cz)
      Gets a chunk part.
      Parameter:
      cx - the chunk part x offset.
      cy - the chunk part y offset (vertical).
      cz - the chunk part z offset.
      Gibt zurück:
      the chunk object.
    • triggerExplosion

      public static void triggerExplosion(Vector3f position, Quaternion rotation, Vector3f scale, float damageFactor)
      Creates an explosion in the world.
      Parameter:
      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