From 9da664ac78feb5ba6ba1cff8eaf7e4627c8669ba Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Thu, 9 Nov 2023 19:00:44 +0100 Subject: [PATCH] added support for overridingnew Jeweler expertise --- CHANGELOG.md | 2 +- .../VaultModTweaks/Configuration.java | 7 ++- .../mixin/MixinJewelExpertise.java | 50 +++++++++++++++++++ .../assets/the_vault_tweaks/lang/en_us.json | 1 + .../resources/mixins.the_vault_tweaks.json | 1 + 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 src/main/java/tv/alterNERD/VaultModTweaks/integration/mixin/MixinJewelExpertise.java diff --git a/CHANGELOG.md b/CHANGELOG.md index fdfcdd8..230df5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # devel -* +* Added support for overriding the new Jeweler Expertise; disabling it now grants 3 free cuts by default. # 3.12.1.0 (2023-11-09) diff --git a/src/main/java/tv/alterNERD/VaultModTweaks/Configuration.java b/src/main/java/tv/alterNERD/VaultModTweaks/Configuration.java index 2fa0ee5..1a3304f 100644 --- a/src/main/java/tv/alterNERD/VaultModTweaks/Configuration.java +++ b/src/main/java/tv/alterNERD/VaultModTweaks/Configuration.java @@ -18,7 +18,6 @@ package tv.alterNERD.VaultModTweaks; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import net.minecraft.resources.ResourceLocation; @@ -41,6 +40,7 @@ public class Configuration { public static BooleanValue JEWELER_ENABLED; public static DoubleValue JEWELER_CHANCE; + public static IntValue JEWELER_FREE_CUTS; public static BooleanValue JEWELS_ENABLED; public static IntValue JEWELS_SIZE; @@ -96,8 +96,11 @@ public class Configuration { .comment("Remove the Jeweler Expertise and change the default cutting chance accordingly") .define("disableJeweler", false); JEWELER_CHANCE = builder - .comment("Chance to break the jewel / remove a modifier") + .comment("Chance to break the jewel / remove a modifier (DEPRECATED since Vault Hunters 3.12.1)") .defineInRange("breakChance", 0.25d, 0d, 0.5d); + JEWELER_FREE_CUTS = builder + .comment("Number of free cuts (pack default: up to 3 with Jeweler Expetise)") + .defineInRange("free_cuts", 3, 0, 10); builder.pop(); // Budding Crystal diff --git a/src/main/java/tv/alterNERD/VaultModTweaks/integration/mixin/MixinJewelExpertise.java b/src/main/java/tv/alterNERD/VaultModTweaks/integration/mixin/MixinJewelExpertise.java new file mode 100644 index 0000000..f530c1f --- /dev/null +++ b/src/main/java/tv/alterNERD/VaultModTweaks/integration/mixin/MixinJewelExpertise.java @@ -0,0 +1,50 @@ +/** + * Copyright 2023 alterNERDtive. + * + * This file is part of Vault Mod Tweaks. + * + * Vault Mod Tweaks is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Vault Mod Tweaks is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with Vault Mod Tweaks. If not, see . + */ +package tv.alterNERD.VaultModTweaks.integration.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import iskallia.vault.skill.expertise.type.JewelExpertise; +import tv.alterNERD.VaultModTweaks.Configuration; +import tv.alterNERD.VaultModTweaks.VaultModTweaks; +import tv.alterNERD.VaultModTweaks.util.I18n; + +@Mixin(JewelExpertise.class) +public abstract class MixinJewelExpertise { + + @Shadow + private int numberOfFreeCuts; + + @Inject( + method = "getNumberOfFreeCuts()I", + at = @At("RETURN"), + cancellable = true, + remap = false + ) + private void getNumberOfFreeCuts$return(CallbackInfoReturnable ci) { + if (Configuration.JEWELER_ENABLED.get()) { + int cuts = Configuration.JEWELER_FREE_CUTS.get(); + VaultModTweaks.LOGGER.info(I18n.get("the_vault_tweaks.log.inject.jewelcutting.freecuts", cuts)); + ci.setReturnValue(cuts); + } + } +} diff --git a/src/main/resources/assets/the_vault_tweaks/lang/en_us.json b/src/main/resources/assets/the_vault_tweaks/lang/en_us.json index cd09e11..e8335b7 100644 --- a/src/main/resources/assets/the_vault_tweaks/lang/en_us.json +++ b/src/main/resources/assets/the_vault_tweaks/lang/en_us.json @@ -8,6 +8,7 @@ "the_vault_tweaks.log.inject.fortune.level": "Injecting maximum Fortune level: %1$d …", "the_vault_tweaks.log.inject.fortune.valid": "Overwriting validity check for Fortune …", "the_vault_tweaks.log.inject.jewelcutting.failurechance": "Injecting jewel cutting failure chance: %1$.2f …", + "the_vault_tweaks.log.inject.jewelcutting.freecuts": "Injecting free jewel cuts: %1$d …", "the_vault_tweaks.log.inject.jewelcutting.sizes": "Injecting jewel cutting size values: %1$d–%2$d …", "the_vault_tweaks.log.inject.junkmgmt.upgrades": "Injecting Vault Junk Upgrade multipliers: %1$d, %2$d, %3$d, %4$d …", "the_vault_tweaks.log.inject.relicfragments": "Balancing relic fragment weights …", diff --git a/src/main/resources/mixins.the_vault_tweaks.json b/src/main/resources/mixins.the_vault_tweaks.json index e2d8928..abb12e3 100644 --- a/src/main/resources/mixins.the_vault_tweaks.json +++ b/src/main/resources/mixins.the_vault_tweaks.json @@ -9,6 +9,7 @@ "MixinCrystalBuddingConfig", "MixinEnchantmentEntry", "MixinExpertisesGuiConfig", + "MixinJewelExpertise", "MixinPlayerResearchesData", "MixinStageManager", "MixinToolType",