-
Notifications
You must be signed in to change notification settings - Fork 754
/
AModProtection.java
41 lines (33 loc) · 1.3 KB
/
AModProtection.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
package tconstruct.modifiers.armor;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.armor.EnumArmorPart;
public class AModProtection extends ArmorModTypeFilter
{
int modifyAmount = 3;
public AModProtection(int effect, EnumSet<EnumArmorPart> armorTypes, ItemStack[] items, int[] values)
{
super(effect, "ExoProtection", armorTypes, items, values);
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(getTagName());
int amount = matchingItems(input) * modifyAmount;
return tags.getInteger("Modifiers") >= amount;
}
@Override
public void modify (ItemStack[] input, ItemStack armor)
{
NBTTagCompound baseTag = armor.getTagCompound();
NBTTagCompound armorTag = armor.getTagCompound().getCompoundTag(getTagName());
int modifiers = armorTag.getInteger("Modifiers");
modifiers -= matchingItems(input) * modifyAmount;
armorTag.setInteger("Modifiers", modifiers);
int amount = matchingAmount(input);
double absorb = armorTag.getDouble("protection");
absorb += amount;
armorTag.setDouble("protection", absorb);
}
}