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
|
package gtPlusPlus.core.item.materials;
import static gregtech.api.enums.Mods.GregTech;
import static gtPlusPlus.core.util.minecraft.ItemUtils.getSimpleStack;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import gregtech.api.util.GTOreDictUnificator;
import gtPlusPlus.core.handler.Recipes.DecayableRecipe;
import gtPlusPlus.core.item.base.BaseItemTickable;
import gtPlusPlus.core.lib.GTPPCore;
import gtPlusPlus.core.util.minecraft.EntityUtils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
public class DustDecayable extends BaseItemTickable {
private final Item turnsIntoItem;
private final int radLevel;
public DustDecayable(String unlocal, int colour, int maxTicks, String[] desc1, Item turnsInto, int radLevel) {
super(true, true, unlocal, colour, (maxTicks / 1), desc1);
this.turnsIntoItem = turnsInto;
this.radLevel = radLevel;
GTOreDictUnificator.registerOre(unlocal, ItemUtils.getSimpleStack(this));
new DecayableRecipe(maxTicks, getSimpleStack(this), getSimpleStack(turnsInto));
}
@Override
public void registerIcons(IIconRegister reg) {
String gt = GregTech.ID + ":" + "materialicons/" + "NUCLEAR" + "/" + "dust";
this.mIcon[0] = reg.registerIcon(gt);
String gt2 = GregTech.ID + ":" + "materialicons/" + "NUCLEAR" + "/" + "dust" + "_OVERLAY";
this.mIcon[1] = reg.registerIcon(gt2);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
super.addInformation(stack, player, list, bool);
if (this.radLevel > 0) {
list.add(GTPPCore.GT_Tooltip_Radioactive.get());
}
}
@Override
public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_,
final boolean p_77663_5_) {
if (world == null || iStack == null) {
return;
}
if (world.isRemote) {
return;
}
if (entityHolding instanceof EntityPlayer) {
if (!((EntityPlayer) entityHolding).capabilities.isCreativeMode) {
EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.radLevel, world, entityHolding);
}
}
boolean a1, a2;
a1 = this.isTicking(world, iStack);
a2 = tickItemTag(world, iStack);
if (!a1 && !a2) {
if (entityHolding instanceof EntityPlayer) {
// Logger.INFO("Replacing "+iStack.getDisplayName()+" with "+replacement.getDisplayName()+".");
if (iStack.stackSize > 1) {
int u = iStack.stackSize;
ItemUtils.getSimpleStack(getDecayResult()).stackSize = u;
((EntityPlayer) entityHolding).inventory
.addItemStackToInventory((ItemUtils.getSimpleStack(getDecayResult())));
for (int l = 0; l < u; l++) {
((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this);
}
} else {
ItemUtils.getSimpleStack(getDecayResult()).stackSize = 1;
((EntityPlayer) entityHolding).inventory
.addItemStackToInventory((ItemUtils.getSimpleStack(getDecayResult())));
((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this);
}
}
}
}
public Item getDecayResult() {
return turnsIntoItem;
}
}
|