Class WorldItem

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

public final class WorldItem extends Object
Represents an item that exists in the game world, for example an item that has been dropped by a player.
  • Method Details

    • getGlobalID

      public long getGlobalID()
      Gets the global ID if this item. This ID is unique, but it is only valid until the server restarts.
      Returns:
      the global ID of this item.
    • isValid

      public boolean isValid()
    • getDefinition

      public Items.ItemDefinition getDefinition()
      Gets the item definition of this item.
      Returns:
      the definition of this item.
    • getName

      public String getName()
      Gets the ingame name (not the localized name) of the item.
      Returns:
      the name of the item, e.g "pickaxe".
    • getTypeID

      public short getTypeID()
      Gets the type ID of the item.
      Returns:
      the type ID of the item.
    • getVariant

      public int getVariant()
      Gets the item variant, i.e the texture of the item. For construction elements, for example, this is the texture.
      Returns:
      the variant/texture of the item. Usually this returns for most regular items.
    • getCreationDate

      public long getCreationDate()
      Gets the creation/spawn date of this item (timestamp in seconds).
      Returns:
      a unix timestamp (seconds) representing the creation/spawn date of this item.
    • getStack

      public int getStack()
      Gets the current stack size of the item.
      Returns:
      the stack size of the item.
    • getMaxStackSize

      public int getMaxStackSize()
      Gets the max possible stack size of the item.
      Returns:
      the max stack size of the item (between 1 and 64).
    • getValue

      public float getValue()
      Gets the current value of the item. Usually the value is used to describe a "fill level" or "charging level", for example it describes how much water is in a bottle etc.
      Returns:
      the value of the item. 0 for most items.
    • getStatus

      public short getStatus()
      Gets the current status of the item. The status is used to store additional information about an item (for example the water type in a bucket, or if an electronic device is switched on/off).
      Returns:
      the status of the item.
    • setStatus

      public void setStatus(short status)
    • getModifier

      public Items.Modifier getModifier()
    • getDurability

      public int getDurability()
    • getRelatedPlayer

      public Player getRelatedPlayer()
      This function returns the player that is related to this item. Usually this is the player who has dropped the item.
      Returns:
      the related player of this item, or null if no player was found.
    • getWorldItemType

      public WorldItem.WorldItemType getWorldItemType()
    • setWorldItemType

      public void setWorldItemType(WorldItem.WorldItemType type)
    • setDespawnTimer

      public void setDespawnTimer(float despawnTime)
      Sets the despawn time (remaining seconds until item despawns). Only relevant for items that can despawn.
      Parameters:
      despawnTime - the remaining seconds until this item should despawn.
    • destroy

      public void destroy(boolean silent)
      Destroys (i.e despawns) this item.
      Parameters:
      silent - if true, the item simply despawns. Otherwise it breaks (spawns debris etc).
    • getPosition

      public Vector3f getPosition()
      Gets a Vector3f containing the current global x, y and z coordinate of this item.
      Returns:
      the global item position as a Vector3f (float).
    • setPosition

      public void setPosition(Vector3f position)
      Sets the global position of the item.
      Parameters:
      position - a Vector3f (float) containing the global target position.
    • setPosition

      public void setPosition(float x, float y, float z)
      Sets the global position of the item.
      Parameters:
      x - global X coordinate to set (horizontally).
      y - global Y coordinate to set (vertically).
      z - global Z coordinate to set (horizontally).
    • getRotation

      public Quaternion getRotation()
      Gets a Quaternion containing the current rotation of this item.
      Returns:
      the item rotation as a Quaternion.
    • setRotation

      public void setRotation(Quaternion rotation)
      Sets the rotation of this item.
      Parameters:
      rotation - a Quaternion representing the rotation.
    • setPositionAndRotation

      public void setPositionAndRotation(Vector3f position, Quaternion rotation)
    • applyPhysicalImpulse

      public void applyPhysicalImpulse(Vector3f impulse)
      Applies a physical impulse to the item (applied to the center). Only works if this is a physical item.
      Parameters:
      impulse - the impulse you want to apply to the item.
    • applyPhysicalImpulse

      public void applyPhysicalImpulse(Vector3f offset, Vector3f impulse)
      Applies a physical impulse to the item (applied to the position defined by the local offset). Only works if this is a physical item.
      Parameters:
      offset - the local offset (relative to the item center) where the impulse should be applied.
      impulse - the impulse you want to apply to the item.