Class UseBattleItemEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
com.pixelmonmod.pixelmon.api.events.battles.BattleEvent
com.pixelmonmod.pixelmon.api.events.battles.UseBattleItemEvent
Event fired when an item is about to be used in battle. This is during the execution of battle turns, not in
the moment that the participant decided to use an item.
The target, used ItemStack, and the additionalInfo (in the case of self-targeting item usage) are all mutable but if you decide to use these then first understand how they work for the item you're working with. For items being used on the user, the value of
Cancelling this event will prevent the item from being consumed and from any messages being sent about the item. Note: this will mean the user of the item will do nothing during their turn.
The target, used ItemStack, and the additionalInfo (in the case of self-targeting item usage) are all mutable but if you decide to use these then first understand how they work for the item you're working with. For items being used on the user, the value of
target
and user
will be the same. For
items being used on a target, additionalInfo
will be equal to -1
. Cancelling this event will prevent the item from being consumed and from any messages being sent about the item. Note: this will mean the user of the item will do nothing during their turn.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected final BattleParticipant
protected net.minecraft.world.item.ItemStack
protected PixelmonWrapper
protected final PixelmonWrapper
Fields inherited from class com.pixelmonmod.pixelmon.api.events.battles.BattleEvent
battleController
-
Constructor Summary
ConstructorDescriptionUseBattleItemEvent
(PixelmonWrapper user, PixelmonWrapper target, net.minecraft.world.item.ItemStack stack, int additionalInfo) -
Method Summary
Modifier and TypeMethodDescriptionint
Additional information in integer form that the specific item might need to function.net.minecraft.world.item.ItemStack
getStack()
The ItemStack being used on the Pokémon.Gets the target of the item being used In self targetting instances this is {@link this#getUser()}getUser()
Gets the user of the itemvoid
setAdditionalInfo
(int additionalInfo) Additional information in integer form that the specific item might need to function.void
setStack
(net.minecraft.world.item.ItemStack stack) The ItemStack being used on the Pokémon.void
setTarget
(PixelmonWrapper target) Sets the targetMethods inherited from class com.pixelmonmod.pixelmon.api.events.battles.BattleEvent
getBattleController
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
-
Field Details
-
participant
-
user
-
target
-
stack
protected net.minecraft.world.item.ItemStack stack -
additionalInfo
protected int additionalInfo
-
-
Constructor Details
-
UseBattleItemEvent
public UseBattleItemEvent(PixelmonWrapper user, PixelmonWrapper target, net.minecraft.world.item.ItemStack stack, int additionalInfo)
-
-
Method Details
-
getParticipant
-
getUser
Gets the user of the item- Returns:
- The user
-
getTarget
Gets the target of the item being used In self targetting instances this is {@link this#getUser()}- Returns:
- The target pokemon
-
setTarget
Sets the target- Parameters:
target
- The new target
-
getStack
public net.minecraft.world.item.ItemStack getStack()The ItemStack being used on the Pokémon. This is the exact ItemStack from the inventory that will be consumed. You are free to modify this value so long as it is nevernull
and is never wrapping an item that doesn't extend PixelmonItem. -
setStack
public void setStack(net.minecraft.world.item.ItemStack stack) The ItemStack being used on the Pokémon. This is the exact ItemStack from the inventory that will be consumed. You are free to modify this value so long as it is nevernull
and is never wrapping an item that doesn't extend PixelmonItem. -
getAdditionalInfo
public int getAdditionalInfo()Additional information in integer form that the specific item might need to function. At time of writing, this is -1 for when the item is self-targeting, and in the specific case of Ether usage it is the move index. In all other cases this is zero. As a consequence, this value only needs changing if you are changing the target move of an Ether usage or are changing the used item to an Ether. Highly unlikely, but here you go. -
setAdditionalInfo
public void setAdditionalInfo(int additionalInfo) Additional information in integer form that the specific item might need to function. At time of writing, this is -1 for when the item is self-targeting, and in the specific case of Ether usage it is the move index. In all other cases this is zero. As a consequence, this value only needs changing if you are changing the target move of an Ether usage or are changing the used item to an Ether. Highly unlikely, but here you go.
-