Class ValidatedSlot

java.lang.Object
net.minecraft.screen.slot.Slot
io.github.cottonmc.cotton.gui.ValidatedSlot

public class ValidatedSlot extends net.minecraft.screen.slot.Slot
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Predicate<net.minecraft.item.ItemStack>
    The default item filter that allows all items.
    protected final com.google.common.collect.Multimap<WItemSlot,WItemSlot.ChangeListener>
     

    Fields inherited from class net.minecraft.screen.slot.Slot

    id, inventory, x, y
  • Constructor Summary

    Constructors
    Constructor
    Description
    ValidatedSlot(net.minecraft.inventory.Inventory inventory, int index, int x, int y)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a change listener to this slot.
    boolean
    canInsert(net.minecraft.item.ItemStack stack)
     
    boolean
    canTakeItems(net.minecraft.entity.player.PlayerEntity player)
     
    Predicate<net.minecraft.item.ItemStack>
    Gets the item stack filter of this slot.
    int
    Gets the index of this slot in its inventory.
    net.minecraft.item.ItemStack
     
    boolean
     
    boolean
    Returns whether items can be inserted into this slot.
    boolean
    Returns whether items can be taken from this slot.
    boolean
    Tests whether this slot is visible.
    void
     
    void
    setFilter(Predicate<net.minecraft.item.ItemStack> filter)
    Sets the item stack filter of this slot.
    void
    setInsertingAllowed(boolean insertingAllowed)
    Sets whether inserting items into this slot is allowed.
    void
    setTakingAllowed(boolean takingAllowed)
    Sets whether taking items from this slot is allowed.
    void
    setVisible(boolean visible)
    Sets whether this slot is visible.

    Methods inherited from class net.minecraft.screen.slot.Slot

    canTakePartial, getBackgroundSprite, getIndex, getMaxItemCount, getMaxItemCount, hasStack, insertStack, insertStack, onCrafted, onCrafted, onQuickTransfer, onTake, onTakeItem, setStack, takeStack, takeStackRange, tryTakeStackRange

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_ITEM_FILTER

      public static final Predicate<net.minecraft.item.ItemStack> DEFAULT_ITEM_FILTER
      The default item filter that allows all items.
      Since:
      5.1.1
    • listeners

      protected final com.google.common.collect.Multimap<WItemSlot,WItemSlot.ChangeListener> listeners
  • Constructor Details

    • ValidatedSlot

      public ValidatedSlot(net.minecraft.inventory.Inventory inventory, int index, int x, int y)
  • Method Details

    • canInsert

      public boolean canInsert(net.minecraft.item.ItemStack stack)
      Overrides:
      canInsert in class net.minecraft.screen.slot.Slot
    • canTakeItems

      public boolean canTakeItems(net.minecraft.entity.player.PlayerEntity player)
      Overrides:
      canTakeItems in class net.minecraft.screen.slot.Slot
    • getStack

      public net.minecraft.item.ItemStack getStack()
      Overrides:
      getStack in class net.minecraft.screen.slot.Slot
    • markDirty

      public void markDirty()
      Overrides:
      markDirty in class net.minecraft.screen.slot.Slot
    • getInventoryIndex

      public int getInventoryIndex()
      Gets the index of this slot in its inventory.
      Returns:
      the inventory index
    • isInsertingAllowed

      public boolean isInsertingAllowed()
      Returns whether items can be inserted into this slot.
      Returns:
      true if items can be inserted, false otherwise
      Since:
      1.10.0
    • setInsertingAllowed

      public void setInsertingAllowed(boolean insertingAllowed)
      Sets whether inserting items into this slot is allowed.
      Parameters:
      insertingAllowed - true if items can be inserted, false otherwise
      Since:
      1.10.0
    • isTakingAllowed

      public boolean isTakingAllowed()
      Returns whether items can be taken from this slot.
      Returns:
      true if items can be taken, false otherwise
      Since:
      1.10.0
    • setTakingAllowed

      public void setTakingAllowed(boolean takingAllowed)
      Sets whether taking items from this slot is allowed.
      Parameters:
      takingAllowed - true if items can be taken, false otherwise
      Since:
      1.10.0
    • getFilter

      public Predicate<net.minecraft.item.ItemStack> getFilter()
      Gets the item stack filter of this slot.
      Returns:
      the item filter
      Since:
      2.0.0
    • setFilter

      public void setFilter(Predicate<net.minecraft.item.ItemStack> filter)
      Sets the item stack filter of this slot.
      Parameters:
      filter - the new item filter
      Since:
      2.0.0
    • addChangeListener

      public void addChangeListener(WItemSlot owner, WItemSlot.ChangeListener listener)
      Adds a change listener to this slot. Does nothing if the listener is already registered.
      Parameters:
      owner - the owner of this slot
      listener - the listener
      Throws:
      NullPointerException - if either parameter is null
      Since:
      3.0.0
    • isEnabled

      public boolean isEnabled()
      Overrides:
      isEnabled in class net.minecraft.screen.slot.Slot
    • isVisible

      public boolean isVisible()
      Tests whether this slot is visible.
      Returns:
      true if this slot is visible, false otherwise
      Since:
      3.0.0
    • setVisible

      public void setVisible(boolean visible)
      Sets whether this slot is visible.
      Parameters:
      visible - true if this slot if visible, false otherwise
      Since:
      3.0.0