-
Notifications
You must be signed in to change notification settings - Fork 753
/
AModBoolean.java
55 lines (45 loc) · 1.59 KB
/
AModBoolean.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
package tconstruct.modifiers.armor;
import java.util.EnumSet;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.armor.ArmorMod;
import tconstruct.library.armor.ArmorPart;
/* Adds a boolean NBTTag */
public class AModBoolean extends ArmorMod
{
String color;
String tooltipName;
public AModBoolean(int effect, String tag, EnumSet<ArmorPart> armorTypes, ItemStack[] items, String c, String tip)
{
super(effect, tag, armorTypes, items);
color = c;
tooltipName = tip;
}
@Override
protected boolean canModify (ItemStack armor, ItemStack[] recipe)
{
Item i = armor.getItem();
if (!(i instanceof ArmorCore))
return false;
ArmorCore item = (ArmorCore) armor.getItem();
if (armorTypes.contains(item.armorPart))
{
NBTTagCompound tags = getModifierTag(armor);
return tags.getInteger("Modifiers") > 0;
}
NBTTagCompound tags = getModifierTag(armor);
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); //Will fail if the modifier is false or the tag doesn't exist
}
@Override
public void modify (ItemStack[] recipe, ItemStack input)
{
NBTTagCompound tags =getModifierTag(input);
tags.setBoolean(key, true);
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
addToolTip(input, color + tooltipName, color + key);
}
}