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
    • backgroundSprite

      private Identifier backgroundSprite
  • Constructor Details

    • Slot

      public Slot(Container container, int slot, int x, int y)
  • Method Details

    • onQuickCraft

      public void onQuickCraft(ItemStack picked, ItemStack original)
    • onQuickCraft

      protected void onQuickCraft(ItemStack picked, int count)
    • onSwapCraft

      protected void onSwapCraft(int count)
    • checkTakeAchievements

      protected void checkTakeAchievements(ItemStack carried)
    • onTake

      public void onTake(Player player, ItemStack carried)
    • mayPlace

      public boolean mayPlace(ItemStack itemStack)
    • getItem

      public ItemStack getItem()
    • hasItem

      public boolean hasItem()
    • setByPlayer

      public void setByPlayer(ItemStack itemStack)
    • setByPlayer

      public void setByPlayer(ItemStack itemStack, ItemStack previous)
    • set

      public void set(ItemStack itemStack)
    • setChanged

      public void setChanged()
    • getMaxStackSize

      public int getMaxStackSize()
    • getMaxStackSize

      public int getMaxStackSize(ItemStack itemStack)
    • getNoItemIcon

      public @Nullable Identifier getNoItemIcon()
    • remove

      public ItemStack remove(int amount)
    • mayPickup

      public boolean mayPickup(Player player)
    • 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(Identifier sprite)
      Sets the background atlas and sprite location.
      Parameters:
      sprite - The sprite located on that atlas.
      Returns:
      this, to allow chaining.
    • tryRemove

      public Optional<ItemStack> tryRemove(int amount, int maxAmount, Player player)
    • safeTake

      public ItemStack safeTake(int amount, int maxAmount, Player player)
    • safeInsert

      public ItemStack safeInsert(ItemStack stack)
    • safeInsert

      public ItemStack safeInsert(ItemStack inputStack, int inputAmount)
    • allowModification

      public boolean allowModification(Player player)
    • getContainerSlot

      public int getContainerSlot()
    • isHighlightable

      public boolean isHighlightable()
    • isFake

      public boolean isFake()