diff --git a/src/main/java/fi/dy/masa/tweakeroo/util/InventoryUtils.java b/src/main/java/fi/dy/masa/tweakeroo/util/InventoryUtils.java index a3c96ebb..79704e41 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/util/InventoryUtils.java +++ b/src/main/java/fi/dy/masa/tweakeroo/util/InventoryUtils.java @@ -2,6 +2,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.io.ObjectInputFilter; import java.util.*; import java.util.function.Predicate; import java.util.regex.Matcher; @@ -430,14 +431,17 @@ private static boolean isBetterWeapon(ItemStack testedStack, ItemStack previousW return true; } - if (testedStack.isEmpty() == false && matchesWeaponMapping(testedStack, entity) && (makesMoreDamage(testedStack, previousWeapon) || matchesWeaponMapping(previousWeapon, entity) == false)) + if (testedStack.isEmpty() == false) { - if (Configs.Generic.WEAPON_SWAP_BETTER_ENCHANTS.getBooleanValue()) + if (matchesWeaponMapping(testedStack, entity) && (makesMoreDamage(testedStack, previousWeapon) || matchesWeaponMapping(previousWeapon, entity) == false)) { - return hasTheSameOrBetterRarity(testedStack, previousWeapon) && hasSameOrBetterWeaponEnchantments(testedStack, previousWeapon); - } + if (Configs.Generic.WEAPON_SWAP_BETTER_ENCHANTS.getBooleanValue()) + { + return hasTheSameOrBetterRarity(testedStack, previousWeapon) && hasSameOrBetterWeaponEnchantments(testedStack, previousWeapon); + } - return true; + return true; + } } return false; @@ -541,14 +545,17 @@ private static boolean isBetterTool(ItemStack testedStack, ItemStack previousToo return true; } - if (testedStack.isEmpty() == false && isMoreEffectiveTool(testedStack, previousTool, state)) + if (testedStack.isEmpty() == false) { - if (Configs.Generic.TOOL_SWAP_BETTER_ENCHANTS.getBooleanValue()) + if (isMoreEffectiveTool(testedStack, previousTool, state)) { - return hasTheSameOrBetterRarity(testedStack, previousTool) && hasSameOrBetterToolEnchantments(testedStack, previousTool); - } + if (Configs.Generic.TOOL_SWAP_BETTER_ENCHANTS.getBooleanValue()) + { + return hasTheSameOrBetterRarity(testedStack, previousTool) && hasSameOrBetterToolEnchantments(testedStack, previousTool); + } - return true; + return true; + } } return false; @@ -817,9 +824,6 @@ private static void repairModeHandleSlot(PlayerEntity player, EquipmentSlot type } } - /** - * Adds the enchantment checks for Tools or Weapons - */ private static int findRepairableItemNotInRepairableSlot(Slot targetSlot, PlayerEntity player) { ScreenHandler containerPlayer = player.currentScreenHandler; @@ -834,8 +838,6 @@ private static int findRepairableItemNotInRepairableSlot(Slot targetSlot, Player if ((slot.id - 36) != player.getInventory().selectedSlot && stack.isDamageable() && stack.isDamaged() && targetSlot.canInsert(stack) && getEnchantmentLevel(stack, Enchantments.MENDING) > 0) - //(hasSameOrBetterToolEnchantments(stack, targetSlot.getStack()) || - //hasSameOrBetterWeaponEnchantments(stack, targetSlot.getStack()))) { return slot.id; }