Class SimpleInventory

java.lang.Object
org.cyclops.cyclopscore.inventory.SimpleInventory
All Implemented Interfaces:
net.minecraft.world.Clearable, net.minecraft.world.Container, net.minecraft.world.WorldlyContainer, INBTInventory, INBTSerializable
Direct Known Subclasses:
LargeInventory, NBTSimpleInventoryItemHeld, NBTSimpleInventoryItemStack

public class SimpleInventory extends Object implements INBTInventory, net.minecraft.world.WorldlyContainer
A basic inventory implementation.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.cyclops.cyclopscore.persist.nbt.INBTSerializable

    INBTSerializable.SelfNBTClassType
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final net.minecraft.world.item.ItemStack[]
     

    Fields inherited from interface net.minecraft.world.Container

    DEFAULT_DISTANCE_LIMIT, LARGE_MAX_STACK_SIZE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for NBT persistence, don't call this yourself.
    SimpleInventory(int size, int stackLimit)
    Make a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a dirty marking listener.
    boolean
    canPlaceItem(int i, net.minecraft.world.item.ItemStack itemstack)
     
    boolean
    canPlaceItemThroughFace(int index, net.minecraft.world.item.ItemStack itemStackIn, net.minecraft.core.Direction direction)
     
    boolean
    canTakeItemThroughFace(int index, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction direction)
     
    void
     
    void
    fromNBT(net.minecraft.nbt.CompoundTag tag)
    Read the data from an NBT tag and place it in this object.
    int
     
    net.minecraft.world.item.ItemStack
    getItem(int slotId)
     
    net.minecraftforge.items.IItemHandler
     
    net.minecraftforge.items.IItemHandler
    getItemHandlerSided(net.minecraft.core.Direction side)
     
    net.minecraft.world.item.ItemStack[]
    Get the array of ItemStack inside this inventory.
    int
     
    int[]
    getSlotsForFace(net.minecraft.core.Direction side)
     
    int
     
    boolean
     
    protected void
     
    void
    read(net.minecraft.nbt.CompoundTag data)
    Read inventory data from the given NBT.
    void
    readFromNBT(net.minecraft.nbt.CompoundTag data, String tag)
    Read inventory data from the given NBT.
    void
    Remove a dirty marking listener.
    net.minecraft.world.item.ItemStack
    removeItem(int slotId, int count)
     
    net.minecraft.world.item.ItemStack
    removeItemNoUpdate(int slotId)
     
    void
     
    void
    setItem(int slotId, net.minecraft.world.item.ItemStack itemstack)
     
    void
    startOpen(net.minecraft.world.entity.player.Player playerIn)
     
    boolean
    stillValid(net.minecraft.world.entity.player.Player entityplayer)
     
    void
    stopOpen(net.minecraft.world.entity.player.Player playerIn)
     
    net.minecraft.nbt.CompoundTag
    Convert the data to an NBT tag.
    void
    write(net.minecraft.nbt.CompoundTag data)
    Write inventory data to the given NBT.
    void
    writeToNBT(net.minecraft.nbt.CompoundTag data, String tag)
    Write inventory data to the given NBT.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.world.Container

    canTakeItem, countItem, hasAnyMatching, hasAnyOf
  • Field Details

    • contents

      protected final net.minecraft.world.item.ItemStack[] contents
  • Constructor Details

    • SimpleInventory

      public SimpleInventory()
      Default constructor for NBT persistence, don't call this yourself.
    • SimpleInventory

      public SimpleInventory(int size, int stackLimit)
      Make a new instance.
      Parameters:
      size - The amount of slots in the inventory.
      stackLimit - The stack limit for each slot.
  • Method Details

    • addDirtyMarkListener

      public void addDirtyMarkListener(IDirtyMarkListener dirtyMarkListener)
      Add a dirty marking listener.
      Parameters:
      dirtyMarkListener - The dirty mark listener.
    • removeDirtyMarkListener

      public void removeDirtyMarkListener(IDirtyMarkListener dirtyMarkListener)
      Remove a dirty marking listener.
      Parameters:
      dirtyMarkListener - The dirty mark listener.
    • getContainerSize

      public int getContainerSize()
      Specified by:
      getContainerSize in interface net.minecraft.world.Container
    • getItem

      public net.minecraft.world.item.ItemStack getItem(int slotId)
      Specified by:
      getItem in interface net.minecraft.world.Container
    • removeItem

      public net.minecraft.world.item.ItemStack removeItem(int slotId, int count)
      Specified by:
      removeItem in interface net.minecraft.world.Container
    • setItem

      public void setItem(int slotId, net.minecraft.world.item.ItemStack itemstack)
      Specified by:
      setItem in interface net.minecraft.world.Container
    • getMaxStackSize

      public int getMaxStackSize()
      Specified by:
      getMaxStackSize in interface net.minecraft.world.Container
    • onInventoryChanged

      protected void onInventoryChanged()
    • stillValid

      public boolean stillValid(net.minecraft.world.entity.player.Player entityplayer)
      Specified by:
      stillValid in interface net.minecraft.world.Container
    • startOpen

      public void startOpen(net.minecraft.world.entity.player.Player playerIn)
      Specified by:
      startOpen in interface net.minecraft.world.Container
    • stopOpen

      public void stopOpen(net.minecraft.world.entity.player.Player playerIn)
      Specified by:
      stopOpen in interface net.minecraft.world.Container
    • read

      public void read(net.minecraft.nbt.CompoundTag data)
      Description copied from interface: INBTInventory
      Read inventory data from the given NBT.
      Specified by:
      read in interface INBTInventory
      Parameters:
      data - The NBT data containing inventory data.
    • readFromNBT

      public void readFromNBT(net.minecraft.nbt.CompoundTag data, String tag)
      Read inventory data from the given NBT.
      Parameters:
      data - The NBT data containing inventory data.
      tag - The NBT tag name where the info is located.
    • write

      public void write(net.minecraft.nbt.CompoundTag data)
      Description copied from interface: INBTInventory
      Write inventory data to the given NBT.
      Specified by:
      write in interface INBTInventory
      Parameters:
      data - The NBT tag that will receive inventory data.
    • writeToNBT

      public void writeToNBT(net.minecraft.nbt.CompoundTag data, String tag)
      Write inventory data to the given NBT.
      Parameters:
      data - The NBT tag that will receive inventory data.
      tag - The NBT tag name where the info must be located.
    • removeItemNoUpdate

      public net.minecraft.world.item.ItemStack removeItemNoUpdate(int slotId)
      Specified by:
      removeItemNoUpdate in interface net.minecraft.world.Container
    • getItemStacks

      public net.minecraft.world.item.ItemStack[] getItemStacks()
      Get the array of ItemStack inside this inventory.
      Returns:
      The items in this inventory.
    • canPlaceItem

      public boolean canPlaceItem(int i, net.minecraft.world.item.ItemStack itemstack)
      Specified by:
      canPlaceItem in interface net.minecraft.world.Container
    • clearContent

      public void clearContent()
      Specified by:
      clearContent in interface net.minecraft.world.Clearable
    • setChanged

      public void setChanged()
      Specified by:
      setChanged in interface net.minecraft.world.Container
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface net.minecraft.world.Container
      Specified by:
      isEmpty in interface INBTInventory
      Returns:
      If all slots are empty.
    • toNBT

      public net.minecraft.nbt.CompoundTag toNBT()
      Description copied from interface: INBTSerializable
      Convert the data to an NBT tag.
      Specified by:
      toNBT in interface INBTSerializable
      Returns:
      The NBT tag.
    • fromNBT

      public void fromNBT(net.minecraft.nbt.CompoundTag tag)
      Description copied from interface: INBTSerializable
      Read the data from an NBT tag and place it in this object. The given tag will never be null, so make sure that all fields have a correct default value in case the received tag would be null anyways.
      Specified by:
      fromNBT in interface INBTSerializable
      Parameters:
      tag - The tag to read from.
    • getItemHandler

      public net.minecraftforge.items.IItemHandler getItemHandler()
    • getItemHandlerSided

      public net.minecraftforge.items.IItemHandler getItemHandlerSided(net.minecraft.core.Direction side)
    • getState

      public int getState()
      Returns:
      The inventory state.
    • getSlotsForFace

      public int[] getSlotsForFace(net.minecraft.core.Direction side)
      Specified by:
      getSlotsForFace in interface net.minecraft.world.WorldlyContainer
    • canPlaceItemThroughFace

      public boolean canPlaceItemThroughFace(int index, net.minecraft.world.item.ItemStack itemStackIn, @Nullable net.minecraft.core.Direction direction)
      Specified by:
      canPlaceItemThroughFace in interface net.minecraft.world.WorldlyContainer
    • canTakeItemThroughFace

      public boolean canTakeItemThroughFace(int index, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction direction)
      Specified by:
      canTakeItemThroughFace in interface net.minecraft.world.WorldlyContainer