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
|
package gregtech.api.items;
import static gregtech.api.util.GT_Utility.formatNumbers;
import gregtech.common.items.GT_DepletetCell_Item;
import ic2.api.item.IBoxable;
import ic2.core.util.StackUtil;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
public class GT_RadioactiveCell_Item extends GT_Generic_Item implements IBoxable {
protected int cellCount;
protected int maxDmg;
protected int dura;
public GT_RadioactiveCell_Item(String aUnlocalized, String aEnglish, int aCellcount) {
super(aUnlocalized, aEnglish, null);
this.setMaxStackSize(64);
this.setMaxDamage(100);
setNoRepair();
this.cellCount = Math.max(1, aCellcount);
}
public static int getDurabilityOfStack(ItemStack aStack) {
NBTTagCompound tNBT = aStack.getTagCompound();
if (tNBT == null) {
tNBT = new NBTTagCompound();
aStack.setTagCompound(tNBT);
}
return tNBT.getInteger("advDmg");
}
protected static int sumUp(int a) {
int b = 0;
for (int c = 1; c <= a; c++) {
b += c;
}
return b;
}
protected static int triangularNumber(int x) {
return (x * x + x) / 2;
}
protected boolean outputPulseForStack(ItemStack aStack) {
NBTTagCompound tNBT = aStack.getTagCompound();
if (tNBT == null) {
tNBT = new NBTTagCompound();
aStack.setTagCompound(tNBT);
}
tNBT.setInteger("output", tNBT.getInteger("output") + 1);
return false; // (this.pulserate > 0) || (tNBT.getInteger("output") % -this.pulserate == 0);
}
protected boolean incrementPulseForStack(ItemStack aStack) {
NBTTagCompound tNBT = aStack.getTagCompound();
if (tNBT == null) {
tNBT = new NBTTagCompound();
aStack.setTagCompound(tNBT);
}
tNBT.setInteger("pulse", tNBT.getInteger("pulse") + 1);
return false; // (this.pulserate > 0) || (tNBT.getInteger("pulse") % -this.pulserate == 0);
}
protected void setDurabilityForStack(ItemStack aStack, int aDurability) {
NBTTagCompound tNBT = aStack.getTagCompound();
if (tNBT == null) {
tNBT = new NBTTagCompound();
aStack.setTagCompound(tNBT);
}
tNBT.setInteger("durability", aDurability);
}
public int getMaxNuclearDurability() {
return 0; // return this.maxDelay;
}
public int func_77619_b() {
return 0;
}
@Override
public boolean isBookEnchantable(ItemStack ingredient, ItemStack bookEnchant) {
return false;
}
// getIsRepairable
public boolean func_82789_a(ItemStack toBeRepaired, ItemStack repairWith) {
return false;
}
public void setDamageForStack(ItemStack stack, int advDmg) {
NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack);
nbtData.setInteger("advDmg", advDmg);
if (this.maxDmg > 0) {
double p = (double) advDmg / (double) this.maxDmg;
int newDmg = (int) (stack.getMaxDamage() * p);
if (newDmg >= stack.getMaxDamage()) {
newDmg = stack.getMaxDamage() - 1;
}
stack.setItemDamage(newDmg);
this.dura = newDmg;
}
}
public int getDamageOfStack(ItemStack stack) {
NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack);
this.dura = nbtData.getInteger("advDmg");
return this.dura;
}
public int getControlTagOfStack(ItemStack stack) {
NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack);
return nbtData.getInteger("tag");
}
public void setControlTagOfStack(ItemStack stack, int tag) {
NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack);
nbtData.setInteger("tag", tag);
}
public int getMaxDamageEx() {
return this.maxDmg;
}
public void damageItemStack(ItemStack stack, int Dmg) {
setDamageForStack(stack, getDamageOfStack(stack) + Dmg);
}
@Override
public void addAdditionalToolTips(List<String> aList, ItemStack aStack, EntityPlayer aPlayer) {
super.addAdditionalToolTips(aList, aStack, aPlayer);
// aList.add("Time left: " + (this.maxDelay - getDurabilityOfStack(aStack)) + " secs");
int rDmg = getDurabilityOfStack(aStack) * 6 / this.maxDmg;
EnumChatFormatting color2;
switch (rDmg) {
case 0:
case 1:
color2 = EnumChatFormatting.WHITE;
break;
case 2:
case 3:
case 4:
color2 = EnumChatFormatting.GRAY;
break;
default:
color2 = EnumChatFormatting.DARK_GRAY;
break;
}
EnumChatFormatting color1 =
this instanceof GT_DepletetCell_Item ? color2 = EnumChatFormatting.DARK_GRAY : EnumChatFormatting.WHITE;
aList.add(color1
+ String.format(
transItem("001", "Durability: %s/%s"),
"" + color2 + formatNumbers(this.maxDmg - getDurabilityOfStack(aStack)) + color1,
"" + formatNumbers(this.maxDmg)));
}
@Override
public boolean canBeStoredInToolbox(ItemStack itemstack) {
return true;
}
}
|