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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
package ihl.flexible_cable;
import java.util.Iterator;
import java.util.List;
import net.minecraft.item.ItemStack;
import ic2.api.recipe.IRecipeInput;
import ic2.core.IC2;
import ic2.core.item.ItemUpgradeModule;
import ihl.interfaces.IWire;
import ihl.utils.IHLUtils;
public class InvSlotProcessableIronWorkbench extends IronWorkbenchInvSlot {
public InvSlotProcessableIronWorkbench(IronWorkbenchTileEntity base1,
String name1, int oldStartIndex1, Access access1, int count) {
super(base1, name1, oldStartIndex1, access1, count);
}
@Override
public boolean accepts(ItemStack itemStack)
{
if (itemStack != null && itemStack.getItem() instanceof ItemUpgradeModule)
{
return false;
}
else
{
return true;
}
}
@Override
public void put(int index, ItemStack content)
{
super.put(index, content);
if(IC2.platform.isSimulating() && ((IronWorkbenchTileEntity)this.base).container!=null)
{
((IronWorkbenchTileEntity)this.base).resetOutput();
((IronWorkbenchTileEntity)this.base).container.detectAndSendChanges();
}
}
public void substract(List<IRecipeInput> materials, int multiplier)
{
Iterator<IRecipeInput> i1 = materials.iterator();
while(i1.hasNext())
{
IRecipeInput is1 = i1.next();
for(int i=0;i<this.size();i++)
{
ItemStack is = this.get(i);
if(is!=null && (is1.matches(is)))
{
if(is.getItem() instanceof IWire)
{
if(IHLUtils.adjustWireLength(is, -is1.getAmount()*multiplier))
{
is.stackSize=0;
}
}
else
{
is.stackSize-=is1.getAmount()*multiplier;
}
if(is.stackSize<=0)
{
this.put(i, null);
}
break;
}
}
}
}
public int getAmountOf(ItemStack rubber)
{
int amount = 0;
for(int i=0;i<this.size();i++)
{
ItemStack is = this.get(i);
if(is!=null && ((is.getItem() == rubber.getItem() && is.getItemDamage() == rubber.getItemDamage())||IHLUtils.isItemsHaveSameOreDictionaryEntry(is, rubber)))
{
amount+=is.stackSize;
}
}
return amount;
}
public int getMultiplier(List<IRecipeInput> materials)
{
int m = Integer.MAX_VALUE;
for(int i=0;i<this.size();i++)
{
ItemStack is = this.get(i);
for(IRecipeInput recipeInput:materials)
{
if(is!=null && recipeInput.matches(is))
{
m = Math.min(m, Math.max(IHLUtils.getAmountOf(is)/recipeInput.getAmount(),1));
}
}
}
return m;
}
}
|