Applied-Energistics-2-tiler.../util/inv/WrapperInvSlot.java

118 lines
2 KiB
Java
Raw Normal View History

2013-12-28 22:02:33 +01:00
package appeng.util.inv;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
2014-07-12 23:28:55 +02:00
public class WrapperInvSlot
2013-12-28 22:02:33 +01:00
{
2014-07-12 23:28:55 +02:00
class InternalInterfaceWrapper implements IInventory
2013-12-28 22:02:33 +01:00
{
2014-07-12 23:28:55 +02:00
private final IInventory inv;
private final int slot;
public InternalInterfaceWrapper(IInventory target, int slot) {
this.inv = target;
this.slot = slot;
}
@Override
public int getSizeInventory()
{
return 1;
}
@Override
public ItemStack getStackInSlot(int i)
{
return inv.getStackInSlot( slot );
}
@Override
public ItemStack decrStackSize(int i, int num)
{
return inv.decrStackSize( slot, num );
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
{
return inv.getStackInSlotOnClosing( slot );
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
{
inv.setInventorySlotContents( slot, itemstack );
}
@Override
public String getInventoryName()
{
return inv.getInventoryName();
}
@Override
public boolean hasCustomInventoryName()
{
return inv.hasCustomInventoryName();
}
@Override
public int getInventoryStackLimit()
{
return inv.getInventoryStackLimit();
}
@Override
public void markDirty()
{
inv.markDirty();
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return inv.isUseableByPlayer( entityplayer );
}
@Override
public void openInventory()
{
inv.openInventory();
}
@Override
public void closeInventory()
{
inv.closeInventory();
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return isItemValid( itemstack ) && inv.isItemValidForSlot( slot, itemstack );
}
};
private IInventory inv;
2013-12-28 22:02:33 +01:00
2014-07-12 23:28:55 +02:00
public WrapperInvSlot(IInventory inv) {
this.inv = inv;
2013-12-28 22:02:33 +01:00
}
2014-07-12 23:28:55 +02:00
public IInventory getWrapper(int slot)
2013-12-28 22:02:33 +01:00
{
2014-07-12 23:28:55 +02:00
InternalInterfaceWrapper wrapper = new InternalInterfaceWrapper( inv, slot );
return wrapper;
2013-12-28 22:02:33 +01:00
}
2014-07-12 23:28:55 +02:00
protected boolean isItemValid(ItemStack itemstack)
2013-12-28 22:02:33 +01:00
{
2014-07-12 23:28:55 +02:00
return true;
2013-12-28 22:02:33 +01:00
}
}