First armor modifier

This commit is contained in:
mDiyo committed 2013-12-12 21:05:26 -08:00
1 parent 8b154a9cb4
commit 90f09b7e2d
12 files changed
+299 -19

No files matched your search

@@ -1,29 +1,54 @@
package tconstruct.library.armor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.EnumSet;
import java.util.UUID;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
public abstract class ArmorMod extends ToolMod
{
public ArmorMod(ItemStack[] items, int effect, String dataKey)
protected final EnumSet<EnumArmorPart> armorTypes;
public ArmorMod(int effect, String dataKey, EnumSet<EnumArmorPart> armorTypes, ItemStack[] items)
{
super(items, effect, dataKey);
this.armorTypes = armorTypes;
}
@Override
protected String getTagName()
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") > 0;
}
return false;
}
@Override
protected String getTagName ()
{
return "TinkerArmor";
}
public boolean validArmorType(ArmorCore armor)
public boolean validArmorType (ArmorCore armor)
{
return true;
}
protected NBTTagCompound getAttributeTag(String attributeType, String modifierName, double amount, boolean flat, UUID uuid)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setString("AttributeName", attributeType);
tag.setString("Name", modifierName);
tag.setDouble("Amount", amount);
tag.setInteger("Operation", flat ? 0 : 1);//0 = flat increase, 1 = % increase
tag.setLong("UUIDMost", uuid.getMostSignificantBits());
tag.setLong("UUIDLeast", uuid.getLeastSignificantBits());
return tag;
}
}
@@ -3,7 +3,7 @@ package tconstruct.library.armor;
public enum EnumArmorPart
{
HELMET(0), CHESTPLATE(1), LEGGINGS(2), BOOTS(3);
HELMET(0), CHEST(1), PANTS(2), SHOES(3);
private final int partID;
@@ -493,6 +493,15 @@ public class ToolBuilder
public static void registerToolMod (ToolMod mod)
{
if (mod == null)
throw new NullPointerException("Tool modifier cannot be null.");
instance.toolMods.add(mod);
}
public static void registerArmorMod(ArmorMod mod)
{
if (mod == null)
throw new NullPointerException("Armor modifier cannot be null.");
instance.armorMods.add(mod);
}
}