Class UseBattleItemEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
com.pixelmonmod.pixelmon.api.events.battles.BattleEvent
com.pixelmonmod.pixelmon.api.events.battles.UseBattleItemEvent

public class UseBattleItemEvent extends BattleEvent
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 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.

  • Field Details

    • participant

      protected final BattleParticipant participant
    • user

      protected final PixelmonWrapper user
    • target

      protected PixelmonWrapper 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

      public BattleParticipant getParticipant()
    • getUser

      public PixelmonWrapper getUser()
      Gets the user of the item
      Returns:
      The user
    • getTarget

      public PixelmonWrapper getTarget()
      Gets the target of the item being used In self targetting instances this is {@link this#getUser()}
      Returns:
      The target pokemon
    • setTarget

      public void setTarget(PixelmonWrapper target)
      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 never null 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 never null 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.