-
Notifications
You must be signed in to change notification settings - Fork 755
/
AModInteger.java
60 lines (50 loc) · 1.66 KB
/
AModInteger.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
51
52
53
54
55
56
57
58
59
60
package tconstruct.library.armor;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* Adds an integer NBTTag */
public class AModInteger extends ArmorMod
{
public final int modifyCount;
public final int amount;
public final String color;
public final String tooltipName;
public AModInteger(int effect, String dataKey, EnumSet<EnumArmorPart> armorTypes, ItemStack[] items, int count, int increase, String c, String tip)
{
super(effect, dataKey, armorTypes, items);
this.modifyCount = count;
this.amount = increase;
color = c;
tooltipName = tip;
}
@Override
protected boolean canModify (ItemStack armor, ItemStack[] input)
{
ArmorCore item = (ArmorCore) armor.getItem();
if (armorTypes.contains(item.armorPart))
{
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getTagName());
return tags.getInteger("Modifiers") >= modifyCount;
}
return false;
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(getTagName());
if (tags.hasKey(key))
{
int increase = tags.getInteger(key);
increase += this.amount;
tags.setInteger(key, increase);
}
else
{
tags.setInteger(key, amount);
}
int modifiers = tags.getInteger("Modifiers");
modifiers -= modifyCount;
tags.setInteger("Modifiers", modifiers);
addToolTip(tool, color + tooltipName, color + key);
}
}