Class HeldItemChangedEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
com.pixelmonmod.pixelmon.api.events.HeldItemChangedEvent
Direct Known Subclasses:
HeldItemChangedEvent.Post, HeldItemChangedEvent.Pre

public class HeldItemChangedEvent extends net.minecraftforge.eventbus.api.Event
Event fired whenever a Pokémon's held item is changed. Use HeldItemChangedEvent.Pre or HeldItemChangedEvent.Post As of the time of creation, this captures all Pixelmon-handled out-of-battle held item changes. However, it is possible for sidemods to modify the held item without triggering this event, and in-battle held item changes are ignored.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Event fired after a Pokémon's held item is changed.
    static class 
    Cancelable event fired before a Pokémon's held item is changed.

    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

    Fields
    Modifier and Type
    Field
    Description
    protected net.minecraft.world.item.ItemStack
    The held item to use.
    protected final net.minecraft.server.level.ServerPlayer
    The player owner of the Pokémon, if there is a player owner.
    protected final Pokemon
    The Pokémon who is getting the new item.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    HeldItemChangedEvent(net.minecraft.server.level.ServerPlayer player, Pokemon pokemon, net.minecraft.world.item.ItemStack newHeldItem)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.ItemStack
    Gets the ItemStack of the held item that the Pokémon is getting.
    net.minecraft.server.level.ServerPlayer
    Gets the ServerPlayer who is getting the new item.
    Gets the Pokemon who is getting the new item.
    Gets the Species of the Pokémon who is getting the new item.

    Methods inherited from class net.minecraftforge.eventbus.api.Event

    getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • player

      protected final net.minecraft.server.level.ServerPlayer player
      The player owner of the Pokémon, if there is a player owner.
    • pokemon

      protected final Pokemon pokemon
      The Pokémon who is getting the new item.
    • heldItem

      @Nonnull protected net.minecraft.world.item.ItemStack heldItem
      The held item to use. This may be modified during HeldItemChangedEvent.Pre.
  • Constructor Details

    • HeldItemChangedEvent

      protected HeldItemChangedEvent(@Nullable net.minecraft.server.level.ServerPlayer player, Pokemon pokemon, net.minecraft.world.item.ItemStack newHeldItem)
  • Method Details

    • getSpecies

      public Species getSpecies()
      Gets the Species of the Pokémon who is getting the new item.
      Returns:
      The Pokémon's species.
    • getPokemon

      public Pokemon getPokemon()
      Gets the Pokemon who is getting the new item.
      Returns:
      The Pokémon who is getting the new item.
    • getPlayer

      public net.minecraft.server.level.ServerPlayer getPlayer()
      Gets the ServerPlayer who is getting the new item.
      Returns:
      The player who is getting the new item
    • getHeldItem

      @Nonnull public net.minecraft.world.item.ItemStack getHeldItem()
      Gets the ItemStack of the held item that the Pokémon is getting.
      Returns:
      The held item that the Pokémon is getting.