diff --git a/build.gradle b/build.gradle index 170f9a2d..313a82da 100644 --- a/build.gradle +++ b/build.gradle @@ -42,6 +42,7 @@ repositories { maven { url = "http://chickenbones.net/maven/" } maven { url = "http://dl.tsr.me/artifactory/libs-release-local" } maven { url = "http://maven.tterrag.com" } + maven { url = "http://maven.ic2.player.to" } } dependencies { @@ -50,6 +51,7 @@ dependencies { compile "com.mod-buildcraft:buildcraft:${buildcraft_version}:api" compile "mcp.mobius.waila:Waila:${waila_version}" compile "tterrag.core:ttCore:${ttCore_version}" + compile "net.sengir.forestry:${forestry_version}:api" } sourceSets { diff --git a/gradle.properties b/gradle.properties index b6c240b4..5a88ad65 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,5 +10,6 @@ buildcraft_version=6.1.5 waila_version=1.5.8a_1.7.10 ae2_version=rv1-stable-1 ttCore_version=MC1.7.10-0.1.0-55 +forestry_version=forestry_1.7.10:3.3.0.423-unstable curse_projectId=64578 \ No newline at end of file diff --git a/resources/assets/enderio/lang/en_US.lang b/resources/assets/enderio/lang/en_US.lang index ba13566f..10ac6012 100644 --- a/resources/assets/enderio/lang/en_US.lang +++ b/resources/assets/enderio/lang/en_US.lang @@ -621,6 +621,21 @@ enderio.darksteel.upgrade.sound.disabled=Sound Locator Disabled enderio.darksteel.upgrade.gogglesOfRevealing.name=Revealing enderio.darksteel.upgrade.gogglesOfRevealing.tooltip.detailed.line1=Vis Discount: 5% +enderio.darksteel.upgrade.naturalistEye.name=Naturalist's Eye +enderio.darksteel.upgrade.naturalistEye.tooltip.detailed.line1=Shows pollinated tree leaves + +enderio.darksteel.upgrade.apiaristArmor.helmet.name=Apiarist's Hat +enderio.darksteel.upgrade.apiaristArmor.helmet.tooltip.detailed.line1=Protection against bees + +enderio.darksteel.upgrade.apiaristArmor.chestplate.name=Apiarist's Shirt +enderio.darksteel.upgrade.apiaristArmor.chestplate.tooltip.detailed.line1=Protection against bees + +enderio.darksteel.upgrade.apiaristArmor.leggings.name=Apiarist's Pants +enderio.darksteel.upgrade.apiaristArmor.leggings.tooltip.detailed.line1=Protection against bees + +enderio.darksteel.upgrade.apiaristArmor.boots.name=Apiarist's Shoes +enderio.darksteel.upgrade.apiaristArmor.boots.tooltip.detailed.line1=Protection against bees + item.itemGliderWing.name=Glider Wing item.itemGliderWings.name=Glider Wings item.itemGliderWings.tooltip.detailed.line1=Upgrade for Dark Steel diff --git a/src/main/java/crazypants/enderio/EnderIO.java b/src/main/java/crazypants/enderio/EnderIO.java index 7c6dc0df..92e013a0 100644 --- a/src/main/java/crazypants/enderio/EnderIO.java +++ b/src/main/java/crazypants/enderio/EnderIO.java @@ -157,7 +157,7 @@ import static crazypants.enderio.EnderIO.MODID; import static crazypants.enderio.EnderIO.MOD_NAME; import static crazypants.enderio.EnderIO.VERSION; -@Mod(modid = MODID, name = MOD_NAME, version = VERSION, dependencies = "required-after:Forge@10.13.0.1150,);after:MineFactoryReloaded", guiFactory = "crazypants.enderio.config.ConfigFactoryEIO") +@Mod(modid = MODID, name = MOD_NAME, version = VERSION, dependencies = "required-after:Forge@10.13.0.1150,);after:MineFactoryReloaded;after:Forestry", guiFactory = "crazypants.enderio.config.ConfigFactoryEIO") public class EnderIO { public static final String MODID = "EnderIO"; diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 112c2798..0271f103 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -211,6 +211,8 @@ public final class Config { public static int darkSteelGogglesOfRevealingCost = 10; + public static int darkSteelApiaristArmorCost = 10; + public static int darkSteelSwimCost = 10; public static int darkSteelNightVisionCost = 10; @@ -788,6 +790,9 @@ public final class Config { darkSteelGogglesOfRevealingCost= config.get(sectionDarkSteel.name, "darkSteelGogglesOfRevealingCost", darkSteelGogglesOfRevealingCost, "Number of levels required for the Goggles of Revealing upgrade.").getInt(darkSteelGogglesOfRevealingCost); + darkSteelApiaristArmorCost= config.get(sectionDarkSteel.name, "darkSteelApiaristArmorCost", darkSteelApiaristArmorCost, + "Number of levels required for the Apiarist Armor upgrade.").getInt(darkSteelApiaristArmorCost); + darkSteelTravelCost = config.get(sectionDarkSteel.name, "darkSteelTravelCost", darkSteelTravelCost, "Number of levels required for the 'Travel' upgrade.").getInt(darkSteelTravelCost); diff --git a/src/main/java/crazypants/enderio/item/darksteel/ApiaristArmorUpgrade.java b/src/main/java/crazypants/enderio/item/darksteel/ApiaristArmorUpgrade.java new file mode 100644 index 00000000..d5165d0d --- /dev/null +++ b/src/main/java/crazypants/enderio/item/darksteel/ApiaristArmorUpgrade.java @@ -0,0 +1,92 @@ +package crazypants.enderio.item.darksteel; + +import cpw.mods.fml.common.registry.GameRegistry; +import crazypants.enderio.config.Config; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ApiaristArmorUpgrade extends AbstractUpgrade { + + private static String UPGRADE_NAME = "apiaristArmor"; + + private static final String forestryItemNames[] = { + "apiaristHelmet", "apiaristChest", "apiaristLegs", "apiaristBoots"}; + + public static final ApiaristArmorUpgrade HELMET = new ApiaristArmorUpgrade(0); + public static final ApiaristArmorUpgrade CHEST = new ApiaristArmorUpgrade(1); + public static final ApiaristArmorUpgrade LEGS = new ApiaristArmorUpgrade(2); + public static final ApiaristArmorUpgrade BOOTS = new ApiaristArmorUpgrade(3); + + public static ItemStack getApiaristArmor(int slot) { + Item i = GameRegistry.findItem("Forestry", forestryItemNames[slot]); + if(i != null) { + return new ItemStack(i); + } + return null; + } + + public static ApiaristArmorUpgrade 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 ApiaristArmorUpgrade((NBTTagCompound) stack.stackTagCompound.getTag(KEY_UPGRADE_PREFIX + UPGRADE_NAME)); + } + + private final int slot; + + public ApiaristArmorUpgrade(NBTTagCompound tag) { + super(UPGRADE_NAME, tag); + this.slot = tag.getInteger("slot"); + } + + public ApiaristArmorUpgrade(int slot) { + super(UPGRADE_NAME, + "enderio.darksteel.upgrade.apiaristArmor.".concat(ItemDarkSteelArmor.NAMES[slot]), + getApiaristArmor(slot), Config.darkSteelApiaristArmorCost); + this.slot = slot; + } + + @Override + public boolean canAddToItem(ItemStack stack) { + if(stack == null || stack.getItem() != ItemDarkSteelArmor.forArmorType(slot) || getUpgradeItem() == null) { + return false; + } + ApiaristArmorUpgrade up = loadFromItem(stack); + return up == null; + } + + @Override + public boolean hasUpgrade(ItemStack stack) { + return super.hasUpgrade(stack) && stack.getItem() == ItemDarkSteelArmor.forArmorType(slot); + } + + @Override + public void writeUpgradeToNBT(NBTTagCompound upgradeRoot) { + upgradeRoot.setByte("slot", (byte)slot); + } + + @Override + public ItemStack getUpgradeItem() { + if(upgradeItem != null) { + return upgradeItem; + } + upgradeItem = getApiaristArmor(slot); + return upgradeItem; + } + + @Override + public String getUpgradeItemName() { + if(getUpgradeItem() == null) { + return "Apiarist Armor"; + } + return super.getUpgradeItemName(); + } +} diff --git a/src/main/java/crazypants/enderio/item/darksteel/DarkSteelRecipeManager.java b/src/main/java/crazypants/enderio/item/darksteel/DarkSteelRecipeManager.java index 0216a46e..e71c0a9a 100644 --- a/src/main/java/crazypants/enderio/item/darksteel/DarkSteelRecipeManager.java +++ b/src/main/java/crazypants/enderio/item/darksteel/DarkSteelRecipeManager.java @@ -49,6 +49,13 @@ public class DarkSteelRecipeManager { if(Loader.isModLoaded("Thaumcraft")) { upgrades.add(GogglesOfRevealingUpgrade.INSTANCE); } + if(Loader.isModLoaded("Forestry")) { + upgrades.add(NaturalistEyeUpgrade.INSTANCE); + upgrades.add(ApiaristArmorUpgrade.HELMET); + upgrades.add(ApiaristArmorUpgrade.CHEST); + upgrades.add(ApiaristArmorUpgrade.LEGS); + upgrades.add(ApiaristArmorUpgrade.BOOTS); + } } @SubscribeEvent diff --git a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelArmor.java b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelArmor.java index be982cd5..56d5976d 100644 --- a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelArmor.java +++ b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelArmor.java @@ -33,14 +33,18 @@ import crazypants.enderio.config.Config; import crazypants.enderio.gui.IAdvancedTooltipProvider; import crazypants.util.ItemUtil; import crazypants.util.Lang; +import forestry.api.apiculture.IArmorApiarist; +import forestry.api.core.IArmorNaturalist; @InterfaceList({ @Interface(iface = "thaumcraft.api.IGoggles", modid = "Thaumcraft"), @Interface(iface = "thaumcraft.api.IVisDiscountGear", modid = "Thaumcraft"), - @Interface(iface = "thaumcraft.api.nodes.IRevealer", modid = "Thaumcraft") + @Interface(iface = "thaumcraft.api.nodes.IRevealer", modid = "Thaumcraft"), + @Interface(iface = "forestry.api.apiculture.IArmorApiarist", modid = "Forestry"), + @Interface(iface = "forestry.api.core.IArmorNaturalist", modid = "Forestry") }) public class ItemDarkSteelArmor extends ItemArmor implements IEnergyContainerItem, ISpecialArmor, IAdvancedTooltipProvider, IDarkSteelItem, IGoggles, - IRevealer, IVisDiscountGear { + IRevealer, IVisDiscountGear, IArmorApiarist, IArmorNaturalist { public static final ArmorMaterial MATERIAL = EnumHelper.addArmorMaterial("darkSteel", 35, new int[] { 2, 6, 5, 2 }, 15); @@ -294,4 +298,20 @@ public class ItemDarkSteelArmor extends ItemArmor implements IEnergyContainerIte this.gogglesUgradeActive = gogglesUgradeActive; } + // Forestry + + @Override + @Method(modid = "Forestry") + public boolean protectPlayer(EntityPlayer player, ItemStack armor, String cause, boolean doProtect) { + return ApiaristArmorUpgrade.loadFromItem(armor) != null; + } + + @Override + @Method(modid = "Forestry") + public boolean canSeePollination(EntityPlayer player, ItemStack armor, boolean doSee) { + if(armor == null || armor.getItem() != EnderIO.itemDarkSteelHelmet) { + return false; + } + return NaturalistEyeUpgrade.isUpgradeEquipped(player); + } } diff --git a/src/main/java/crazypants/enderio/item/darksteel/NaturalistEyeUpgrade.java b/src/main/java/crazypants/enderio/item/darksteel/NaturalistEyeUpgrade.java new file mode 100644 index 00000000..9f44a03f --- /dev/null +++ b/src/main/java/crazypants/enderio/item/darksteel/NaturalistEyeUpgrade.java @@ -0,0 +1,81 @@ +package crazypants.enderio.item.darksteel; + +import cpw.mods.fml.common.registry.GameRegistry; +import crazypants.enderio.EnderIO; +import crazypants.enderio.config.Config; +import static crazypants.enderio.item.darksteel.AbstractUpgrade.KEY_UPGRADE_PREFIX; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class NaturalistEyeUpgrade extends AbstractUpgrade { + + private static String UPGRADE_NAME = "naturalistEye"; + + public static final NaturalistEyeUpgrade INSTANCE = new NaturalistEyeUpgrade(); + + public static ItemStack getNaturalistEye() { + Item i = GameRegistry.findItem("Forestry", "naturalistHelmet"); + if(i != null) { + return new ItemStack(i); + } + return null; + } + + public static NaturalistEyeUpgrade 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 NaturalistEyeUpgrade((NBTTagCompound) stack.stackTagCompound.getTag(KEY_UPGRADE_PREFIX + UPGRADE_NAME)); + } + + public static boolean isUpgradeEquipped(EntityPlayer player) { + ItemStack helmet = player.getEquipmentInSlot(4); + return NaturalistEyeUpgrade.loadFromItem(helmet) != null; + } + + public NaturalistEyeUpgrade(NBTTagCompound tag) { + super(UPGRADE_NAME, tag); + } + + public NaturalistEyeUpgrade() { + super(UPGRADE_NAME, "enderio.darksteel.upgrade.naturalistEye",getNaturalistEye(), Config.darkSteelApiaristArmorCost); + } + + @Override + public boolean canAddToItem(ItemStack stack) { + if(stack == null || stack.getItem() != EnderIO.itemDarkSteelHelmet || getUpgradeItem() == null) { + return false; + } + NaturalistEyeUpgrade up = loadFromItem(stack); + return up == null; + } + + @Override + public void writeUpgradeToNBT(NBTTagCompound upgradeRoot) { + } + + @Override + public ItemStack getUpgradeItem() { + if(upgradeItem != null) { + return upgradeItem; + } + upgradeItem = getNaturalistEye(); + return upgradeItem; + } + + @Override + public String getUpgradeItemName() { + if(getUpgradeItem() == null) { + return "Naturalist Helmet"; + } + return super.getUpgradeItemName(); + } +}