reformat
This commit is contained in:
@@ -4,38 +4,48 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventorySimple implements IInventory {
|
||||
public class InventorySimple implements IInventory
|
||||
{
|
||||
private ItemStack[] inventory;
|
||||
private int size;
|
||||
private String name;
|
||||
|
||||
public InventorySimple(String name, int size) {
|
||||
public InventorySimple(String name, int size)
|
||||
{
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
this.inventory = new ItemStack[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIndex) {
|
||||
public ItemStack getStackInSlot(int slotIndex)
|
||||
{
|
||||
return inventory[slotIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
|
||||
if (stack != null) {
|
||||
if (stack.stackSize <= amount) {
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.stackSize <= amount)
|
||||
{
|
||||
setInventorySlotContents(slot, null);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = stack.splitStack(amount);
|
||||
|
||||
if (stack.stackSize == 0) {
|
||||
if (stack.stackSize == 0)
|
||||
{
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
}
|
||||
@@ -45,10 +55,12 @@ public class InventorySimple implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
ItemStack stack = getStackInSlot(slot);
|
||||
|
||||
if (stack != null) {
|
||||
if (stack != null)
|
||||
{
|
||||
setInventorySlotContents(slot, null);
|
||||
}
|
||||
|
||||
@@ -56,8 +68,10 @@ public class InventorySimple implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@@ -65,39 +79,47 @@ public class InventorySimple implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
public String getInventoryName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
public void markDirty()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user