2013-09-05 12:39:18 -07:00
|
|
|
package tconstruct.inventory;
|
2013-07-27 17:03:16 +10:00
|
|
|
|
2013-09-05 12:39:18 -07:00
|
|
|
import tconstruct.util.landmine.behavior.Behavior;
|
2013-07-27 17:03:16 +10:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
2013-08-31 05:13:31 -07:00
|
|
|
public class SlotBehavedOnly extends Slot
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public SlotBehavedOnly(IInventory par1iInventory, int par2, int par3, int par4)
|
|
|
|
|
{
|
|
|
|
|
super(par1iInventory, par2, par3, par4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isItemValid (ItemStack par1ItemStack)
|
|
|
|
|
{
|
|
|
|
|
Behavior b = Behavior.getBehaviorFromStack(par1ItemStack);
|
|
|
|
|
|
|
|
|
|
if (b == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int stackL = b.getStackLimit(par1ItemStack);
|
|
|
|
|
|
|
|
|
|
if (b != null && this.inventory.getStackInSlot(this.slotNumber) != null && !this.inventory.getStackInSlot(this.slotNumber).isItemEqual(par1ItemStack))
|
|
|
|
|
{
|
|
|
|
|
ItemStack is = this.inventory.getStackInSlot(this.slotNumber);
|
|
|
|
|
if (is.stackSize + par1ItemStack.stackSize <= stackL)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return par1ItemStack.stackSize <= stackL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
//return b != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getSlotStackLimit (ItemStack par1ItemStack)
|
|
|
|
|
{
|
|
|
|
|
return Behavior.getBehaviorFromStack(par1ItemStack) != null ? Behavior.getBehaviorFromStack(par1ItemStack).getStackLimit(par1ItemStack) : 1;
|
|
|
|
|
}
|
2013-07-27 17:03:16 +10:00
|
|
|
}
|