mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-25 22:44:34 +00:00
#1703 added Forestry upgrades to the Dark Steel Armor
This commit is contained in:
1 parent
aaee449a70
commit
1a35e6df71
9 files changed
+226
-3
No files matched your search
@@ -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:[email protected],);after:MineFactoryReloaded", guiFactory = "crazypants.enderio.config.ConfigFactoryEIO")
|
||||
@Mod(modid = MODID, name = MOD_NAME, version = VERSION, dependencies = "required-after:[email protected],);after:MineFactoryReloaded;after:Forestry", guiFactory = "crazypants.enderio.config.ConfigFactoryEIO")
|
||||
public class EnderIO {
|
||||
|
||||
public static final String MODID = "EnderIO";
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user