-
Notifications
You must be signed in to change notification settings - Fork 754
/
SlotBehavedOnly.java
50 lines (41 loc) · 1.4 KB
/
SlotBehavedOnly.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package tconstruct.inventory;
import tconstruct.util.landmine.behavior.Behavior;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
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;
}
}