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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
package gregtech.api.items;
import gregtech.api.enums.ItemList;
import ic2.api.reactor.IReactor;
import ic2.api.reactor.IReactorComponent;
import ic2.core.IC2Potion;
import ic2.core.Ic2Items;
import ic2.core.init.InternalName;
import ic2.core.item.ItemGradualInt;
import ic2.core.item.armor.ItemArmorHazmat;
import java.util.ArrayList;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class GT_RadioactiveCellIC_Item extends GT_RadioactiveCell_Item implements IReactorComponent
{
public final int numberOfCells;
public final double sEnergy;
public final int sRadiation;
public GT_RadioactiveCellIC_Item( String aUnlocalized, String aEnglish, int aCellcount, int maxDamage, double aEnergy, int aRadiation)
{
super(aUnlocalized, aEnglish, aCellcount);
setMaxStackSize(64);
this.maxDmg=maxDamage;
this.numberOfCells = aCellcount;
this.sEnergy = aEnergy;
this.sRadiation = aRadiation;
}
private class ItemStackCoord
{
public ItemStack stack;
public int x;
public int y;
public ItemStackCoord(ItemStack stack1, int x1, int y1)
{
this.stack = stack1;
this.x = x1;
this.y = y1;
}
}
public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y, boolean heatrun)
{
if (!reactor.produceEnergy()) {
return;
}
for (int iteration = 0; iteration < this.numberOfCells; iteration++)
{
int pulses = 1 + this.numberOfCells / 2;
if (!heatrun)
{
for (int i = 0; i < pulses; i++) {
acceptUraniumPulse(reactor, yourStack, yourStack, x, y, x, y, heatrun);
}
pulses += checkPulseable(reactor, x - 1, y, yourStack, x, y, heatrun) + checkPulseable(reactor, x + 1, y, yourStack, x, y, heatrun) + checkPulseable(reactor, x, y - 1, yourStack, x, y, heatrun) + checkPulseable(reactor, x, y + 1, yourStack, x, y, heatrun);
}
else
{
pulses += checkPulseable(reactor, x - 1, y, yourStack, x, y, heatrun) + checkPulseable(reactor, x + 1, y, yourStack, x, y, heatrun) + checkPulseable(reactor, x, y - 1, yourStack, x, y, heatrun) + checkPulseable(reactor, x, y + 1, yourStack, x, y, heatrun);
int heat = sumUp(pulses) * 4;
ArrayList<ItemStackCoord> heatAcceptors = new ArrayList();
checkHeatAcceptor(reactor, x - 1, y, heatAcceptors);
checkHeatAcceptor(reactor, x + 1, y, heatAcceptors);
checkHeatAcceptor(reactor, x, y - 1, heatAcceptors);
checkHeatAcceptor(reactor, x, y + 1, heatAcceptors);
heat = (int) (heat * sEnergy);
while ((heatAcceptors.size() > 0) && (heat > 0))
{
int dheat = heat / heatAcceptors.size();
heat -= dheat;
dheat = ((IReactorComponent)((ItemStackCoord)heatAcceptors.get(0)).stack.getItem()).alterHeat(reactor, ((ItemStackCoord)heatAcceptors.get(0)).stack, ((ItemStackCoord)heatAcceptors.get(0)).x, ((ItemStackCoord)heatAcceptors.get(0)).y, dheat);
heat += dheat;
heatAcceptors.remove(0);
}
if (heat > 0) {
reactor.addHeat(heat);
}
}
}
if (getDamageOfStack(yourStack) >= getMaxDamageEx() - 1) {
switch (this.numberOfCells)
{
case 1:
reactor.setItemAt(x, y, ItemList.Depleted_Thorium_1.get(1, new Object[0]));
break;
case 2:
reactor.setItemAt(x, y, ItemList.Depleted_Thorium_2.get(1, new Object[0]));
break;
case 4:
reactor.setItemAt(x, y, ItemList.Depleted_Thorium_4.get(1, new Object[0]));
}
} else if (heatrun) {
damageItemStack(yourStack, 1);
}
}
private static int checkPulseable(IReactor reactor, int x, int y, ItemStack me, int mex, int mey, boolean heatrun)
{
ItemStack other = reactor.getItemAt(x, y);
if ((other != null) && ((other.getItem() instanceof IReactorComponent)) &&
(((IReactorComponent)other.getItem()).acceptUraniumPulse(reactor, other, me, x, y, mex, mey, heatrun))) {
return 1;
}
return 0;
}
private void checkHeatAcceptor(IReactor reactor, int x, int y, ArrayList<ItemStackCoord> heatAcceptors)
{
ItemStack thing = reactor.getItemAt(x, y);
if ((thing != null) && ((thing.getItem() instanceof IReactorComponent)) &&
(((IReactorComponent)thing.getItem()).canStoreHeat(reactor, thing, x, y))) {
heatAcceptors.add(new ItemStackCoord(thing, x, y));
}
}
public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY, boolean heatrun)
{
if (!heatrun) {
reactor.addOutput((float) (1.0F*this.sEnergy));
}
return true;
}
public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y)
{
return false;
}
public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y)
{
return 0;
}
public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y)
{
return 0;
}
public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat)
{
return heat;
}
public float influenceExplosion(IReactor reactor, ItemStack yourStack)
{
return 2 * this.numberOfCells;
}
public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem)
{
if (this.sRadiation>0&&(entity instanceof EntityLivingBase))
{
EntityLivingBase entityLiving = (EntityLivingBase)entity;
if (!ItemArmorHazmat.hasCompleteHazmat(entityLiving)) {
IC2Potion.radiation.applyTo(entityLiving, sRadiation*20, sRadiation*10);
}
}
}
}
|