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 fired before either of the above are called, when a carried item is clicked on top of another in a GUI slot.
This event (and items stacking on others in general) is fired on both sides, but only on the client in the creative menu.
This event is cancellable. If the event is cancelled, the two vanilla methods described above will not be called. The remaining logic depends on the cancellation result:
- If it is
true, then 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 event listener. - If it is
false, vanilla processing continues except for the two vanilla methods mentioned above.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClickActionprivate booleanprivate final ItemStackprivate final SlotAccessprivate final Playerprivate final Slotprivate final ItemStack -
Constructor Summary
ConstructorsConstructorDescriptionItemStackedOnOtherEvent(ItemStack carriedItem, ItemStack stackedOnItem, Slot slot, ClickAction action, Player player, SlotAccess carriedSlotAccess) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelWithResult(boolean cancelResult) Cancels this event and sets the cancellation result.booleanReturns the cancellation result.Returns the stack being carried by the mouse, which may be empty.Returns a fake slot allowing the listener to see and change what item is being carried.Returns the click action being used.Returns the player doing the item swap attempt.getSlot()Returns the slot being clicked on.Returns the stack currently in the slot being clicked on, which may be empty.voidsetCancellationResult(boolean cancelResult) Sets the cancellation result of this event, which is used to determine further processing of the click when this event is cancelled.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
carriedItem
-
stackedOnItem
-
slot
-
action
-
player
-
carriedSlotAccess
-
cancelResult
private boolean cancelResult
-
-
Constructor Details
-
ItemStackedOnOtherEvent
@Internal public ItemStackedOnOtherEvent(ItemStack carriedItem, ItemStack stackedOnItem, Slot slot, ClickAction action, Player player, SlotAccess carriedSlotAccess)
-
-
Method Details
-
getCarriedItem
Returns the stack being carried by the mouse, which may be empty.- Returns:
- the stack being carried by the mouse, which may be empty
-
getStackedOnItem
Returns the stack currently in the slot being clicked on, which may be empty.- Returns:
- the stack currently in the slot being clicked on, which may be empty
-
getSlot
-
getClickAction
Returns the click action being used. The click actions do not necessarily map to specific mouse buttons, as they may be rebound by the client. For default key mappings, the primary click action corresponds to a mouse left-click, and the secondary click action to a mouse right-click.- Returns:
- the click action being used
-
getPlayer
Returns the player doing the item swap attempt.- Returns:
- the player doing the item swap attempt
-
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
-
setCancellationResult
public void setCancellationResult(boolean cancelResult) Sets the cancellation result of this event, which is used to determine further processing of the click when this event is cancelled. See the javadocs of this class for more details.- Parameters:
cancelResult- the cancel result- See Also:
-
getCancellationResult
public boolean getCancellationResult()Returns the cancellation result.. This is used only when the event is cancelled; see the javadocs of this class for more details.- Returns:
- the cancellation result
-
cancelWithResult
public void cancelWithResult(boolean cancelResult) Cancels this event and sets the cancellation result.- Parameters:
cancelResult- the cancel result- See Also:
-