Class PlayerDestroyItemEvent


public class PlayerDestroyItemEvent extends PlayerEvent
PlayerDestroyItemEvent is fired when a player destroys an item.
This event is fired whenever a player destroys an item in MultiPlayerGameMode.destroyBlock(BlockPos), MultiPlayerGameMode.useItem(Player, InteractionHand), MultiPlayerGameMode.useItemOn(LocalPlayer, InteractionHand, BlockHitResult) , Player.attack(Entity), Player#hurtCurrentlyUsedShield(float), Player.interactOn(Entity, InteractionHand), ForgeHooks.getCraftingRemainingItem(ItemStack), ServerPlayerGameMode.useItem(ServerPlayer, Level, ItemStack, InteractionHand) , ServerPlayerGameMode.useItemOn(ServerPlayer, Level, ItemStack, InteractionHand, BlockHitResult) and ServerPlayerGameMode.destroyBlock(BlockPos).

original contains the original ItemStack before the item was destroyed.
(@link #hand) contains the hand that the current item was held in.

This event is not Cancelable.

This event does not have a result. Event.HasResult

This event is fired from ForgeEventFactory.onPlayerDestroyItem(Player, ItemStack, InteractionHand).
This event is fired on the MinecraftForge.EVENT_BUS.
  • Field Details

    • original

      @NotNull private final @NotNull ItemStack original
    • slot

      @Nullable private final @Nullable EquipmentSlot slot
  • Constructor Details

    • PlayerDestroyItemEvent

      public PlayerDestroyItemEvent(Player player, @NotNull @NotNull ItemStack original, @Nullable @Nullable EquipmentSlot slot)
  • Method Details

    • getOriginal

      @NotNull public @NotNull ItemStack getOriginal()
    • getSlot

      @Nullable public @Nullable EquipmentSlot getSlot()