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

129 lines
2.3 KiB
Java
Raw Normal View History

package appeng.util.inv;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class WrapperInventoryRange implements IInventory
{
private IInventory src;
int[] slots;
protected boolean ignoreValidItems = false;
public static String concateLines(int[] s, String separator)
{
if ( s.length > 0 )
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length; i++)
{
if ( sb.length() > 0 )
sb.append( separator );
sb.append( s[i] );
}
return sb.toString();
}
return "";
}
public WrapperInventoryRange(IInventory a, int[] s, boolean ignoreValid) {
src = a;
slots = s;
if ( slots == null )
slots = new int[0];
ignoreValidItems = ignoreValid;
}
public WrapperInventoryRange(IInventory a, int _min, int _size, boolean ignoreValid) {
src = a;
slots = new int[_size];
for (int x = 0; x < _size; x++)
slots[x] = _min + x;
ignoreValidItems = ignoreValid;
}
@Override
public int getSizeInventory()
{
return slots.length;
}
@Override
public ItemStack getStackInSlot(int var1)
{
return src.getStackInSlot( slots[var1] );
}
@Override
public ItemStack decrStackSize(int var1, int var2)
{
return src.decrStackSize( slots[var1], var2 );
}
@Override
public ItemStack getStackInSlotOnClosing(int var1)
{
return src.getStackInSlotOnClosing( slots[var1] );
}
@Override
public void setInventorySlotContents(int var1, ItemStack var2)
{
src.setInventorySlotContents( slots[var1], var2 );
}
@Override
2014-02-09 02:34:52 +01:00
public String getInventoryName()
{
2014-02-09 02:34:52 +01:00
return src.getInventoryName();
}
@Override
public int getInventoryStackLimit()
{
return src.getInventoryStackLimit();
}
@Override
2014-02-09 02:34:52 +01:00
public void markDirty()
{
2014-02-09 02:34:52 +01:00
src.markDirty();
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1)
{
return src.isUseableByPlayer( var1 );
}
@Override
2014-02-09 02:34:52 +01:00
public void openInventory()
{
2014-02-09 02:34:52 +01:00
src.openInventory();
}
@Override
2014-02-09 02:34:52 +01:00
public void closeInventory()
{
2014-02-09 02:34:52 +01:00
src.closeInventory();
}
@Override
2014-02-09 02:34:52 +01:00
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
if ( ignoreValidItems )
return true;
return src.isItemValidForSlot( slots[i], itemstack );
}
}