Class ValidatedSlot

java.lang.Object
net.minecraft.world.inventory.Slot
io.github.cottonmc.cotton.gui.ValidatedSlot

public class ValidatedSlot extends net.minecraft.world.inventory.Slot
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Predicate<net.minecraft.world.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.world.inventory.Slot

    container, index, x, y
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    void
    Adds a change listener to this slot.
    Predicate<net.minecraft.world.item.ItemStack>
    Gets the item stack input filter of this slot.
    int
    Gets the index of this slot in its inventory.
    net.minecraft.world.item.ItemStack
     
    Predicate<net.minecraft.world.item.ItemStack>
    Gets the item stack output filter of this slot.
    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.
    boolean
    mayPickup(net.minecraft.world.entity.player.Player player)
     
    boolean
    mayPlace(net.minecraft.world.item.ItemStack stack)
     
    void
     
    void
    setInputFilter(Predicate<net.minecraft.world.item.ItemStack> inputFilter)
    Sets the item stack input filter of this slot.
    void
    setInsertingAllowed(boolean insertingAllowed)
    Sets whether inserting items into this slot is allowed.
    void
    setOutputFilter(Predicate<net.minecraft.world.item.ItemStack> outputFilter)
    Sets the item stack output filter of this slot.
    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.world.inventory.Slot

    allowModification, checkTakeAchievements, getContainerSlot, getMaxStackSize, getMaxStackSize, getNoItemIcon, hasItem, isFake, isHighlightable, onQuickCraft, onQuickCraft, onSwapCraft, onTake, remove, safeInsert, safeInsert, safeTake, set, setByPlayer, setByPlayer, tryRemove

    Methods inherited from class Object

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

    • DEFAULT_ITEM_FILTER

      public static final Predicate<net.minecraft.world.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.world.Container inventory, int index, int x, int y)
  • Method Details

    • mayPlace

      public boolean mayPlace(net.minecraft.world.item.ItemStack stack)
      Overrides:
      mayPlace in class net.minecraft.world.inventory.Slot
    • mayPickup

      public boolean mayPickup(net.minecraft.world.entity.player.Player player)
      Overrides:
      mayPickup in class net.minecraft.world.inventory.Slot
    • getItem

      public net.minecraft.world.item.ItemStack getItem()
      Overrides:
      getItem in class net.minecraft.world.inventory.Slot
    • setChanged

      public void setChanged()
      Overrides:
      setChanged in class net.minecraft.world.inventory.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
    • getInputFilter

      public Predicate<net.minecraft.world.item.ItemStack> getInputFilter()
      Gets the item stack input filter of this slot.
      Returns:
      the item input filter
      Since:
      8.1.0
    • setInputFilter

      public void setInputFilter(Predicate<net.minecraft.world.item.ItemStack> inputFilter)
      Sets the item stack input filter of this slot.
      Parameters:
      inputFilter - the new item input filter
      Since:
      8.1.0
    • getOutputFilter

      public Predicate<net.minecraft.world.item.ItemStack> getOutputFilter()
      Gets the item stack output filter of this slot.
      Returns:
      the item output filter
      Since:
      8.1.0
    • setOutputFilter

      public void setOutputFilter(Predicate<net.minecraft.world.item.ItemStack> outputFilter)
      Sets the item stack output filter of this slot.
      Parameters:
      outputFilter - the new item output filter
      Since:
      8.1.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
    • isActive

      public boolean isActive()
      Overrides:
      isActive in class net.minecraft.world.inventory.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