More Config for Magnet

* Config values re #2387 (defaults unchanged)
* Fix to @Optional.Method annotation might help with #2414 #2246
This commit is contained in:
Henry Loenwind committed 2015-05-04 17:56:13 +02:00
1 parent d54765d439
commit a1fcc934b4
4 files changed
+36 -8

No files matched your search

@@ -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);
@@ -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
@@ -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;
}
}
@@ -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;
}