Package net.neoforged.neoforge.event
Class ItemStackedOnOtherEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.ItemStackedOnOtherEvent
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
public class ItemStackedOnOtherEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.bus.api.ICancellableEvent
This event provides the functionality of the pair of functions used for the Bundle, in one event:
Item.overrideOtherStackedOnMe(ItemStack, ItemStack, Slot, ClickAction, Player, SlotAccess)
Item.overrideStackedOnOther(ItemStack, Slot, ClickAction, Player)
This event is cancellable, and does not
.
If the event is cancelled, the container's logic halts, the carried item and the slot will not be swapped, and handling is assumed to have been done by the mod.
This also means that the two vanilla checks described above will not be called.invalid reference
have a result
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final net.minecraft.world.inventory.ClickAction
private final net.minecraft.world.item.ItemStack
private final net.minecraft.world.entity.SlotAccess
private final net.minecraft.world.entity.player.Player
private final net.minecraft.world.inventory.Slot
private final net.minecraft.world.item.ItemStack
-
Constructor Summary
ConstructorsConstructorDescriptionItemStackedOnOtherEvent
(net.minecraft.world.item.ItemStack carriedItem, net.minecraft.world.item.ItemStack stackedOnItem, net.minecraft.world.inventory.Slot slot, net.minecraft.world.inventory.ClickAction action, net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.SlotAccess carriedSlotAccess) -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.item.ItemStack
Returns the stack being carried by the mouse.net.minecraft.world.entity.SlotAccess
Returns a fake slot allowing the listener to see and change what item is being carried.net.minecraft.world.inventory.ClickAction
Returns the click action being used.net.minecraft.world.entity.player.Player
Returns the player doing the item swap attempt.net.minecraft.world.inventory.Slot
getSlot()
Returns the slot being clicked on.net.minecraft.world.item.ItemStack
Returns the stack currently in the slot being clicked on.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
carriedItem
private final net.minecraft.world.item.ItemStack carriedItem -
stackedOnItem
private final net.minecraft.world.item.ItemStack stackedOnItem -
slot
private final net.minecraft.world.inventory.Slot slot -
action
private final net.minecraft.world.inventory.ClickAction action -
player
private final net.minecraft.world.entity.player.Player player -
carriedSlotAccess
private final net.minecraft.world.entity.SlotAccess carriedSlotAccess
-
-
Constructor Details
-
ItemStackedOnOtherEvent
@Internal public ItemStackedOnOtherEvent(net.minecraft.world.item.ItemStack carriedItem, net.minecraft.world.item.ItemStack stackedOnItem, net.minecraft.world.inventory.Slot slot, net.minecraft.world.inventory.ClickAction action, net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.SlotAccess carriedSlotAccess)
-
-
Method Details
-
getCarriedItem
public net.minecraft.world.item.ItemStack getCarriedItem()Returns the stack being carried by the mouse. This may be empty!- Returns:
- the stack being carried by the mouse
-
getStackedOnItem
public net.minecraft.world.item.ItemStack getStackedOnItem()Returns the stack currently in the slot being clicked on. This may be empty!- Returns:
- the stack currently in the slot being clicked on
-
getSlot
public net.minecraft.world.inventory.Slot getSlot()Returns the slot being clicked on.- Returns:
- the slot being clicked on
-
getClickAction
public net.minecraft.world.inventory.ClickAction getClickAction()Returns the click action being used. By default ClickAction.PRIMARY corresponds to left-click, and ClickAction.SECONDARY is right-click.- Returns:
- the click action being used
-
getPlayer
public net.minecraft.world.entity.player.Player getPlayer()Returns the player doing the item swap attempt.- Returns:
- the player doing the item swap attempt
-
getCarriedSlotAccess
public net.minecraft.world.entity.SlotAccess getCarriedSlotAccess()Returns a fake slot allowing the listener to see and change what item is being carried.- Returns:
- a fake slot allowing the listener to see and change what item is being carried
-