diff --git a/LATEST_CHANGES.MD b/LATEST_CHANGES.MD index 0b21d7b43..0779bd0d3 100644 --- a/LATEST_CHANGES.MD +++ b/LATEST_CHANGES.MD @@ -12,6 +12,9 @@ - Increased stack size to 64 - Upgrading scrolls now requires one ink per level, instead of a scroll of equal level - The rarity of the ink is equal to the rarity of the resulting scroll rarity + - Upgrade Orbs + - Spell Power Upgrade Orbs now give +5% power (previously +3%) + - Cooldown and Resistance Upgrade Orbs now give +5% Cooldown/Spell Resistance (Previously +6%) - Spellbooks - Spellbooks now give max mana - "High Tier" spellbooks (spellbooks with spell power buffs) now give +200 Max Mana diff --git a/src/main/java/io/redspace/ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java b/src/main/java/io/redspace/ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java index 4e1cb24e2..296f4de0f 100644 --- a/src/main/java/io/redspace/ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java +++ b/src/main/java/io/redspace/ironsspellbooks/jei/ArcaneAnvilRecipeMaker.java @@ -4,25 +4,16 @@ 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.capabilities.magic.UpgradeData; import io.redspace.ironsspellbooks.item.UpgradeOrbItem; -import io.redspace.ironsspellbooks.registries.CreativeTabRegistry; -import io.redspace.ironsspellbooks.registries.ItemRegistry; -import io.redspace.ironsspellbooks.util.UpgradeUtils; import mezz.jei.api.recipe.vanilla.IVanillaRecipeFactory; import mezz.jei.api.runtime.IIngredientManager; -import net.minecraft.core.Registry; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.SwordItem; import net.minecraftforge.registries.ForgeRegistries; -import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -37,34 +28,34 @@ private ArcaneAnvilRecipeMaker() { } public static List getRecipes(IVanillaRecipeFactory vanillaRecipeFactory, IIngredientManager ingredientManager) { + var visibleItems = getVisibleItems(); return Stream.of( - getScrollRecipes(vanillaRecipeFactory, ingredientManager), - getImbueRecipes(vanillaRecipeFactory, ingredientManager), - getUpgradeRecipes(vanillaRecipeFactory, ingredientManager)) + getScrollRecipes(visibleItems), + getImbueRecipes(visibleItems), + getUpgradeRecipes(visibleItems)) .flatMap(x -> x) .toList(); } - private static Stream getScrollRecipes(IVanillaRecipeFactory vanillaRecipeFactory, IIngredientManager ingredientManager) { + private static Stream getScrollRecipes(List visibleItems) { return SpellRegistry.getEnabledSpells().stream() .sorted(Comparator.comparing(AbstractSpell::getSpellId)) .flatMap(spell -> IntStream.rangeClosed(spell.getMinLevel(), spell.getMaxLevel() - 1).mapToObj(i -> new ArcaneAnvilRecipe(spell, i))); /*.filter(ArcaneAnvilRecipe::isValid)*///Filter out any blank recipes created where min and max spell level are equal } - private static Stream getImbueRecipes(IVanillaRecipeFactory vanillaRecipeFactory, IIngredientManager ingredientManager) { - return getVisibleItems().stream() + private static Stream getImbueRecipes(List visibleItems) { + return visibleItems.stream() .filter(item -> Utils.canImbue(new ItemStack(item))) .map(item -> new ArcaneAnvilRecipe(new ItemStack(item), (AbstractSpell) null)); } - private static Stream getUpgradeRecipes(IVanillaRecipeFactory vanillaRecipeFactory, IIngredientManager ingredientManager) { + private static Stream getUpgradeRecipes(List visibleItems) { + var upgradable = visibleItems.stream().filter(item -> Utils.canBeUpgraded(new ItemStack(item))).toList(); return ForgeRegistries.ITEMS.getValues().stream() .filter(item -> item instanceof UpgradeOrbItem) - .flatMap(upgradeOrb -> - getVisibleItems().stream() - .filter(item -> Utils.canBeUpgraded(new ItemStack(item))) - .map(item -> new ArcaneAnvilRecipe(new ItemStack(item), List.of(new ItemStack(upgradeOrb))))); + .flatMap(upgradeOrb -> upgradable.stream() + .map(item -> new ArcaneAnvilRecipe(new ItemStack(item), List.of(new ItemStack(upgradeOrb))))); } public static List getVisibleItems() {