Skip to content

Commit

Permalink
[1.21.1] Config option to disable upgrading Scrolls in the Arcane Anv…
Browse files Browse the repository at this point in the history
…il (#628)

* jei compat (reload required to see changes)

* added config option

* check for config option
  • Loading branch information
Cephelo authored Oct 19, 2024
1 parent d3cb67a commit c45cb04
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class ServerConfigs {
public static final ModConfigSpec.ConfigValue<Integer> MAX_UPGRADES;
public static final ModConfigSpec.ConfigValue<Double> MANA_SPAWN_PERCENT;
public static final ModConfigSpec.ConfigValue<Double> SCROLL_RECYCLE_CHANCE;
public static final ModConfigSpec.ConfigValue<Boolean> SCROLL_MERGING;
private static final ModConfigSpec.ConfigValue<List<? extends String>> UPGRADE_WHITELIST;
private static final ModConfigSpec.ConfigValue<List<? extends String>> UPGRADE_BLACKLIST;
private static final ModConfigSpec.ConfigValue<List<? extends String>> IMBUE_WHITELIST;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,9 +40,14 @@ public static List<ArcaneAnvilRecipe> getRecipes(IVanillaRecipeFactory vanillaRe
}

private static Stream<ArcaneAnvilRecipe> getScrollRecipes(List<Item> 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<ArcaneAnvilRecipe> getImbueRecipes(List<Item> visibleItems) {
Expand Down

0 comments on commit c45cb04

Please sign in to comment.