-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ToB spellbook now remembers old spells after crafting
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/mystchonky/tomeofblood/common/events/RecipeEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
); | ||
} | ||
} | ||
|
||
} |