diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 19e721a8..e3ef7ec2 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -311,6 +311,11 @@ public final class Config { public static String[] magnetBlacklist = new String[] { "appliedenergistics2:item.ItemCrystalSeed", "Botania:livingrock", "Botania:manaTablet" }; + public static boolean magnetAllowInMainInventory = false; + public static boolean magnetAllowInBaublesSlot = true; + public static boolean magnetAllowDeactivatedInBaublesSlot = false; + public static String magnetBaublesType = "AMULET"; + public static boolean useCombustionGenModel = false; public static int crafterRfPerCraft = 2500; @@ -1046,6 +1051,17 @@ public final class Config { magnetBlacklist = config.getStringList("magnetBlacklist", sectionMagnet.name, magnetBlacklist, "These items will not be picked up by the magnet."); + magnetAllowInMainInventory = config.get(sectionMagnet.name, "magnetAllowInMainInventory", magnetAllowInMainInventory, + "If true the magnet will also work in the main inventory, not just the hotbar").getBoolean(magnetAllowInMainInventory); + + magnetAllowInBaublesSlot = config.get(sectionMagnet.name, "magnetAllowInBaublesSlot", magnetAllowInBaublesSlot, + "If true the magnet can be put into the 'amulet' Baubles slot (requires Baubles to be installed)").getBoolean(magnetAllowInBaublesSlot); + 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); + + magnetBaublesType = config.get(sectionMagnet.name, "magnetBaublesType", magnetBaublesType, + "The BaulesType the magnet should be, 'AMULET', 'RING' or 'BELT' (requires Baubles to be installed and magnetAllowInBaublesSlot to be on)").getString(); + useCombustionGenModel = config.get(sectionAesthetic.name, "useCombustionGenModel", useCombustionGenModel, "If set to true: WIP Combustion Generator model will be used").getBoolean(useCombustionGenModel); diff --git a/src/main/java/crazypants/enderio/item/ItemMagnet.java b/src/main/java/crazypants/enderio/item/ItemMagnet.java index f6f0dead..15e48cac 100644 --- a/src/main/java/crazypants/enderio/item/ItemMagnet.java +++ b/src/main/java/crazypants/enderio/item/ItemMagnet.java @@ -173,9 +173,15 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP } @Override - @Method(modid = "Baubles") + @Method(modid = "Baubles|API") public BaubleType getBaubleType(ItemStack itemstack) { - return baubles.api.BaubleType.AMULET; + BaubleType t = null; + try { + t = BaubleType.valueOf(Config.magnetBaublesType); + } catch (Exception e) { + //NOP + } + return t != null ? t : BaubleType.AMULET; } @Override @@ -206,7 +212,7 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP @Override public boolean canEquip(ItemStack itemstack, EntityLivingBase player) { - return isActive(itemstack); + return Config.magnetAllowInBaublesSlot && (Config.magnetAllowDeactivatedInBaublesSlot || isActive(itemstack)); } @Override diff --git a/src/main/java/crazypants/enderio/item/KeyTracker.java b/src/main/java/crazypants/enderio/item/KeyTracker.java index b6b034dd..3cfd6681 100644 --- a/src/main/java/crazypants/enderio/item/KeyTracker.java +++ b/src/main/java/crazypants/enderio/item/KeyTracker.java @@ -113,7 +113,8 @@ public class KeyTracker { for (int i = 0; i < baubles.getSizeInventory(); i++) { ItemStack stack = baubles.getStackInSlot(i); if(stack != null && stack.getItem() != null && stack.getItem() == itemMagnet) { - PacketHandler.INSTANCE.sendToServer(new PacketMagnetState(SlotType.BAUBLES, i, false)); + boolean isActive = !ItemMagnet.isActive(inv[i]); + PacketHandler.INSTANCE.sendToServer(new PacketMagnetState(SlotType.BAUBLES, i, isActive)); return; } } diff --git a/src/main/java/crazypants/enderio/item/MagnetController.java b/src/main/java/crazypants/enderio/item/MagnetController.java index 1a98ce8a..f87c20b3 100644 --- a/src/main/java/crazypants/enderio/item/MagnetController.java +++ b/src/main/java/crazypants/enderio/item/MagnetController.java @@ -46,7 +46,8 @@ public class MagnetController implements IEntitySelector { private ActiveMagnet getActiveMagnet(EntityPlayer player) { ItemStack[] inv = player.inventory.mainInventory; - for(int i=0;i<9;i++) { + int maxSlot = Config.magnetAllowInMainInventory ? 4 * 9 : 9; + for (int i = 0; i < maxSlot;i++) { if(ItemMagnet.isActive(inv[i]) && ItemMagnet.hasPower(inv[i])) { return new ActiveMagnet(inv[i], i); } @@ -149,7 +150,7 @@ public class MagnetController implements IEntitySelector { if (stack == null || stack.getItem() == null || stack.getItem() != itemMagnet || ItemMagnet.isActive(stack) == isActive) { return; } - if (type == SlotType.BAUBLES) { + if (!Config.magnetAllowDeactivatedInBaublesSlot && type == SlotType.BAUBLES && !isActive) { ItemStack[] inv = player.inventory.mainInventory; for (int i = 0; i < inv.length && dropOff < 0; i++) { if (inv[i] == null) { @@ -169,8 +170,12 @@ public class MagnetController implements IEntitySelector { case ARMOR: return; case BAUBLES: - baubles.setInventorySlotContents(slot, null); - player.inventory.setInventorySlotContents(dropOff, stack); + if (dropOff < 0) { + player.inventory.setInventorySlotContents(slot, stack); + } else { + baubles.setInventorySlotContents(slot, null); + player.inventory.setInventorySlotContents(dropOff, stack); + } player.inventory.markDirty(); break; }