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

public final class PlayerPlaceItemEvent extends PlayerEvent implements 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).
  • 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

      public WorldItem 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

      public Item 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

      public Vector3f getPosition()
      Gets the world position of the item.
      Returns:
      the global item position, i.e where the item will be placed.
    • setPosition

      public void setPosition(Vector3f position)
      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

      public Quaternion getRotation()
      Gets the rotation of the item.
      Returns:
      the item rotation, i.e how the item will be rotated.
    • setRotation

      public void setRotation(Quaternion rotation)
      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

      public Vector3f getScale()
      Gets the scale of the item as a Vector3f.
      Returns:
      the item scale. Default scale is (1, 1, 1)
    • setScale

      public void setScale(Vector3f position)
      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

      public MetaObject 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: Cancellable
      Determines 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:
      isCancelled in interface Cancellable
      Returns:
      true if the event is cancelled, or false if not.
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Cancels this event. This means it will no longer be executed, but other plugins will still receive the event.

      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - set to true if you want to cancel this event.
      Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
      1//Listener class
      2public class PlayerListener implements Listener{
      3 @EventMethod
      4 public void onEnterArea(PlayerEnterAreaEvent evt){
      5 //Now the player will not be able to enter the area, i.e.
      6 //he will be teleported back to his old position (outside the area)
      7 evt.setCancelled(true);
      8 }
      9}