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.
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
FieldsModifier and TypeFieldDescriptionstatic final Event<ItemClickBehaviorCallback> Callback that runs in net.minecraft.world.inventory.AbstractContainerMenu#tryItemClickBehaviourOverride(Player, ClickAction, Slot, ItemStack, ItemStack). -
Method Summary
Modifier and TypeMethodDescriptiononItemClickBehavior(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
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 cursorhoveredSlot- the slot hovered by the mouse cursoritemHeldByCursor- the item carried by the cursorslotHeldByCursor- the slot abstraction for the cursorclickAction- the mouse button that was used in the clickplayer- the player- Returns:
EventResult.ALLOWto allow normal container menu click behavior to run,EventResult.DENYto prevent normal click behavior, which allows for implementing a custom interaction as vanilla does for bundles,EventResult.PASSto fall back to other callbacks and eventually resolve ItemStack#overrideStackedOnOther(Slot, ClickAction, Player) and ItemStack#overrideOtherStackedOnMe(ItemStack, Slot, ClickAction, Player, SlotAccess)
-