public class MalisisInventory
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Set<MalisisInventoryContainer> |
containers
List of
MalisisInventory that is currently containing this MalisisInventory. |
protected int |
inventoryId
The inventory id inside the container.
|
protected IInventoryProvider |
inventoryProvider
Object containing this
MalisisInventory. |
protected net.minecraft.item.ItemStack |
itemStackProvider
ItemStack holding the inventory when inventoryProvider is an Item.
|
protected java.lang.String |
name
Name of this
MalisisInventory. |
protected int |
slotMaxStackSize
Maximum stack size for the slots.
|
protected net.minecraft.util.NonNullList<MalisisSlot> |
slots
Slots for this
MalisisInventory. |
InventoryState |
state
Current inventory state.
|
| Constructor and Description |
|---|
MalisisInventory(IInventoryProvider provider,
int size)
Instantiates a new
MalisisInventory. |
MalisisInventory(IInventoryProvider provider,
MalisisSlot... slots)
Instantiates a new
MalisisInventory with the specified MalisisSlot. |
MalisisInventory(IInventoryProvider provider,
java.util.function.Supplier<? extends MalisisSlot> supplier,
int size)
Instantiates a new
MalisisInventory with size amount of slots from supplied by the |
| Modifier and Type | Method and Description |
|---|---|
void |
addOpenedContainer(MalisisInventoryContainer container)
Adds the opened container.
|
void |
breakInventory(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
Spills out all the itemStack contained inside this
MalisisInventory. |
void |
closeContainers()
Closes all currently opened containers
|
void |
emptyInventory()
Empties this
MalisisInventory and sets all slots contents to null. |
java.util.Optional<MalisisSlot> |
getFirstOccupiedSlot()
Gets the first
MalisisSlot containing an ItemStack. |
int |
getInventoryId()
Gets the id of this
MalisisInventory inside the MalisisInventoryContainer. |
int |
getInventoryStackLimit()
Gets the inventory stack limit.
|
net.minecraft.item.ItemStack |
getItemStack(int slotNumber)
Gets the itemStack from the slot at position slotNumber.
|
net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> |
getItemStackList()
Gets all the non empty
ItemStack stored in this MalisisInventory. |
java.lang.String |
getName()
Gets this
MalisisInventory name. |
java.util.List<MalisisSlot> |
getNonEmptySlots()
Gets the non empty slots.
|
java.util.Set<MalisisInventoryContainer> |
getOpenedContainers()
Gets the opened containers.
|
IInventoryProvider |
getProvider()
Gets the
IInventoryProvider of this MalisisInventory. |
int |
getSize()
Gets the size inventory.
|
MalisisSlot |
getSlot(int slotIndex)
Gets the slot at position slotNumber.
|
java.util.List<MalisisSlot> |
getSlots()
Gets the slots.
|
boolean |
hasCustomName()
Checks if this
MalisisInventory has a name set. |
boolean |
isEmpty()
Checks if at least one non-empty
ItemStack is present in this MalisisInventory. |
boolean |
isFull()
Checks if at least one slot is not full.
|
boolean |
isItemValidForSlot(int slotNumber,
net.minecraft.item.ItemStack itemStack)
Checks whether itemStack can be contained by the slot at position slotNumber.
|
boolean |
itemValidForSlot(MalisisSlot slot,
net.minecraft.item.ItemStack itemStack)
Checks whether itemStack can be contained by slot.
|
void |
onSlotChanged(MalisisSlot slot)
Called when itemStack change in slot.
|
static <T> MalisisInventoryContainer |
open(net.minecraft.entity.player.EntityPlayerMP player,
IInventoryProvider.IDeferredInventoryProvider<T> inventoryProvider,
T data)
Opens this
MalisisInventory. |
static MalisisInventoryContainer |
open(net.minecraft.entity.player.EntityPlayerMP player,
IInventoryProvider.IDirectInventoryProvider inventoryProvider)
Opens this
MalisisInventory. |
static <T> MalisisInventoryContainer |
open(net.minecraft.client.entity.EntityPlayerSP player,
IInventoryProvider.IDeferredInventoryProvider<T> inventoryProvider,
T data,
int windowId)
Opens this
MalisisInventory. |
static MalisisInventoryContainer |
open(net.minecraft.client.entity.EntityPlayerSP player,
IInventoryProvider.IDirectInventoryProvider inventoryProvider,
int windowId)
Opens this
MalisisInventory. |
void |
overrideSlot(MalisisSlot slot,
int slotIndex)
Overrides a specific slot with a new one.
|
net.minecraft.item.ItemStack |
pullItemStack()
Removes the first non-empty
ItemStack in this MalisisInventory and returns it. |
boolean |
pullItemStacks(net.minecraft.item.ItemStack itemStack,
boolean ignoreFullStacks)
Pulls all the possible non-full
ItemStack into itemStack. |
void |
readFromNBT(net.minecraft.nbt.NBTTagCompound tagCompound)
Reads this
MalisisInventory data from tagCompound. |
void |
register(java.lang.Object object)
Registers an object for the events fired by this
MalisisInventory. |
void |
removeOpenedContainer(MalisisInventoryContainer container)
Removes the opened container.
|
void |
setInventoryId(int id)
Sets the id of this
MalisisInventory inside its container. |
void |
setInventoryStackLimit(int limit)
Sets the inventory stack limit.
|
void |
setItemStack(int slotNumber,
net.minecraft.item.ItemStack itemStack)
Sets the itemStack for the slot at position slotNumber.
|
void |
setItemStackProvider(net.minecraft.item.ItemStack itemStack)
Set this
MalisisInventory contents based on the itemStack NBT. |
void |
setName(java.lang.String name)
Sets this
MalisisInventory name. |
java.lang.String |
toString() |
void |
transfer(MalisisInventory inventory)
Transfers into this
MalisisInventory the contents of inventory. |
net.minecraft.item.ItemStack |
transferInto(net.minecraft.item.ItemStack itemStack)
Transfers an
ItemStack inside this MalisisInventory. |
net.minecraft.item.ItemStack |
transferInto(net.minecraft.item.ItemStack itemStack,
boolean reversed)
Transfers itemStack inside this
MalisisInventory. |
protected net.minecraft.item.ItemStack |
transferInto(net.minecraft.item.ItemStack itemStack,
boolean emptySlot,
int start,
int end)
Transfers itemStack inside this
MalisisInventory into slots at position from start to end. |
void |
writeToNBT(net.minecraft.nbt.NBTTagCompound tagCompound)
Writes this
MalisisInventory data inside tagCompound. |
protected java.util.Set<MalisisInventoryContainer> containers
MalisisInventory that is currently containing this MalisisInventory.protected int inventoryId
protected IInventoryProvider inventoryProvider
MalisisInventory.protected net.minecraft.item.ItemStack itemStackProvider
protected net.minecraft.util.NonNullList<MalisisSlot> slots
MalisisInventory.protected java.lang.String name
MalisisInventory.protected int slotMaxStackSize
public InventoryState state
public MalisisInventory(IInventoryProvider provider, java.util.function.Supplier<? extends MalisisSlot> supplier, int size)
MalisisInventory with size amount of slots from supplied by the supplier.provider - the providersupplier - the suppliersize - the sizepublic MalisisInventory(IInventoryProvider provider, int size)
MalisisInventory.provider - the providersize - the sizepublic MalisisInventory(IInventoryProvider provider, MalisisSlot... slots)
MalisisInventory with the specified MalisisSlot.provider - the providerslots - the slotspublic IInventoryProvider getProvider()
IInventoryProvider of this MalisisInventory.public void overrideSlot(MalisisSlot slot, int slotIndex)
slot - the slotslotIndex - the slot indexpublic void register(java.lang.Object object)
MalisisInventory.object - the objectpublic void setInventoryId(int id)
MalisisInventory inside its container.id - the new inventory idpublic int getInventoryId()
MalisisInventory inside the MalisisInventoryContainer.public void setName(java.lang.String name)
MalisisInventory name.name - the new namepublic java.lang.String getName()
MalisisInventory name.public boolean hasCustomName()
MalisisInventory has a name set.public MalisisSlot getSlot(int slotIndex)
slotIndex - the slot indexpublic java.util.List<MalisisSlot> getSlots()
MalisisInventory.public java.util.List<MalisisSlot> getNonEmptySlots()
public net.minecraft.item.ItemStack getItemStack(int slotNumber)
slotNumber - the slot numberpublic void setItemStack(int slotNumber,
net.minecraft.item.ItemStack itemStack)
slotNumber - the slot numberitemStack - the item stackpublic net.minecraft.util.NonNullList<net.minecraft.item.ItemStack> getItemStackList()
ItemStack stored in this MalisisInventory.public boolean itemValidForSlot(MalisisSlot slot, net.minecraft.item.ItemStack itemStack)
slot - the slotitemStack - the item stackpublic boolean isItemValidForSlot(int slotNumber,
net.minecraft.item.ItemStack itemStack)
slotNumber - the slot numberitemStack - the item stackpublic int getSize()
MalisisInventory.public int getInventoryStackLimit()
public void setInventoryStackLimit(int limit)
limit - the new inventory stack limitpublic void setItemStackProvider(net.minecraft.item.ItemStack itemStack)
MalisisInventory contents based on the itemStack NBT. itemStack - the new item stack providerpublic void addOpenedContainer(MalisisInventoryContainer container)
container - the containerpublic void removeOpenedContainer(MalisisInventoryContainer container)
container - the containerpublic java.util.Set<MalisisInventoryContainer> getOpenedContainers()
public boolean isEmpty()
ItemStack is present in this MalisisInventory.public boolean isFull()
public void onSlotChanged(MalisisSlot slot)
slot - the slotpublic java.util.Optional<MalisisSlot> getFirstOccupiedSlot()
MalisisSlot containing an ItemStack.public net.minecraft.item.ItemStack pullItemStack()
ItemStack in this MalisisInventory and returns it.public boolean pullItemStacks(net.minecraft.item.ItemStack itemStack,
boolean ignoreFullStacks)
ItemStack into itemStack.itemStack - the item stackpublic void transfer(MalisisInventory inventory)
MalisisInventory the contents of inventory.inventory - the inventorypublic net.minecraft.item.ItemStack transferInto(net.minecraft.item.ItemStack itemStack)
ItemStack inside this MalisisInventory.itemStack - the item stackpublic net.minecraft.item.ItemStack transferInto(net.minecraft.item.ItemStack itemStack,
boolean reversed)
MalisisInventory.itemStack - the item stackreversed - if true, start filling slots from the last slotprotected net.minecraft.item.ItemStack transferInto(net.minecraft.item.ItemStack itemStack,
boolean emptySlot,
int start,
int end)
MalisisInventory into slots at position from start to end. If start > end,
the slots will be filled backwards.itemStack - the item stackemptySlot - whether to fill empty slots onlystart - the startend - the endpublic void breakInventory(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos pos)
MalisisInventory.world - the worldpos - the pospublic void emptyInventory()
MalisisInventory and sets all slots contents to null.public void closeContainers()
public void readFromNBT(net.minecraft.nbt.NBTTagCompound tagCompound)
MalisisInventory data from tagCompound.tagCompound - the tag compoundpublic void writeToNBT(net.minecraft.nbt.NBTTagCompound tagCompound)
MalisisInventory data inside tagCompound.tagCompound - the tag compoundpublic java.lang.String toString()
toString in class java.lang.Objectpublic static MalisisInventoryContainer open(net.minecraft.entity.player.EntityPlayerMP player, IInventoryProvider.IDirectInventoryProvider inventoryProvider)
MalisisInventory. Called server-side only.player - the playerinventoryProvider - the inventory providerMalisisInventoryContainerpublic static <T> MalisisInventoryContainer open(net.minecraft.entity.player.EntityPlayerMP player, IInventoryProvider.IDeferredInventoryProvider<T> inventoryProvider, T data)
MalisisInventory. Called server-side only.T - the generic typeplayer - the playerinventoryProvider - the inventory providerdata - the dataMalisisInventoryContainerpublic static MalisisInventoryContainer open(net.minecraft.client.entity.EntityPlayerSP player, IInventoryProvider.IDirectInventoryProvider inventoryProvider, int windowId)
MalisisInventory. Called client-side only.player - the playerinventoryProvider - the inventory providerwindowId - the window idMalisisInventoryContainerpublic static <T> MalisisInventoryContainer open(net.minecraft.client.entity.EntityPlayerSP player, IInventoryProvider.IDeferredInventoryProvider<T> inventoryProvider, T data, int windowId)
MalisisInventory. Called client-side only.player - the playerinventoryProvider - the inventory providerwindowId - the window iddata - the dataMalisisInventoryContainer