From 69c64a69fe24f82b2bd87b4f4e57049e32e0861e Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Tue, 20 Jun 2023 23:32:11 +0200 Subject: [PATCH] remove emerald cost from vault enchanter --- CHANGELOG.md | 1 + .../VaultModTweaks/Configuration.java | 8 +++ .../mixin/MixinEnchantmentCost.java | 64 +++++++++++++++++++ .../assets/the_vault_tweaks/lang/en_us.json | 1 + .../resources/mixins.the_vault_tweaks.json | 1 + 5 files changed, 75 insertions(+) create mode 100644 src/main/java/tv/alterNERD/VaultModTweaks/integration/mixin/MixinEnchantmentCost.java diff --git a/CHANGELOG.md b/CHANGELOG.md index c8694e4..d61fde8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # devel +* Removed Emerald cost from Vault Enchanter. * Lots of refactoring work behind the scenes. * Added i18n support and lots of logging. * Fixed AE2 fake player in existing worlds not getting new research when it is added to the pack. diff --git a/src/main/java/tv/alterNERD/VaultModTweaks/Configuration.java b/src/main/java/tv/alterNERD/VaultModTweaks/Configuration.java index 638f822..8c12c76 100644 --- a/src/main/java/tv/alterNERD/VaultModTweaks/Configuration.java +++ b/src/main/java/tv/alterNERD/VaultModTweaks/Configuration.java @@ -31,6 +31,8 @@ public class Configuration { public static BooleanValue FORTUNE_ENABLED; public static IntValue FORTUNE_LEVEL; + public static BooleanValue ENCHANTS_FORFREE; + public static BooleanValue JEWELER_ENABLED; public static DoubleValue JEWELER_CHANCE; @@ -69,6 +71,12 @@ public class Configuration { FORTUNE_LEVEL = builder.defineInRange("maxLevel", 5, 3, 5); builder.pop(); + // Enchantment Cost + builder.push("VaultEnchanter"); + builder.comment("Remove the Emerald cost from the Vault Enchanter"); + ENCHANTS_FORFREE = builder.define("removeEmeraldCost", true); + builder.pop(); + // Jeweler builder.push("Jeweler"); builder.comment("Remove the Jeweler Expertise and change the default cutting chance accordingly"); diff --git a/src/main/java/tv/alterNERD/VaultModTweaks/integration/mixin/MixinEnchantmentCost.java b/src/main/java/tv/alterNERD/VaultModTweaks/integration/mixin/MixinEnchantmentCost.java new file mode 100644 index 0000000..ecd61db --- /dev/null +++ b/src/main/java/tv/alterNERD/VaultModTweaks/integration/mixin/MixinEnchantmentCost.java @@ -0,0 +1,64 @@ +/** + * 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 java.util.LinkedList; +import java.util.List; + +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.CallbackInfo; + +import iskallia.vault.util.EnchantmentCost; +import net.minecraft.world.item.ItemStack; +import tv.alterNERD.VaultModTweaks.Configuration; +import tv.alterNERD.VaultModTweaks.VaultModTweaks; + +/** + * Changes the {@link iskallia.vault.util.EnchantmentCost} class used by the + * Vault Enchanter. + * + * Specifically, it removes the Emerald cost of enchantments. Just because I + * cannot be arsed to bring them over every time. + */ +@Mixin(EnchantmentCost.class) +public class MixinEnchantmentCost { + @Shadow(remap = false) + private List items; + + /** + * Removes the Emerald cost from all Vault Enchanter enchantments. + * + * @param items + * @param levels + * @param ci + */ + @Inject( + method = "(Ljava/util/List;I)V", + at = @At("RETURN"), + remap = false + ) + private void initCallback(List items, int levels, CallbackInfo ci) { + if (Configuration.ENCHANTS_FORFREE.get()) { + VaultModTweaks.LOGGER.info("the_vault_tweaks.log.inject.enchanter.forfree"); + this.items = new LinkedList(); + } + } +} 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 7bdcaa8..165b884 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 @@ -1,6 +1,7 @@ { "the_vault_tweaks.log.inject.ae2research": "Injecting research for AE2 fake player …", "the_vault_tweaks.log.inject.buddingcrystal": "Injecting Budding Crystal settings …", + "the_vault_tweaks.log.inject.enchanter.forfree": "Removing Emerald cost from Vault Enchanter …", "the_vault_tweaks.log.inject.expertise.fortunate": "Removing Fortunate expertise …", "the_vault_tweaks.log.inject.expertise.jeweler": "Removing Jeweler expertise …", "the_vault_tweaks.log.inject.fortune.level": "Injecting maximum Fortune level: %1$d …", diff --git a/src/main/resources/mixins.the_vault_tweaks.json b/src/main/resources/mixins.the_vault_tweaks.json index 7e8d72b..052c328 100644 --- a/src/main/resources/mixins.the_vault_tweaks.json +++ b/src/main/resources/mixins.the_vault_tweaks.json @@ -6,6 +6,7 @@ "refmap": "mixins.the_vault_tweaks.refmap.json", "mixins": [ "MixinCrystalBuddingConfig", + "MixinEnchantmentCost", "MixinEnchantmentEntry", "MixinExpertisesGuiConfig", "MixinPlayerResearchesData",