Skip to content

Commit

Permalink
Merge branch '1.19.2' into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
iron431 committed Aug 5, 2024
2 parents b302701 + 6273849 commit 361b3cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
3 changes: 3 additions & 0 deletions LATEST_CHANGES.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -37,34 +28,34 @@ private ArcaneAnvilRecipeMaker() {
}

public static List<ArcaneAnvilRecipe> 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<ArcaneAnvilRecipe> getScrollRecipes(IVanillaRecipeFactory vanillaRecipeFactory, IIngredientManager ingredientManager) {
private static Stream<ArcaneAnvilRecipe> getScrollRecipes(List<Item> 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<ArcaneAnvilRecipe> getImbueRecipes(IVanillaRecipeFactory vanillaRecipeFactory, IIngredientManager ingredientManager) {
return getVisibleItems().stream()
private static Stream<ArcaneAnvilRecipe> getImbueRecipes(List<Item> visibleItems) {
return visibleItems.stream()
.filter(item -> Utils.canImbue(new ItemStack(item)))
.map(item -> new ArcaneAnvilRecipe(new ItemStack(item), (AbstractSpell) null));
}

private static Stream<ArcaneAnvilRecipe> getUpgradeRecipes(IVanillaRecipeFactory vanillaRecipeFactory, IIngredientManager ingredientManager) {
private static Stream<ArcaneAnvilRecipe> getUpgradeRecipes(List<Item> 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<Item> getVisibleItems() {
Expand Down

0 comments on commit 361b3cd

Please sign in to comment.