Class BagItemEvent.SelectItem

java.lang.Object
net.neoforged.bus.api.Event
Direct Known Subclasses:
BagItemEvent.SelectItem.Post, BagItemEvent.SelectItem.Pre
Enclosing class:
BagItemEvent

public static class BagItemEvent.SelectItem extends BagItemEvent
This event is fired when the client attempts to use an item from their bag, and it is subequently removed from their inventory and then given to the battle controller.

This event is fired before the UseBattleItemEvent and should be used to modify item removal if you've added custom items to the list in the BagItemEvent.CollectItems.Pre event

  • Field Details

    • selectedItem

      protected final net.minecraft.world.item.ItemStack selectedItem
    • foundItem

      protected net.minecraft.world.item.ItemStack foundItem
  • Constructor Details

    • SelectItem

      public SelectItem(BattleController battleController, String identifier, net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack selectedItem, net.minecraft.world.item.ItemStack foundItem)
  • Method Details

    • getSelectedItem

      public net.minecraft.world.item.ItemStack getSelectedItem()
      The ItemStack selected by the player. This may not match the found item if a fake item was selected.
      Returns:
      The ItemStack selected by the player.
    • getFoundItem

      public net.minecraft.world.item.ItemStack getFoundItem()
      The ItemStack found by the inventory scan performed. This may be null if a fake item was selected. In order for the item use to be successful, this must be set to a non-null value.
      Returns:
      The ItemStack found by the inventory scan.