From c45cb04432af19bdabeb7b792c5f1407ee232617 Mon Sep 17 00:00:00 2001 From: Cephelo <79186646+Cephelo@users.noreply.github.com> Date: Sat, 19 Oct 2024 15:30:08 -0500 Subject: [PATCH] [1.21.1] Config option to disable upgrading Scrolls in the Arcane Anvil (#628) * jei compat (reload required to see changes) * added config option * check for config option --- .../io/redspace/ironsspellbooks/config/ServerConfigs.java | 3 +++ .../ironsspellbooks/gui/arcane_anvil/ArcaneAnvilMenu.java | 2 +- .../ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/redspace/ironsspellbooks/config/ServerConfigs.java b/src/main/java/io/redspace/ironsspellbooks/config/ServerConfigs.java index 20ad95dda..83935e52e 100644 --- a/src/main/java/io/redspace/ironsspellbooks/config/ServerConfigs.java +++ b/src/main/java/io/redspace/ironsspellbooks/config/ServerConfigs.java @@ -28,6 +28,7 @@ public class ServerConfigs { public static final ModConfigSpec.ConfigValue MAX_UPGRADES; public static final ModConfigSpec.ConfigValue MANA_SPAWN_PERCENT; public static final ModConfigSpec.ConfigValue SCROLL_RECYCLE_CHANCE; + public static final ModConfigSpec.ConfigValue SCROLL_MERGING; private static final ModConfigSpec.ConfigValue> UPGRADE_WHITELIST; private static final ModConfigSpec.ConfigValue> UPGRADE_BLACKLIST; private static final ModConfigSpec.ConfigValue> IMBUE_WHITELIST; @@ -93,6 +94,8 @@ public class ServerConfigs { BUILDER.pop(); BUILDER.push("Upgrade Overrides"); + BUILDER.comment("Whether merging scrolls with ink to upgrade them in the Arcane Anvil is enabled."); + SCROLL_MERGING = BUILDER.define("scrollMerging", true); BUILDER.comment("Use these lists to change what items can interact with the Arcane Anvil's upgrade system. This can also be done via datapack."); BUILDER.comment("Upgrade Whitelist. Use an item's id to allow it to be upgraded, ex: \"minecraft:iron_sword\""); UPGRADE_WHITELIST = BUILDER.defineListAllowEmpty("upgradeWhitelist", ArrayList::new, (string) -> true); diff --git a/src/main/java/io/redspace/ironsspellbooks/gui/arcane_anvil/ArcaneAnvilMenu.java b/src/main/java/io/redspace/ironsspellbooks/gui/arcane_anvil/ArcaneAnvilMenu.java index c6d1a2722..fc8ec1016 100644 --- a/src/main/java/io/redspace/ironsspellbooks/gui/arcane_anvil/ArcaneAnvilMenu.java +++ b/src/main/java/io/redspace/ironsspellbooks/gui/arcane_anvil/ArcaneAnvilMenu.java @@ -85,7 +85,7 @@ public void createResult() { ItemStack modifierItemStack = inputSlots.getItem(1); if (!baseItemStack.isEmpty() && !modifierItemStack.isEmpty()) { //Scroll Merging - if (baseItemStack.getItem() instanceof Scroll && modifierItemStack.getItem() instanceof InkItem inkItem/*Scroll*/) { + if (ServerConfigs.SCROLL_MERGING.get() && baseItemStack.getItem() instanceof Scroll && modifierItemStack.getItem() instanceof InkItem inkItem/*Scroll*/) { var spell1 = ISpellContainer.get(baseItemStack).getSpellAtIndex(0); if (spell1.getLevel() < spell1.getSpell().getMaxLevel()) { var baseRarity = spell1.getRarity(); diff --git a/src/main/java/io/redspace/ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java b/src/main/java/io/redspace/ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java index 6c7899d3f..770edd732 100644 --- a/src/main/java/io/redspace/ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java +++ b/src/main/java/io/redspace/ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java @@ -4,6 +4,7 @@ import io.redspace.ironsspellbooks.api.spells.AbstractSpell; import io.redspace.ironsspellbooks.api.spells.ISpellContainer; import io.redspace.ironsspellbooks.api.util.Utils; +import io.redspace.ironsspellbooks.config.ServerConfigs; import io.redspace.ironsspellbooks.item.UpgradeOrbItem; import mezz.jei.api.recipe.vanilla.IVanillaRecipeFactory; import mezz.jei.api.runtime.IIngredientManager; @@ -39,9 +40,14 @@ public static List getRecipes(IVanillaRecipeFactory vanillaRe } private static Stream getScrollRecipes(List visibleItems) { - return SpellRegistry.getEnabledSpells().stream() + if (ServerConfigs.SCROLL_MERGING.get()) { + return SpellRegistry.getEnabledSpells().stream() .sorted(Comparator.comparing(AbstractSpell::getSpellId)) .flatMap(spell -> IntStream.rangeClosed(spell.getMinLevel(), spell.getMaxLevel() - 1).mapToObj(i -> new ArcaneAnvilRecipe(spell, i))); + } + else { + return Stream.empty(); + } } private static Stream getImbueRecipes(List visibleItems) {