mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-16 10:24:41 +00:00
Added general inventory management classes
This commit is contained in:
1 parent
16d43f287d
commit
6a8a453496
5 files changed
+726
No files matched your search
@@ -0,0 +1,130 @@
|
||||
package codechicken.lib.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventorySimple implements IInventory
|
||||
{
|
||||
public ItemStack[] items;
|
||||
public int limit;
|
||||
public String name;
|
||||
|
||||
public InventorySimple(ItemStack[] items, int limit, String name)
|
||||
{
|
||||
this.items = items;
|
||||
this.limit = limit;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public InventorySimple(ItemStack[] items, String name)
|
||||
{
|
||||
this(items, 64, name);
|
||||
}
|
||||
|
||||
public InventorySimple(ItemStack[] items, int limit)
|
||||
{
|
||||
this(items, limit, "inv");
|
||||
}
|
||||
|
||||
public InventorySimple(ItemStack[] items)
|
||||
{
|
||||
this(items, 64, "inv");
|
||||
}
|
||||
|
||||
public InventorySimple(int size, int limit, String name)
|
||||
{
|
||||
this(new ItemStack[size], limit, name);
|
||||
}
|
||||
|
||||
public InventorySimple(int size, int limit)
|
||||
{
|
||||
this(size, limit, "inv");
|
||||
}
|
||||
|
||||
public InventorySimple(int size, String name)
|
||||
{
|
||||
this(size, 64, name);
|
||||
}
|
||||
|
||||
public InventorySimple(int size)
|
||||
{
|
||||
this(size, 64, "inv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
return items[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
return InventoryUtils.decrStackSize(this, slot, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
return InventoryUtils.getStackInSlotOnClosing(this, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
items[slot] = stack;
|
||||
onInventoryChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user