Class MetaObject

java.lang.Object
net.risingworld.api.objects.MetaObject

public class MetaObject extends Object
Represents a meta object, which is typically any kind of processing station, e.g a furnace, grinders, cooking station etc.
  • Method Details

    • getID

      public long getID()
      Gets the global, unique ID of the object.
      Returns:
      the unique ID.
    • isValid

      public boolean isValid()
      Checks if this instance is still valid.
      Returns:
      true if the instance is valid, false if not.
    • getWorldPosition

      public Vector3f getWorldPosition()
      Gets the world position of the object.
      Returns:
      the object world position.
    • getChunkPositionX

      public int getChunkPositionX()
      Gets the x offset of the chunk (which contains the object).
      Returns:
      the x chunk offset.
    • getChunkPositionY

      public int getChunkPositionY()
      Gets the y offset of the chunk (which contains the object).
      Returns:
      the y chunk offset.
    • getChunkPositionZ

      public int getChunkPositionZ()
      Gets the z offset of the chunk (which contains the object).
      Returns:
      the z chunk offset.
    • getChunkPosition

      public Vector3i getChunkPosition()
      Gets the chunk position of the meta object.
      Returns:
      the meta object chunk coordinates.
    • getStatus

      public int getStatus()
      Gets the current status of the meta object.
      Returns:
      the meta object status.
    • setStatus

      public void setStatus(int status, boolean updateObject)
      Sets the status of the meta object. Optionally updates the actual object representation as well (recommended).
      Parameters:
      status - the new status.
      updateObject - true if you want to change the actual object representation as well, false if you only want to change the value of the meta object. For example, if you want to turn on a furnace and you set this value to false, the furnace wouldn't turn on, but it would still start smelting items.
    • requiresFuel

      public boolean requiresFuel()
      Gets whether or not this meta object requires fuel for processing (e.g a furnace).
      Returns:
      true if this object requires fuel, false if not.
    • getFuel

      public int getFuel()
      Gets the current fuel value of the meta object (only if it requires fuel).
      Returns:
      the current fuel value of the meta object.
      See Also:
    • setFuel

      public void setFuel(int fuel)
      Sets a new fuel value for the meta object. Only relevant if it requires fuel.
      Parameters:
      fuel - the new fuel value.
      See Also:
    • getRelatedObject

      public ObjectElement getRelatedObject()
      Gets the object element which represents this meta object in the world.
      Returns:
      the actual object representation in the world.
    • getObjectInfoDefinition

      public Objects.ObjectInfoDefinition getObjectInfoDefinition()
    • getItems

      public WorldItem[] getItems()
      Gets an array containing all items which are currently associated with this meta object (usually these are the items which are placed in this object, e.g ores in a furnace etc).
      Returns:
      a new array containing all items associated with this meta object. Returns null if there are no items in this meta object (or if the meta object cannot store items).
      Example: Destroy all items in furnace
      1MetaObject furnace = ...;
      2
      3//Get all items in our furnace
      4WorldItem[] items = furnace.getItems();
      5
      6//Check if array is not null (i.e furnace contains items)
      7if (items != null) {
      8 //Go through all items and destroy them
      9 for (WorldItem item : items) {
      10 //If item is not null, destroy it
      11 if (item != null) item.destroy(false);
      12 }
      13}
    • setItems

      public void setItems(WorldItem[] items)
      Assigns new items to this meta object. Also use this method if you have changed the array that was retrieved via getItems(). This method automatically removes the old items from the meta object.
      Parameters:
      items - the new items array you want to assign. Set null to remove all items from the meta object.
    • triggerUpdate

      public void triggerUpdate()
      Forces an update of the meta object. Usually it's not necessary to call this method. Only call this method if you have changed the progress value of an item (associated with this meta object) and want the change to become active immediately (without waiting until the game performs the regular update).