From bb06413fda7eb62880bb280a06fc1f4c794eb859 Mon Sep 17 00:00:00 2001 From: HenryLoenwind Date: Wed, 27 Jan 2016 22:48:34 +0100 Subject: [PATCH] Prevent magnet from being used as battery by default --- src/main/java/crazypants/enderio/config/Config.java | 4 ++++ .../java/crazypants/enderio/item/ItemMagnet.java | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 8a4ecbd4..3392e8f7 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -327,6 +327,7 @@ public final class Config { public static boolean magnetAllowInMainInventory = false; public static boolean magnetAllowInBaublesSlot = true; public static boolean magnetAllowDeactivatedInBaublesSlot = false; + public static boolean magnetAllowPowerExtraction = false; public static String magnetBaublesType = "AMULET"; public static boolean useCombustionGenModel = false; @@ -1098,6 +1099,9 @@ public final class Config { magnetAllowDeactivatedInBaublesSlot = config.get(sectionMagnet.name, "magnetAllowDeactivatedInBaublesSlot", magnetAllowDeactivatedInBaublesSlot, "If true the magnet can be put into the 'amulet' Baubles slot even if switched off (requires Baubles to be installed and magnetAllowInBaublesSlot to be on)").getBoolean(magnetAllowDeactivatedInBaublesSlot); + magnetAllowPowerExtraction = config.get(sectionMagnet.name, "magnetAllowPowerExtraction", magnetAllowPowerExtraction, + "If true the magnet can be used as a battery.").getBoolean(magnetAllowPowerExtraction); + magnetBaublesType = config.get(sectionMagnet.name, "magnetBaublesType", magnetBaublesType, "The BaublesType the magnet should be, 'AMULET', 'RING' or 'BELT' (requires Baubles to be installed and magnetAllowInBaublesSlot to be on)").getString(); diff --git a/src/main/java/crazypants/enderio/item/ItemMagnet.java b/src/main/java/crazypants/enderio/item/ItemMagnet.java index 1a1e6398..dd9c75c7 100644 --- a/src/main/java/crazypants/enderio/item/ItemMagnet.java +++ b/src/main/java/crazypants/enderio/item/ItemMagnet.java @@ -63,7 +63,7 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP } public static void drainPerSecondPower(ItemStack itemStack) { - DarkSteelItems.itemMagnet.extractEnergy(itemStack, Config.magnetPowerUsePerSecondRF, false); + DarkSteelItems.itemMagnet.extractEnergyInternal(itemStack, Config.magnetPowerUsePerSecondRF, false); } static MagnetController controller = new MagnetController(); @@ -137,8 +137,16 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP @Override public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + if (Config.magnetAllowPowerExtraction) { + return extractEnergyInternal(container, maxExtract, simulate); + } else { + return 0; + } + } + + public int extractEnergyInternal(ItemStack container, int maxExtract, boolean simulate) { int res = super.extractEnergy(container, maxExtract, simulate); - if(res != 0 && !simulate) { + if (res != 0 && !simulate) { updateDamage(container); } return res;