From 6cb240f90a7ecb5a83e2c4730e208776b6e604b7 Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Tue, 5 Aug 2014 02:03:07 -0400 Subject: [PATCH] Fix bad merge, re-add new DS Armor modules --- .../item/darksteel/NightVisionUpgrade.java | 62 +++++++++++++++++++ .../enderio/item/darksteel/SwimUpgrade.java | 54 ++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 src/main/java/crazypants/enderio/item/darksteel/NightVisionUpgrade.java create mode 100644 src/main/java/crazypants/enderio/item/darksteel/SwimUpgrade.java diff --git a/src/main/java/crazypants/enderio/item/darksteel/NightVisionUpgrade.java b/src/main/java/crazypants/enderio/item/darksteel/NightVisionUpgrade.java new file mode 100644 index 00000000..06bfae1b --- /dev/null +++ b/src/main/java/crazypants/enderio/item/darksteel/NightVisionUpgrade.java @@ -0,0 +1,62 @@ +package crazypants.enderio.item.darksteel; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionHelper; +import crazypants.enderio.EnderIO; +import crazypants.enderio.config.Config; + +public class NightVisionUpgrade extends AbstractUpgrade { + + private static String UPGRADE_NAME = "nightVision"; + + public static final NightVisionUpgrade INSTANCE = new NightVisionUpgrade(); + + public static NightVisionUpgrade loadFromItem(ItemStack stack) { + if(stack == null) { + return null; + } + if(stack.stackTagCompound == null) { + return null; + } + if(!stack.stackTagCompound.hasKey(KEY_UPGRADE_PREFIX + UPGRADE_NAME)) { + return null; + } + return new NightVisionUpgrade((NBTTagCompound) stack.stackTagCompound.getTag(KEY_UPGRADE_PREFIX + UPGRADE_NAME)); + } + + private static ItemStack createUpgradeItem() { + ItemStack pot = new ItemStack(Items.potionitem, 1, 0); + int res = PotionHelper.applyIngredient(0, Items.nether_wart.getPotionEffect(new ItemStack(Items.nether_wart))); + res = PotionHelper.applyIngredient(res, PotionHelper.goldenCarrotEffect); + pot.setItemDamage(res); + return pot; + } + + + public NightVisionUpgrade(NBTTagCompound tag) { + super(UPGRADE_NAME, tag); + } + + public NightVisionUpgrade() { + super(UPGRADE_NAME, "enderio.darksteel.upgrade.nightVision", createUpgradeItem(), Config.darkSteelNightVisionCost); + } + + @Override + public boolean canAddToItem(ItemStack stack) { + if(stack == null || stack.getItem() != EnderIO.itemDarkSteelHelmet) { + return false; + } + NightVisionUpgrade up = loadFromItem(stack); + if(up == null) { + return true; + } + return false; + } + + @Override + public void writeUpgradeToNBT(NBTTagCompound upgradeRoot) { + } +} diff --git a/src/main/java/crazypants/enderio/item/darksteel/SwimUpgrade.java b/src/main/java/crazypants/enderio/item/darksteel/SwimUpgrade.java new file mode 100644 index 00000000..d255b15c --- /dev/null +++ b/src/main/java/crazypants/enderio/item/darksteel/SwimUpgrade.java @@ -0,0 +1,54 @@ +package crazypants.enderio.item.darksteel; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import crazypants.enderio.EnderIO; +import crazypants.enderio.config.Config; + +public class SwimUpgrade extends AbstractUpgrade { + + private static String UPGRADE_NAME = "swim"; + + public static final SwimUpgrade INSTANCE = new SwimUpgrade(); + + public static SwimUpgrade loadFromItem(ItemStack stack) { + if(stack == null) { + return null; + } + if(stack.stackTagCompound == null) { + return null; + } + if(!stack.stackTagCompound.hasKey(KEY_UPGRADE_PREFIX + UPGRADE_NAME)) { + return null; + } + return new SwimUpgrade((NBTTagCompound) stack.stackTagCompound.getTag(KEY_UPGRADE_PREFIX + UPGRADE_NAME)); + } + + + public SwimUpgrade(NBTTagCompound tag) { + super(UPGRADE_NAME, tag); + } + + public SwimUpgrade() { + super(UPGRADE_NAME, "enderio.darksteel.upgrade.swim", new ItemStack(Blocks.waterlily), Config.darkSteelSwimCost); + } + + @Override + public boolean canAddToItem(ItemStack stack) { + if(stack == null || stack.getItem() != EnderIO.itemDarkSteelBoots) { + return false; + } + SwimUpgrade up = loadFromItem(stack); + if(up == null) { + return true; + } + return false; + } + + @Override + public void writeUpgradeToNBT(NBTTagCompound upgradeRoot) { + } + + +}