From b715a5f30c76feadeab4b3bd9d037e42f238859c Mon Sep 17 00:00:00 2001 From: mystchonky Date: Sat, 4 Nov 2023 23:32:46 +0530 Subject: [PATCH] ToB spellbook now remembers old spells after crafting --- CHANGELOG.md | 4 +- .../common/events/RecipeEventHandler.java | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/mystchonky/tomeofblood/common/events/RecipeEventHandler.java diff --git a/CHANGELOG.md b/CHANGELOG.md index cab8d0b..b0d8297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ # Changelog -## [0.3.2] - Unreleased +## [0.3.2] - 2023-11-04 ## Changed - Updated textures for Heretics Armor! Thanks Gronglegrowth/Eset! - Sentient Harm Glyph now consumes will when on successful damage. The values are similar to Sentient Sword. +- Tome of Blood should now remember the old spells when crafting (the blood altar one works for now while the alchemy + table recipes need an upstream(Blood Magic) fix) ## [0.3.1] - 2023-10-30 diff --git a/src/main/java/com/mystchonky/tomeofblood/common/events/RecipeEventHandler.java b/src/main/java/com/mystchonky/tomeofblood/common/events/RecipeEventHandler.java new file mode 100644 index 0000000..1c8e351 --- /dev/null +++ b/src/main/java/com/mystchonky/tomeofblood/common/events/RecipeEventHandler.java @@ -0,0 +1,41 @@ +package com.mystchonky.tomeofblood.common.events; + +import com.hollingsworth.arsnouveau.common.items.SpellBook; +import com.mystchonky.tomeofblood.TomeOfBlood; +import com.mystchonky.tomeofblood.common.items.TomeOfBloodItem; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import wayoftime.bloodmagic.api.event.BloodMagicCraftedEvent; + +import java.util.Arrays; + +@Mod.EventBusSubscriber(modid = TomeOfBlood.MODID) +public class RecipeEventHandler { + + @SubscribeEvent + public static void altarSpellbookRecipe(BloodMagicCraftedEvent.Altar event) { + if (event.getOutput().getItem() instanceof TomeOfBloodItem) { + if (event.getInputs()[0].getItem() instanceof SpellBook) { + ItemStack tome = event.getOutput().copy(); + tome.setTag(event.getInputs()[0].getTag()); + event.setOutput(tome); + } + } + } + + @SubscribeEvent + public static void alchemyTableSpellbookRecipe(BloodMagicCraftedEvent.AlchemyTable event) { + if (event.getOutput().getItem() instanceof TomeOfBloodItem) { + Arrays.stream(event.getInputs()) + .filter(itemStack -> itemStack.getItem() instanceof TomeOfBloodItem) + .findFirst().ifPresent((input) -> { + ItemStack tome = event.getOutput().copy(); + tome.setTag(input.getTag()); + event.setOutput(tome); + } + ); + } + } + +}