Package net.risingworld.api.events.world
Class ItemTransformEvent
java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.world.ItemTransformEvent
- All Implemented Interfaces:
Cancellable
Called when a world item transforms, i.e when the item id changes. Usually this happens
when cooking food or smelting ores (so this event is triggered when the item changes
its state from raw to cooked, or if the ore is smelted into an ingot etc)
Example: If ore gets crushed by grinder, randomly turn it into a gold ingot Example: Notify furnace owner when ore is smelted
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Determines why theItemTransformEvent
was triggered exactly (i.e what caused the item to transform). -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetItem()
Gets the world item that's about to transform.Gets the meta object that was involved in this process, i.e the object that processed the items.int
Gets the new stack size of the item.short
Gets the new target item type ID.long
Gets the unique global ID of the meta object which processsed this item (e.g the furnace ID).Gets the definition of the related meta object (which processes this item, e.g the furnace, grinder etc).short
Gets the type ID of the meta object.Gets the processing type (related to the meta object processing this item), i.e how the item was processed.Gets the trigger of the item transformation, i.e what caused the item to transform.boolean
Determines if the event is cancelled.void
setCancelled
(boolean cancel) Cancels this event.void
setNewStack
(int newStack) Overrides the stack size of the item.void
setNewTypeID
(short newTypeID) Overrides the target item type ID.
-
Method Details
-
getItem
Gets the world item that's about to transform.- Returns:
- the world item that's about to transform.
-
getNewTypeID
public short getNewTypeID()Gets the new target item type ID. This means this item will transform to this item (e.g ifgetItem()
returns a raw steak,getNewTypeID()
would usually return the type ID of a cooked steak etc).- Returns:
- the new type ID.
-
getNewStack
public int getNewStack()Gets the new stack size of the item.- Returns:
- the new stack size (amount of items).
-
setNewTypeID
public void setNewTypeID(short newTypeID) Overrides the target item type ID.- Parameters:
newTypeID
- the new type ID.
-
setNewStack
public void setNewStack(int newStack) Overrides the stack size of the item.- Parameters:
newStack
- the new stack size (amount of items).
-
getObjectID
public long getObjectID()Gets the unique global ID of the meta object which processsed this item (e.g the furnace ID). Returns -1 if the transform wasn't triggered by a meta object (furnace, grinder etc).- Returns:
- the meta object ID.
-
getObjectTypeID
public short getObjectTypeID()Gets the type ID of the meta object.- Returns:
- the meta object type ID.
-
getTrigger
Gets the trigger of the item transformation, i.e what caused the item to transform.- Returns:
- the trigger of the item transformation.
-
getMetaObject
Gets the meta object that was involved in this process, i.e the object that processed the items. For example, this is a furnace which smelted ores, or a grinder which crushed items etc. Only ifgetTrigger()
isTrigger.MetaObject
, else null is returned.- Returns:
- the object that was involved in this event (e.g furnace, grinder, grill etc), or null if no object was involved.
-
getObjectInfoDefinition
Gets the definition of the related meta object (which processes this item, e.g the furnace, grinder etc). It provides more information about how this item was processed and about the meta object.- Returns:
- the related meta object definition.
-
getProcessingType
Gets the processing type (related to the meta object processing this item), i.e how the item was processed. If the item was not processed by an object, null is returned.- Returns:
- the processing type (resulting into the item transformation), or null if the item transform was not related to an object.
-
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 interfaceCancellable
- 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 interfaceCancellable
- Parameters:
cancel
- set to true if you want to cancel this event.- Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
-