Interface ItemClickBehaviorCallback

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ItemClickBehaviorCallback

A single event that allows for overriding item behavior otherwise implemented via ItemStack.overrideStackedOnOther(Slot, ClickAction, Player) and ItemStack.overrideOtherStackedOnMe(ItemStack, Slot, ClickAction, Player, SlotAccess) on a per-item basis.

The event runs whenever a slot in an AbstractContainerMenu is clicked and provides the item in the slot and the item currently carried by the cursor. Either item can be empty.

This behavior runs on both the client and server side except the creative mode inventory menu, which is only ever handled client-side.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Callback that runs in net.minecraft.world.inventory.AbstractContainerMenu#tryItemClickBehaviourOverride(Player, ClickAction, Slot, ItemStack, ItemStack).
  • Method Summary

    Modifier and Type
    Method
    Description
    onItemClickBehavior(net.minecraft.world.item.ItemStack hoveredItem, net.minecraft.world.inventory.Slot hoveredSlot, net.minecraft.world.item.ItemStack itemHeldByCursor, net.minecraft.world.entity.SlotAccess slotHeldByCursor, net.minecraft.world.inventory.ClickAction clickAction, net.minecraft.world.entity.player.Player player)
    Handles menu interactions when clicking items on top of each other in a container menu.
  • Field Details

    • EVENT

      static final Event<ItemClickBehaviorCallback> EVENT
      Callback that runs in net.minecraft.world.inventory.AbstractContainerMenu#tryItemClickBehaviourOverride(Player, ClickAction, Slot, ItemStack, ItemStack).
  • Method Details

    • onItemClickBehavior

      EventResult onItemClickBehavior(net.minecraft.world.item.ItemStack hoveredItem, net.minecraft.world.inventory.Slot hoveredSlot, net.minecraft.world.item.ItemStack itemHeldByCursor, net.minecraft.world.entity.SlotAccess slotHeldByCursor, net.minecraft.world.inventory.ClickAction clickAction, net.minecraft.world.entity.player.Player player)
      Handles menu interactions when clicking items on top of each other in a container menu.
      Parameters:
      hoveredItem - the item in the slot hovered by the mouse cursor
      hoveredSlot - the slot hovered by the mouse cursor
      itemHeldByCursor - the item carried by the cursor
      slotHeldByCursor - the slot abstraction for the cursor
      clickAction - the mouse button that was used in the click
      player - the player
      Returns:
      EventResult.ALLOW to allow normal container menu click behavior to run, EventResult.DENY to prevent normal click behavior, which allows for implementing a custom interaction as vanilla does for bundles, EventResult.PASS to fall back to other callbacks and eventually resolve ItemStack#overrideStackedOnOther(Slot, ClickAction, Player) and ItemStack#overrideOtherStackedOnMe(ItemStack, Slot, ClickAction, Player, SlotAccess)