Class Slot

java.lang.Object
net.minecraft.world.inventory.Slot
Direct Known Subclasses:
ArmorSlot, BeaconMenu.PaymentSlot, BrewingStandMenu.FuelSlot, BrewingStandMenu.IngredientsSlot, BrewingStandMenu.PotionSlot, CrafterSlot, CreativeModeInventoryScreen.CustomCreativeSlot, CreativeModeInventoryScreen.SlotWrapper, FurnaceFuelSlot, FurnaceResultSlot, MerchantResultSlot, NonInteractiveResultSlot, ResultSlot, ShulkerBoxSlot, SlotItemHandler, StackCopySlot

public class Slot extends Object
  • Field Details

    • slot

      private final int slot
    • container

      public final Container container
    • index

      public int index
    • x

      public final int x
    • y

      public final int y
    • backgroundPair

      private com.mojang.datafixers.util.Pair<ResourceLocation,ResourceLocation> backgroundPair
  • Constructor Details

    • Slot

      public Slot(Container pContainer, int pSlot, int pX, int pY)
  • Method Details

    • onQuickCraft

      public void onQuickCraft(ItemStack pOldStack, ItemStack pNewStack)
      if par2 has more items than par1, onCrafting(item,countIncrease) is called
    • onQuickCraft

      protected void onQuickCraft(ItemStack pStack, int pAmount)
      Typically increases an internal count, then calls onCrafting(item).
      Parameters:
      pStack - the output - ie, iron ingots, and pickaxes, not ore and wood.
    • onSwapCraft

      protected void onSwapCraft(int pNumItemsCrafted)
    • checkTakeAchievements

      protected void checkTakeAchievements(ItemStack pStack)
      Parameters:
      pStack - the output - ie, iron ingots, and pickaxes, not ore and wood.
    • onTake

      public void onTake(Player pPlayer, ItemStack pStack)
    • mayPlace

      public boolean mayPlace(ItemStack pStack)
      Check if the stack is allowed to be placed in this slot, used for armor slots as well as furnace fuel.
    • getItem

      public ItemStack getItem()
    • hasItem

      public boolean hasItem()
    • setByPlayer

      public void setByPlayer(ItemStack pStack)
    • setByPlayer

      public void setByPlayer(ItemStack pNewStack, ItemStack pOldStack)
    • set

      public void set(ItemStack pStack)
      Helper method to put a stack in the slot.
    • setChanged

      public void setChanged()
    • getMaxStackSize

      public int getMaxStackSize()
    • getMaxStackSize

      public int getMaxStackSize(ItemStack pStack)
    • getNoItemIcon

      @Nullable public com.mojang.datafixers.util.Pair<ResourceLocation,ResourceLocation> getNoItemIcon()
    • remove

      public ItemStack remove(int pAmount)
      Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new stack.
    • mayPickup

      public boolean mayPickup(Player pPlayer)
      Return whether this slot's stack can be taken from this slot.
    • isActive

      public boolean isActive()
    • getSlotIndex

      public int getSlotIndex()
      Retrieves the index in the inventory for this slot, this value should typically not be used, but can be useful for some occasions.
      Returns:
      Index in associated inventory for this slot.
    • isSameInventory

      public boolean isSameInventory(Slot other)
      Checks if the other slot is in the same inventory, by comparing the inventory reference.
      Parameters:
      other -
      Returns:
      true if the other slot is in the same inventory
    • setBackground

      public Slot setBackground(ResourceLocation atlas, ResourceLocation sprite)
      Sets the background atlas and sprite location.
      Parameters:
      atlas - The atlas name
      sprite - The sprite located on that atlas.
      Returns:
      this, to allow chaining.
    • tryRemove

      public Optional<ItemStack> tryRemove(int pCount, int pDecrement, Player pPlayer)
    • safeTake

      public ItemStack safeTake(int pCount, int pDecrement, Player pPlayer)
    • safeInsert

      public ItemStack safeInsert(ItemStack pStack)
    • safeInsert

      public ItemStack safeInsert(ItemStack pStack, int pIncrement)
    • allowModification

      public boolean allowModification(Player pPlayer)
    • getContainerSlot

      public int getContainerSlot()
    • isHighlightable

      public boolean isHighlightable()
    • isFake

      public boolean isFake()