Class ObjectElement
java.lang.Object
net.risingworld.api.objects.world.ObjectElement
Represents an "ObjectElement" which was placed in the world (or spawned naturally).
This could be furniture, doors, lamps etc. An ObjectElement is always bound to a
chunk.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteAttribute
(String key) Removes a player attribute.void
destroy
(boolean silent) Destroys the object.boolean
getAttribute
(String key) Gets the value to which the specified key is mapped, or null if no attribute is stored for that key.Gets a set containing all keys and attributes of this object.int
Gets the x offset of the chunk (which contains the object).int
Gets the y offset of the chunk (which contains the object).int
Gets the z offset of the chunk (which contains the object).int
getColor()
Gets the object color.long
Gets a unix timestamp (seconds) when this element was first spawned / placedGets the object definition (containing all relevant meta data of this object type).long
Gets the unique global ID of the object.long
getInfo()
int
Gets the database ID of the player who placed the object.Gets the rotation of this object.getScale()
Gets the scale (along x, y and z) of this object.byte
Gets the current status of the object.short
Gets the remaining strength of the object (if strength goes to 0, e.g after hitting the object, the object breaks).short
Gets the object type ID.byte
Gets the object variant.Gets the world position of this object.boolean
hasAttribute
(String key) Gets whether or not the provided attribute exists.boolean
hasAttribute
(String key, Class type) Gets whether or not the provided attribute exists (also checks if it has a specific type).int
hashCode()
boolean
isValid()
void
setAttribute
(String key, Object value) Stores an attribute for this object.void
setColor
(int color) Sets a new color for this object.void
Sets a new color for this object.void
setInfo
(long infoID) void
setPlayerDbID
(int dbID) Changes the owner database ID (i.e the database ID of the player who should be considered the object owner).void
setRotation
(Quaternion rotation) Sets the rotation of this object.void
setScale
(float x, float y, float z) Sets a new scale for this object.void
Sets a new scale for this object.void
setStatus
(byte status) Changes the status of the object.void
setStrength
(short strength) Sets a new strength for the object.
-
Method Details
-
isValid
public boolean isValid() -
getGlobalID
public long getGlobalID()Gets the unique global ID of the object.- Returns:
- the object global ID.
-
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.
-
getTypeID
public short getTypeID()Gets the object type ID.- Returns:
- the object type ID.
-
getVariant
public byte getVariant()Gets the object variant. Most objects don't have additional variants. The default variant is 0.- Returns:
- the object variant.
-
getDefinition
Gets the object definition (containing all relevant meta data of this object type).- Returns:
- the object definition.
-
getPlayerDbID
public int getPlayerDbID()Gets the database ID of the player who placed the object. -1 for naturally spawned objects- Returns:
- the owner database ID, or -1 if this object was spawned naturally.
-
setPlayerDbID
public void setPlayerDbID(int dbID) Changes the owner database ID (i.e the database ID of the player who should be considered the object owner). Set to -1 to remove ownership.- Parameters:
dbID
- the unique database ID of the new owner, or -1 to remove ownership.
-
getCreationDate
public long getCreationDate()Gets a unix timestamp (seconds) when this element was first spawned / placed- Returns:
- a unix timestamp representing the creation date of the object.
-
getWorldPosition
Gets the world position of this object.- Returns:
- the global position.
-
getRotation
Gets the rotation of this object.- Returns:
- the object rotation.
-
setRotation
Sets the rotation of this object.- Parameters:
rotation
- the new rotation you want to set.
-
getScale
Gets the scale (along x, y and z) of this object. By default, the scale is 1 1 1- Returns:
- a new Vector3f containing the object scale factors.
-
setScale
public void setScale(float x, float y, float z) Sets a new scale for this object.- Parameters:
x
- the new scale along x (width).y
- the new scale along y (height).z
- the new scale along z (depth).
-
setScale
Sets a new scale for this object.- Parameters:
scale
- the new scale along x (width), y (height) and z (depth).
-
getColor
public int getColor()Gets the object color. If no color is set, 0 is returned.- Returns:
- the object color as int rgba value.
-
setColor
public void setColor(int color) Sets a new color for this object.- Parameters:
color
- the new color as int rgba value.
-
setColor
Sets a new color for this object.- Parameters:
color
- the new color you want to set.
-
getStatus
public byte getStatus()Gets the current status of the object. Only certain objects have a "status" - for instance, it determines if doors are opened or closed, or lamps turned on / off. The default status is usually 0.- Returns:
- the current status of the object.
-
setStatus
public void setStatus(byte status) Changes the status of the object. This is not supported by all objects! For example, it's used to specify the door status (0 == closed, 1 == opened), furnace status (depending on the furnace, status 0-3), chests (only to represent the visual state) etc.- Parameters:
status
- the new object status. Note that the new status gets saved and is still active after a server restart (until someone else changes the status again).- Example: When a player tries to destroy a door, just open it instead
-
getInfo
public long getInfo() -
setInfo
public void setInfo(long infoID) -
getStrength
public short getStrength()Gets the remaining strength of the object (if strength goes to 0, e.g after hitting the object, the object breaks).- Returns:
- the object strength.
-
setStrength
public void setStrength(short strength) Sets a new strength for the object. If you want to break the object, calldestroy(boolean)
instead.- Parameters:
strength
- the new strength you want to set.
-
destroy
public void destroy(boolean silent) Destroys the object.- Parameters:
silent
- true if you just want to remove the object, false if you want it to actually break (spawn debris, play break sound etc)
-
setAttribute
Stores an attribute for this object. You can store any type. Note that all attributes will be reset upon server restart!- Parameters:
key
- the name of the attribute.value
- the value/object you want to store. Set null to remove the attribute.
-
getAttribute
Gets the value to which the specified key is mapped, or null if no attribute is stored for that key.- Parameters:
key
- the name of the attribute.- Returns:
- the attribute that is stored for that key, or null of the key does not exists.
-
hasAttribute
Gets whether or not the provided attribute exists.- Parameters:
key
- the name of the attribute.- Returns:
- true if the attribute exists, false if not.
-
hasAttribute
Gets whether or not the provided attribute exists (also checks if it has a specific type).- Parameters:
key
- the name of the attribute.type
- the type of the attribute- Returns:
- true if the attribute exists and if it has the desired type, false if not.
-
deleteAttribute
Removes a player attribute. Does nothing if the attribute doesn't exist.- Parameters:
key
- the name of the attribute you want to delete.
-
getAttributes
Gets a set containing all keys and attributes of this object.
Be careful when modifying the set, because that affects the attributes.- Returns:
- a set containing all keys and attributes.
-
equals
-
hashCode
public int hashCode()
-