Interface BaseContainer

All Superinterfaces:
net.minecraft.world.Clearable, net.minecraft.world.Container

public interface BaseContainer extends net.minecraft.world.Container
  • Field Summary

    Fields inherited from interface net.minecraft.world.Container

    DEFAULT_DISTANCE_LIMIT, LARGE_MAX_STACK_SIZE
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Clears the inventory.
    default int
    Returns the inventory size.
    default net.minecraft.world.item.ItemStack
    getItem(int slot)
    Retrieves the item in the slot.
    net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>
    Retrieves the item list of this inventory.
    default boolean
    Checks if the inventory is empty.
    of(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> items)
    Creates an inventory from the item list.
    ofSize(int size)
    Creates a new inventory with the specified size.
    default net.minecraft.world.item.ItemStack
    removeItem(int slot, int count)
    Removes items from an inventory slot.
    default net.minecraft.world.item.ItemStack
    Removes all items from an inventory slot.
    default void
    Marks the state as dirty.
    default void
    setItem(int slot, net.minecraft.world.item.ItemStack stack)
    Replaces the current stack in an inventory slot with the provided stack.
    default boolean
    stillValid(net.minecraft.world.entity.player.Player player)
     

    Methods inherited from interface net.minecraft.world.Container

    canPlaceItem, canTakeItem, countItem, getMaxStackSize, hasAnyMatching, hasAnyOf, startOpen, stopOpen
  • Method Details

    • getItems

      net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> getItems()
      Retrieves the item list of this inventory. Must return the same instance every time it's called.
    • of

      static BaseContainer of(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> items)
      Creates an inventory from the item list.
    • ofSize

      static BaseContainer ofSize(int size)
      Creates a new inventory with the specified size.
    • getContainerSize

      default int getContainerSize()
      Returns the inventory size.
      Specified by:
      getContainerSize in interface net.minecraft.world.Container
    • isEmpty

      default boolean isEmpty()
      Checks if the inventory is empty.
      Specified by:
      isEmpty in interface net.minecraft.world.Container
      Returns:
      true if this inventory has only empty stacks, false otherwise.
    • getItem

      default net.minecraft.world.item.ItemStack getItem(int slot)
      Retrieves the item in the slot.
      Specified by:
      getItem in interface net.minecraft.world.Container
    • removeItem

      default net.minecraft.world.item.ItemStack removeItem(int slot, int count)
      Removes items from an inventory slot.
      Specified by:
      removeItem in interface net.minecraft.world.Container
      Parameters:
      slot - The slot to remove from.
      count - How many items to remove. If there are less items in the slot than what are requested, takes all items in that slot.
    • removeItemNoUpdate

      default net.minecraft.world.item.ItemStack removeItemNoUpdate(int slot)
      Removes all items from an inventory slot.
      Specified by:
      removeItemNoUpdate in interface net.minecraft.world.Container
      Parameters:
      slot - The slot to remove from.
    • setItem

      default void setItem(int slot, net.minecraft.world.item.ItemStack stack)
      Replaces the current stack in an inventory slot with the provided stack.
      Specified by:
      setItem in interface net.minecraft.world.Container
      Parameters:
      slot - The inventory slot of which to replace the itemstack.
      stack - The replacing itemstack. If the stack is too big for this inventory (Container.getMaxStackSize() ()}), it gets resized to this inventory's maximum amount.
    • clearContent

      default void clearContent()
      Clears the inventory.
      Specified by:
      clearContent in interface net.minecraft.world.Clearable
    • setChanged

      default void setChanged()
      Marks the state as dirty. Must be called after changes in the inventory, so that the game can properly save the inventory contents and notify neighboring blocks of inventory changes.
      Specified by:
      setChanged in interface net.minecraft.world.Container
    • stillValid

      default boolean stillValid(net.minecraft.world.entity.player.Player player)
      Specified by:
      stillValid in interface net.minecraft.world.Container
      Returns:
      true if the player can use the inventory, false otherwise.