Class PlayerPlaceItemEvent
java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.player.PlayerEvent
net.risingworld.api.events.player.world.PlayerPlaceItemEvent
- All Implemented Interfaces:
Cancellable
Called when a player places an item in the world. This includes persistent item placement, but also placing items
in/on meta object (e.g ores in a furnace, hides on a tanning rack etc).
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the item in inventory that represented this item (i.e that is about to be placed).shortGets the type ID of the item (not to be confused with the global ID of the world item!)intGets the item texture.If this item is placed on/in a meta object (e.g a furnace, grinder etc), this method returns the meta object.Gets the world position of the item.Gets the rotation of the item.getScale()Gets the scale of the item as a Vector3f.Gets the world item that is about to be placed.booleanDetermines if the event is cancelled.booleanGets whether or not this item was placed via creative mode placement.booleanGets whether or not this is a persistent item (i.e an item that does not despawn and is stored in the database).voidsetCancelled(boolean cancel) Cancels this event.voidsetPosition(float x, float y, float z) Changes the item world position, i.e where the item will be placed.voidsetPosition(Vector3f position) Changes the item world position, i.e where the item will be placed.voidsetRotation(Quaternion rotation) Changes the item rotation, i.e how the item will be rotated.voidsetScale(float x, float y, float z) Changes the item scale.voidChanges the item scale.Methods inherited from class net.risingworld.api.events.player.PlayerEvent
getPlayer
-
Method Details
-
getItemID
public short getItemID()Gets the type ID of the item (not to be confused with the global ID of the world item!)- Returns:
- the item type ID.
-
getItemTexture
public int getItemTexture()Gets the item texture.- Returns:
- the item texture (default: 0).
-
isPersistent
public boolean isPersistent()Gets whether or not this is a persistent item (i.e an item that does not despawn and is stored in the database).- Returns:
- true if this is a persistent item, false if not.
-
isCreativeModePlacement
public boolean isCreativeModePlacement()Gets whether or not this item was placed via creative mode placement.- Returns:
- true if this item was placed from a creative mode tool, false if not.
-
getWorldItem
Gets the world item that is about to be placed. Note that this might be null in some cases, especially when placing an item in a meta object that does not have a specific item representation (e.g hides on a tanning rack).- Returns:
- the world item (might be null).
-
getInventoryItem
Gets the item in inventory that represented this item (i.e that is about to be placed). Once this event is processed, the item will be removed from inventory.- Returns:
- the inventory item (or null if this item was not placed from inventory).
-
getPosition
Gets the world position of the item.- Returns:
- the global item position, i.e where the item will be placed.
-
setPosition
Changes the item world position, i.e where the item will be placed.- Parameters:
position- the new item position.
-
setPosition
public void setPosition(float x, float y, float z) Changes the item world position, i.e where the item will be placed.- Parameters:
x- the new item x position.y- the new item y position.z- the new item z position.
-
getRotation
Gets the rotation of the item.- Returns:
- the item rotation, i.e how the item will be rotated.
-
setRotation
Changes the item rotation, i.e how the item will be rotated.- Parameters:
rotation- the new item rotation. Set to null to reset the rotation (Quaternion.IDENTITY).
-
getScale
Gets the scale of the item as a Vector3f.- Returns:
- the item scale. Default scale is (1, 1, 1)
-
setScale
Changes the item scale. Default scale is (1, 1, 1)- Parameters:
position- the new item scale.
-
setScale
public void setScale(float x, float y, float z) Changes the item scale. Default scale is (1, 1, 1)- Parameters:
x- the new item x size.y- the new item y size.z- the new item z size.
-
getMetaObject
If this item is placed on/in a meta object (e.g a furnace, grinder etc), this method returns the meta object. Otherwise null is returned.- Returns:
- the meta object this item is placed on, or null if no meta object is involved.
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableDetermines if the event is cancelled. If an event is cancelled, it will no longer be executed, but other plugins will still receive the event.
Please note: If the event is threaded, cancellation has no effect, i.e the event will still be executed.- Specified by:
isCancelledin interfaceCancellable- Returns:
- true if the event is cancelled, or false if not.
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableCancels this event. This means it will no longer be executed, but other plugins will still receive the event.- Specified by:
setCancelledin interfaceCancellable- Parameters:
cancel- set to true if you want to cancel this event.- Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
-