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 inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_LIMIT, LARGE_MAX_STACK_SIZE
-
Constructor Summary
ConstructorDescriptionDefault constructor for NBT persistence, don't call this yourself.SimpleInventory
(int size, int stackLimit) Make a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDirtyMarkListener
(IDirtyMarkListener dirtyMarkListener) 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 ofItemStack
inside this inventory.int
int[]
getSlotsForFace
(net.minecraft.core.Direction side) int
getState()
boolean
isEmpty()
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
removeDirtyMarkListener
(IDirtyMarkListener dirtyMarkListener) 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
toNBT()
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
Add a dirty marking listener.- Parameters:
dirtyMarkListener
- The dirty mark listener.
-
removeDirtyMarkListener
Remove a dirty marking listener.- Parameters:
dirtyMarkListener
- The dirty mark listener.
-
getContainerSize
public int getContainerSize()- Specified by:
getContainerSize
in interfacenet.minecraft.world.Container
-
getItem
public net.minecraft.world.item.ItemStack getItem(int slotId) - Specified by:
getItem
in interfacenet.minecraft.world.Container
-
removeItem
public net.minecraft.world.item.ItemStack removeItem(int slotId, int count) - Specified by:
removeItem
in interfacenet.minecraft.world.Container
-
setItem
public void setItem(int slotId, net.minecraft.world.item.ItemStack itemstack) - Specified by:
setItem
in interfacenet.minecraft.world.Container
-
getMaxStackSize
public int getMaxStackSize()- Specified by:
getMaxStackSize
in interfacenet.minecraft.world.Container
-
onInventoryChanged
protected void onInventoryChanged() -
stillValid
public boolean stillValid(net.minecraft.world.entity.player.Player entityplayer) - Specified by:
stillValid
in interfacenet.minecraft.world.Container
-
startOpen
public void startOpen(net.minecraft.world.entity.player.Player playerIn) - Specified by:
startOpen
in interfacenet.minecraft.world.Container
-
stopOpen
public void stopOpen(net.minecraft.world.entity.player.Player playerIn) - Specified by:
stopOpen
in interfacenet.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 interfaceINBTInventory
- Parameters:
data
- The NBT data containing inventory data.
-
readFromNBT
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 interfaceINBTInventory
- Parameters:
data
- The NBT tag that will receive inventory data.
-
writeToNBT
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 interfacenet.minecraft.world.Container
-
getItemStacks
public net.minecraft.world.item.ItemStack[] getItemStacks()Get the array ofItemStack
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 interfacenet.minecraft.world.Container
-
clearContent
public void clearContent()- Specified by:
clearContent
in interfacenet.minecraft.world.Clearable
-
setChanged
public void setChanged()- Specified by:
setChanged
in interfacenet.minecraft.world.Container
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfacenet.minecraft.world.Container
- Specified by:
isEmpty
in interfaceINBTInventory
- 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 interfaceINBTSerializable
- 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 interfaceINBTSerializable
- 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 interfacenet.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 interfacenet.minecraft.world.WorldlyContainer
-
canTakeItemThroughFace
public boolean canTakeItemThroughFace(int index, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction direction) - Specified by:
canTakeItemThroughFace
in interfacenet.minecraft.world.WorldlyContainer
-