Package net.risingworld.api.objects
Class WorldItem
java.lang.Object
net.risingworld.api.objects.WorldItem
Represents an item that exists in the game world, for example an item that has
been dropped by a player.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
applyPhysicalImpulse
(Vector3f impulse) Applies a physical impulse to the item (applied to the center).void
applyPhysicalImpulse
(Vector3f offset, Vector3f impulse) Applies a physical impulse to the item (applied to the position defined by the local offset).void
destroy
(boolean silent) Destroys (i.e despawns) this item.long
Gets the creation/spawn date of this item (timestamp in seconds).Gets the item definition of this item.int
long
Gets the global ID if this item.Only relevant if this item is processed by a meta object: Gets the item info definition of this item if it's processed by the meta object.int
Gets the max possible stack size of the item.getName()
Gets the ingame name (not the localized name) of the item.Gets a Vector3f containing the current global x, y and z coordinate of this item.float
Only relevant if this item is processed by a meta object: Gets the current item progression value (e.g smelting/cooking progress etc).If this item belongs to a meta object (i.e ifWorldItemType
isWorldItemType.MetaObject
), this method returns the meta object.This function returns the player that is related to this item.Gets a Quaternion containing the current rotation of this item.int
getStack()
Gets the current stack size of the item.short
Gets the current status of the item.short
Gets the type ID of the item.float
getValue()
Gets the current value of the item.int
Gets the item variant, i.e the texture of the item.boolean
isValid()
void
setDespawnTimer
(float despawnTime) Sets the despawn time (remaining seconds until item despawns).void
setPosition
(float x, float y, float z) Sets the global position of the item.void
setPosition
(Vector3f position) Sets the global position of the item.void
setPositionAndRotation
(Vector3f position, Quaternion rotation) void
setProgress
(float progress) Only relevant if this item is processed by a meta object: Sets the current item progression value (e.g smelting/cooking progress etc).void
setRotation
(Quaternion rotation) Sets the rotation of this item.void
setStatus
(short status) void
-
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
Gets the item definition of this item.- Returns:
- the definition of this item.
-
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
-
getDurability
public int getDurability() -
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
-
setWorldItemType
-
getRelatedMetaObject
If this item belongs to a meta object (i.e ifWorldItemType
isWorldItemType.MetaObject
), this method returns the meta object. Otherwise null is returned.- Returns:
- the related meta object, or null if this item does not belong to a meta object.
-
getInfoDefinition
Only relevant if this item is processed by a meta object: Gets the item info definition of this item if it's processed by the meta object.- Returns:
- the info definition of this item (only if item is bound to a meta object, else null is returned).
-
getProgress
public float getProgress()Only relevant if this item is processed by a meta object: Gets the current item progression value (e.g smelting/cooking progress etc).- Returns:
- the item progress value (if processed by a meta object).
-
setProgress
public void setProgress(float progress) Only relevant if this item is processed by a meta object: Sets the current item progression value (e.g smelting/cooking progress etc). The max progression value is determined by theItems.ItemInfo
definition.- Parameters:
progress
- the new progress value.- Example: Set full progression for item
-
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
Gets a Vector3f containing the current global x, y and z coordinate of this item.- Returns:
- the global item position as a Vector3f (float).
- Example:
-
setPosition
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
Gets a Quaternion containing the current rotation of this item.- Returns:
- the item rotation as a Quaternion.
-
setRotation
Sets the rotation of this item.- Parameters:
rotation
- a Quaternion representing the rotation.
-
setPositionAndRotation
-
applyPhysicalImpulse
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
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.
-