diff --git a/gradle.properties b/gradle.properties index 8dcd0e5ab..b1b438983 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,11 +9,11 @@ author = masa mod_file_name = tweakeroo-fabric # Current mod version -mod_version = 0.20.999-sakura.2 +mod_version = 0.20.999-sakura.3 # Required malilib version -malilib_version = 0.19.999-sakura.1 -malilib_id = c9b950bef7 +malilib_version = 0.19.999-sakura.2 +malilib_id = 3244b550e0 # Minecraft, Fabric Loader and API and mappings versions minecraft_version_out = 1.21 diff --git a/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java b/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java index da01ac1ef..c4195387f 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java +++ b/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java @@ -111,6 +111,8 @@ public static class Generic public static final ConfigInteger STRUCTURE_BLOCK_MAX_SIZE = new ConfigInteger ("structureBlockMaxSize", 128, 1, 256, "The maximum dimensions for a Structure Block's saved area"); public static final ConfigString TOOL_SWITCHABLE_SLOTS = new ConfigString ("toolSwitchableSlots", "1-9", "The slots that the Tool Switch tweak is allowed to put tools to.\nNote that Tool Switch can also switch to other slots in the hotbar,\nif they already have the preferred tool, but it will only\nswap new tools to these slots"); public static final ConfigString TOOL_SWITCH_IGNORED_SLOTS = new ConfigString ("toolSwitchIgnoredSlots", "", "The slots where the Tool Switch tweak does not work when they are active."); + public static final ConfigBoolean TOOL_SWAP_BETTER_ENCHANTS = new ConfigBoolean ("toolSwapBetterEnchants", false, "Consider a Tools' Enchantments and Rarity\nfor Tool swapping, only after comparing if\nit's the correct tool to use on the target."); + public static final ConfigBoolean WEAPON_SWAP_BETTER_ENCHANTS = new ConfigBoolean ("weaponSwapBetterEnchants", false, "Consider a Weapons' Enchantments and Rarity\nfor Weapon swapping, only after comparing if \nit's the correct Weapon to use on the target."); public static final ConfigBoolean ZOOM_ADJUST_MOUSE_SENSITIVITY = new ConfigBoolean ("zoomAdjustMouseSensitivity", true, "If enabled, then the mouse sensitivity is reduced\nwhile the zoom feature is enabled and the zoom key is active"); public static final ConfigDouble ZOOM_FOV = new ConfigDouble ("zoomFov", 30, 0.01, 359.99, "The FOV value used for the zoom feature"); @@ -194,6 +196,8 @@ public static class Generic STRUCTURE_BLOCK_MAX_SIZE, TOOL_SWITCHABLE_SLOTS, TOOL_SWITCH_IGNORED_SLOTS, + TOOL_SWAP_BETTER_ENCHANTS, + WEAPON_SWAP_BETTER_ENCHANTS, ZOOM_FOV ); } diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinServerChunkLoadingManager.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinServerChunkLoadingManager.java index ccacc13ef..995be1832 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinServerChunkLoadingManager.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinServerChunkLoadingManager.java @@ -12,7 +12,7 @@ public abstract class MixinServerChunkLoadingManager { @Inject(method = "unloadChunks", cancellable = true, at = @At(value = "FIELD", - target = "Lnet/minecraft/server/world/ServerChunkLoadingManager;currentChunkHolders:Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;")) + target = "Lnet/minecraft/server/world/ServerChunkLoadingManager;chunkHolders:Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;")) private void tweakeroo_disableSaving20ChunksEveryTick(BooleanSupplier shouldKeepTicking, CallbackInfo ci) { if (Configs.Disable.DISABLE_CONSTANT_CHUNK_SAVING.getBooleanValue()) 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 c9934aa56..a3c96ebb0 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/util/InventoryUtils.java +++ b/src/main/java/fi/dy/masa/tweakeroo/util/InventoryUtils.java @@ -425,26 +425,19 @@ public static void trySwitchToWeapon(Entity entity) private static boolean isBetterWeapon(ItemStack testedStack, ItemStack previousWeapon, Entity entity) { - //int itemWeight = 0; - if (previousWeapon.isEmpty()) { return true; } - if (testedStack.isEmpty() == false) + + if (testedStack.isEmpty() == false && matchesWeaponMapping(testedStack, entity) && (makesMoreDamage(testedStack, previousWeapon) || matchesWeaponMapping(previousWeapon, entity) == false)) { - // TODO Experimental Code - /* - itemWeight += matchesWeaponMapping(testedStack, entity) ? 1 : -1; - itemWeight += hasTheSameOrBetterRarity(testedStack, previousWeapon) ? 1 : -1; - itemWeight += hasSameOrBetterWeaponEnchantments(testedStack, previousWeapon) ? 1 : -1; - itemWeight += makesMoreDamage(testedStack, previousWeapon) ? 1 : -1; - itemWeight -= matchesWeaponMapping(previousWeapon, entity) ? 1 : -1; - - return itemWeight > 0; - */ - - return testedStack.isEmpty() == false && matchesWeaponMapping(testedStack, entity) && (makesMoreDamage(testedStack, previousWeapon) || matchesWeaponMapping(previousWeapon, entity) == false); + if (Configs.Generic.WEAPON_SWAP_BETTER_ENCHANTS.getBooleanValue()) + { + return hasTheSameOrBetterRarity(testedStack, previousWeapon) && hasSameOrBetterWeaponEnchantments(testedStack, previousWeapon); + } + + return true; } return false; @@ -543,24 +536,19 @@ public static int getEnchantmentLevel(ItemStack stack, @Nonnull RegistryKey 0; - */ + if (testedStack.isEmpty() == false && isMoreEffectiveTool(testedStack, previousTool, state)) + { + if (Configs.Generic.TOOL_SWAP_BETTER_ENCHANTS.getBooleanValue()) + { + return hasTheSameOrBetterRarity(testedStack, previousTool) && hasSameOrBetterToolEnchantments(testedStack, previousTool); + } - return testedStack.isEmpty() == false && isMoreEffectiveTool(testedStack, previousTool, state); + return true; } return false; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7090c575c..798a03845 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,6 +34,6 @@ "depends": { "minecraft": ">=1.21", - "malilib": ">=0.19.999-sakura.1" + "malilib": ">=0.19.999-sakura.2" } }