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
FieldsFields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_LIMIT, LARGE_MAX_STACK_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for NBT persistence, don't call this yourself.SimpleInventory(int size, int stackLimit) Make a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDirtyMarkListener(IDirtyMarkListener dirtyMarkListener) Add a dirty marking listener.booleancanPlaceItem(int i, net.minecraft.world.item.ItemStack itemstack) booleancanPlaceItemThroughFace(int index, net.minecraft.world.item.ItemStack itemStackIn, net.minecraft.core.Direction direction) booleancanTakeItemThroughFace(int index, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction direction) voidvoidfromNBT(net.minecraft.nbt.CompoundTag tag) Read the data from an NBT tag and place it in this object.intnet.minecraft.world.item.ItemStackgetItem(int slotId) net.minecraftforge.items.IItemHandlernet.minecraftforge.items.IItemHandlergetItemHandlerSided(net.minecraft.core.Direction side) net.minecraft.world.item.ItemStack[]Get the array ofItemStackinside this inventory.intint[]getSlotsForFace(net.minecraft.core.Direction side) intgetState()booleanisEmpty()protected voidvoidread(net.minecraft.nbt.CompoundTag data) Read inventory data from the given NBT.voidreadFromNBT(net.minecraft.nbt.CompoundTag data, String tag) Read inventory data from the given NBT.voidremoveDirtyMarkListener(IDirtyMarkListener dirtyMarkListener) Remove a dirty marking listener.net.minecraft.world.item.ItemStackremoveItem(int slotId, int count) net.minecraft.world.item.ItemStackremoveItemNoUpdate(int slotId) voidvoidsetItem(int slotId, net.minecraft.world.item.ItemStack itemstack) voidstartOpen(net.minecraft.world.entity.player.Player playerIn) booleanstillValid(net.minecraft.world.entity.player.Player entityplayer) voidstopOpen(net.minecraft.world.entity.player.Player playerIn) net.minecraft.nbt.CompoundTagtoNBT()Convert the data to an NBT tag.voidwrite(net.minecraft.nbt.CompoundTag data) Write inventory data to the given NBT.voidwriteToNBT(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, waitMethods 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:
getContainerSizein interfacenet.minecraft.world.Container
-
getItem
public net.minecraft.world.item.ItemStack getItem(int slotId) - Specified by:
getItemin interfacenet.minecraft.world.Container
-
removeItem
public net.minecraft.world.item.ItemStack removeItem(int slotId, int count) - Specified by:
removeItemin interfacenet.minecraft.world.Container
-
setItem
public void setItem(int slotId, net.minecraft.world.item.ItemStack itemstack) - Specified by:
setItemin interfacenet.minecraft.world.Container
-
getMaxStackSize
public int getMaxStackSize()- Specified by:
getMaxStackSizein interfacenet.minecraft.world.Container
-
onInventoryChanged
protected void onInventoryChanged() -
stillValid
public boolean stillValid(net.minecraft.world.entity.player.Player entityplayer) - Specified by:
stillValidin interfacenet.minecraft.world.Container
-
startOpen
public void startOpen(net.minecraft.world.entity.player.Player playerIn) - Specified by:
startOpenin interfacenet.minecraft.world.Container
-
stopOpen
public void stopOpen(net.minecraft.world.entity.player.Player playerIn) - Specified by:
stopOpenin interfacenet.minecraft.world.Container
-
read
public void read(net.minecraft.nbt.CompoundTag data) Description copied from interface:INBTInventoryRead inventory data from the given NBT.- Specified by:
readin 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:INBTInventoryWrite inventory data to the given NBT.- Specified by:
writein 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:
removeItemNoUpdatein interfacenet.minecraft.world.Container
-
getItemStacks
public net.minecraft.world.item.ItemStack[] getItemStacks()Get the array ofItemStackinside this inventory.- Returns:
- The items in this inventory.
-
canPlaceItem
public boolean canPlaceItem(int i, net.minecraft.world.item.ItemStack itemstack) - Specified by:
canPlaceItemin interfacenet.minecraft.world.Container
-
clearContent
public void clearContent()- Specified by:
clearContentin interfacenet.minecraft.world.Clearable
-
setChanged
public void setChanged()- Specified by:
setChangedin interfacenet.minecraft.world.Container
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfacenet.minecraft.world.Container- Specified by:
isEmptyin interfaceINBTInventory- Returns:
- If all slots are empty.
-
toNBT
public net.minecraft.nbt.CompoundTag toNBT()Description copied from interface:INBTSerializableConvert the data to an NBT tag.- Specified by:
toNBTin interfaceINBTSerializable- Returns:
- The NBT tag.
-
fromNBT
public void fromNBT(net.minecraft.nbt.CompoundTag tag) Description copied from interface:INBTSerializableRead 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:
fromNBTin 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:
getSlotsForFacein interfacenet.minecraft.world.WorldlyContainer
-
canPlaceItemThroughFace
public boolean canPlaceItemThroughFace(int index, net.minecraft.world.item.ItemStack itemStackIn, @Nullable net.minecraft.core.Direction direction) - Specified by:
canPlaceItemThroughFacein interfacenet.minecraft.world.WorldlyContainer
-
canTakeItemThroughFace
public boolean canTakeItemThroughFace(int index, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction direction) - Specified by:
canTakeItemThroughFacein interfacenet.minecraft.world.WorldlyContainer
-