Class ItemStackedOnOtherEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.ItemStackedOnOtherEvent

public class ItemStackedOnOtherEvent extends net.minecraftforge.eventbus.api.Event
This event provides the functionality of the pair of functions used for the Bundle, in one event: 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. Practically, that means that listeners of this event should require the player to be in survival mode if using capabilities that are not synced.

This event is cancellable, and does not have a result. 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.

  • Field Details

    • carriedItem

      private final ItemStack carriedItem
    • stackedOnItem

      private final ItemStack stackedOnItem
    • slot

      private final Slot slot
    • action

      private final ClickAction action
    • player

      private final Player player
    • carriedSlotAccess

      private final SlotAccess carriedSlotAccess
  • Constructor Details

  • Method Details

    • getCarriedItem

      public ItemStack getCarriedItem()
      Returns the stack being carried by the mouse. This may be empty!
      Returns:
      the stack being carried by the mouse
    • getStackedOnItem

      public 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 Slot getSlot()
      Returns the slot being clicked on.
      Returns:
      the slot being clicked on
    • getClickAction

      public 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 Player getPlayer()
      Returns the player doing the item swap attempt.
      Returns:
      the player doing the item swap attempt
    • getCarriedSlotAccess

      public 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