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 |
size
Number of slots inside this
MalisisInventory. |
protected int |
slotMaxStackSize
Maximum stack size for the slots.
|
protected 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. |
| 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. |
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.
|
java.util.List<net.minecraft.item.ItemStack> |
getItemStackList()
Gets the item stack list.
|
java.lang.String |
getName()
Gets this
MalisisInventory name. |
java.util.Set<MalisisInventoryContainer> |
getOpenedContainers()
Gets the opened containers.
|
IInventoryProvider |
getProvider()
Gets the
IInventoryProvider of this MalisisInventory. |
int |
getSizeInventory()
Gets the size inventory.
|
MalisisSlot |
getSlot(int slotNumber)
Gets the slot at position slotNumber.
|
MalisisSlot[] |
getSlots()
Gets the slots.
|
boolean |
hasCustomName()
Checks if this
MalisisInventory has a name set. |
boolean |
isEmpty()
Checks if at least one itemStack is present in inventory.
|
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 slotNumber)
Overrides a specific slot with a new one.
|
net.minecraft.item.ItemStack |
pullItemStack()
Removes the first
ItemStack in this MalisisInventory and returns it. |
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. |
void |
setSlots(MalisisSlot[] slots)
Sets the slots for this
MalisisInventory. |
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 MalisisSlot[] slots
MalisisInventory.protected java.lang.String name
MalisisInventory.protected int size
MalisisInventory.protected int slotMaxStackSize
public InventoryState state
public MalisisInventory(IInventoryProvider provider, int size)
MalisisInventory.provider - the providersize - the sizepublic MalisisInventory(IInventoryProvider provider, MalisisSlot... slots)
MalisisInventory.provider - the providerslots - the slotspublic IInventoryProvider getProvider()
IInventoryProvider of this MalisisInventory.public void setSlots(MalisisSlot[] slots)
MalisisInventory.slots - the new slotspublic void overrideSlot(MalisisSlot slot, int slotNumber)
slot - the slotslotNumber - the slot numberpublic 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 slotNumber)
slotNumber - the slot numberpublic MalisisSlot[] getSlots()
MalisisInventory.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 java.util.List<net.minecraft.item.ItemStack> getItemStackList()
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 getSizeInventory()
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()
public boolean isFull()
public void onSlotChanged(MalisisSlot slot)
slot - the slotpublic MalisisSlot getFirstOccupiedSlot()
MalisisSlot containing an ItemStack.public net.minecraft.item.ItemStack pullItemStack()
ItemStack in this MalisisInventory and returns it.public 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