From 103242d3c09bcd8879cda5ab78d9d03f5148982f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20R=C3=B6schke?= Date: Sat, 5 Mar 2022 15:38:28 +0100 Subject: [PATCH] Added Scroll of Spelltransfer. --- .../datagen/LanguageProvider.java | 1 + .../arsinstrumentum/datagen/Recipes.java | 7 ++ .../items/CopyPasteSpellScroll.java | 102 ++++++++++++++++++ .../arsinstrumentum/setup/Registration.java | 2 + .../items/copy_paste_spell_scroll.png | Bin 0 -> 795 bytes .../equipment/copy_paste_spell_scroll.json | 15 +++ 6 files changed, 127 insertions(+) create mode 100644 src/main/java/de/sarenor/arsinstrumentum/items/CopyPasteSpellScroll.java create mode 100644 src/main/resources/assets/ars_instrumentum/textures/items/copy_paste_spell_scroll.png create mode 100644 src/main/resources/data/ars_instrumentum/patchouli_books/wizards_scratchpad/en_us/entries/categories/equipment/copy_paste_spell_scroll.json diff --git a/src/main/java/de/sarenor/arsinstrumentum/datagen/LanguageProvider.java b/src/main/java/de/sarenor/arsinstrumentum/datagen/LanguageProvider.java index 729a45e..41c0238 100644 --- a/src/main/java/de/sarenor/arsinstrumentum/datagen/LanguageProvider.java +++ b/src/main/java/de/sarenor/arsinstrumentum/datagen/LanguageProvider.java @@ -23,6 +23,7 @@ protected void addTranslations() { add(Registration.SCROLL_OF_SAVE_STARBUNCLE.get(), "Scroll of Save Starbuncle"); add(Registration.RUNIC_STORAGE_STONE.get(), "Runic Stone of Storage"); add(Registration.FAKE_WILDEN_TRIBUTE.get(), "Essence of Vanquished Foes"); + add(Registration.COPY_PASTE_SPELL_SCROLL.get(), "Scroll of Spelltransfer"); add(SWITCH_ARMARIUM_SLOT_ID, "Switch Wizards Armarium"); add(CHOOSE_ARMARIUM_SLOT_ID, "(Wizards Armarium) Toggle Selection HUD"); log.info("ArsInstrumentum: AddTranslation ended"); diff --git a/src/main/java/de/sarenor/arsinstrumentum/datagen/Recipes.java b/src/main/java/de/sarenor/arsinstrumentum/datagen/Recipes.java index 83dc19e..fc820c0 100644 --- a/src/main/java/de/sarenor/arsinstrumentum/datagen/Recipes.java +++ b/src/main/java/de/sarenor/arsinstrumentum/datagen/Recipes.java @@ -38,5 +38,12 @@ protected void buildCraftingRecipes(Consumer consumer) { ShapelessRecipeBuilder.shapeless(Registration.RUNIC_STORAGE_STONE.get()).unlockedBy("has_journal", InventoryChangeTrigger.TriggerInstance.hasItems(ItemsRegistry.WORN_NOTEBOOK)) .requires(Registration.RUNIC_STORAGE_STONE.get()) .save(consumer, ArsInstrumentum.MODID + ":" + RunicStorageStone.RUNIC_STORAGE_STONE_ALTERNATE_RECIPE_ID); + + ShapelessRecipeBuilder.shapeless(Registration.COPY_PASTE_SPELL_SCROLL.get()).unlockedBy("has_journal", InventoryChangeTrigger.TriggerInstance.hasItems(ItemsRegistry.WORN_NOTEBOOK)) + .requires(ItemsRegistry.BLANK_PARCHMENT) + .requires(ItemsRegistry.SOURCE_GEM) + .requires(Items.INK_SAC) + .requires(Items.FEATHER) + .save(consumer); } } diff --git a/src/main/java/de/sarenor/arsinstrumentum/items/CopyPasteSpellScroll.java b/src/main/java/de/sarenor/arsinstrumentum/items/CopyPasteSpellScroll.java new file mode 100644 index 0000000..cdb16b0 --- /dev/null +++ b/src/main/java/de/sarenor/arsinstrumentum/items/CopyPasteSpellScroll.java @@ -0,0 +1,102 @@ +package de.sarenor.arsinstrumentum.items; + +import com.hollingsworth.arsnouveau.ArsNouveau; +import com.hollingsworth.arsnouveau.api.item.ICasterTool; +import com.hollingsworth.arsnouveau.api.spell.ISpellCaster; +import com.hollingsworth.arsnouveau.api.spell.Spell; +import com.hollingsworth.arsnouveau.api.util.CasterUtil; +import com.hollingsworth.arsnouveau.common.items.ModItem; +import com.hollingsworth.arsnouveau.common.items.SpellBook; +import com.hollingsworth.arsnouveau.common.items.SpellParchment; +import com.hollingsworth.arsnouveau.common.util.PortUtil; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class CopyPasteSpellScroll extends ModItem implements ICasterTool { + + public static final String COPY_PASTE_SPELL_SCROLL = "copy_paste_spell_scroll"; + public static final String APPLIED_CONFIGURATION = "Applied Spell"; + + public CopyPasteSpellScroll() { + super((new Properties()).stacksTo(1).tab(ArsNouveau.itemGroup)); + } + + @Override + public InteractionResultHolder use(Level worldIn, Player player, InteractionHand handIn) { + ItemStack usedCopyPasteScroll = player.getItemInHand(handIn); + if (!worldIn.isClientSide() && player.isShiftKeyDown()) { + ItemStack offhand = player.getOffhandItem(); + if (offhand.getItem() instanceof ICasterTool offhandCasterTool) { + ISpellCaster copyPasteSpellcaster = this.getSpellCaster(usedCopyPasteScroll); + ISpellCaster offhandSpellcaster = offhandCasterTool.getSpellCaster(offhand); + offhandSpellcaster.setSpell(copyPasteSpellcaster.getSpell()); + offhandSpellcaster.setColor(copyPasteSpellcaster.getColor()); + offhandSpellcaster.setSpellName(copyPasteSpellcaster.getSpellName()); + PortUtil.sendMessage(player, new TextComponent(APPLIED_CONFIGURATION)); + return new InteractionResultHolder<>(InteractionResult.SUCCESS, usedCopyPasteScroll); + } else { + return new InteractionResultHolder<>(InteractionResult.PASS, usedCopyPasteScroll); + } + } + return new InteractionResultHolder<>(InteractionResult.PASS, usedCopyPasteScroll); + } + + public boolean onScribe(Level world, BlockPos pos, Player player, InteractionHand handIn, ItemStack stack) { + ItemStack heldStack = player.getItemInHand(handIn); + ISpellCaster thisCaster = CasterUtil.getCaster(stack); + if (!(heldStack.getItem() instanceof SpellBook) && !(heldStack.getItem() instanceof SpellParchment)) { + return false; + } else { + Spell spell = new Spell(); + if (heldStack.getItem() instanceof ICasterTool) { + ISpellCaster heldCaster = CasterUtil.getCaster(heldStack); + spell = heldCaster.getSpell(); + thisCaster.setColor(heldCaster.getColor()); + thisCaster.setFlavorText(heldCaster.getFlavorText()); + thisCaster.setSpellName(heldCaster.getSpellName()); + } + + if (this.isScribedSpellValid(thisCaster, player, handIn, stack, spell)) { + boolean success = this.setSpell(thisCaster, player, handIn, stack, spell); + if (success) { + this.sendSetMessage(player); + return true; + } + } else { + this.sendInvalidMessage(player); + } + + return false; + } + } + + @Override + public boolean doesSneakBypassUse(ItemStack stack, LevelReader world, BlockPos pos, Player player) { + return true; + } + + @Override + public boolean shouldDisplay(ItemStack stack) { + return false; + } + + @Override + public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip2, TooltipFlag flagIn) { + ISpellCaster copyPasteSpellcaster = this.getSpellCaster(stack); + tooltip2.add(new TextComponent("Inscribed Spell: " + copyPasteSpellcaster.getSpellName())); + tooltip2.add(new TextComponent(copyPasteSpellcaster.getSpell().getDisplayString())); + super.appendHoverText(stack, worldIn, tooltip2, flagIn); + } +} diff --git a/src/main/java/de/sarenor/arsinstrumentum/setup/Registration.java b/src/main/java/de/sarenor/arsinstrumentum/setup/Registration.java index bf80a0a..5703d31 100644 --- a/src/main/java/de/sarenor/arsinstrumentum/setup/Registration.java +++ b/src/main/java/de/sarenor/arsinstrumentum/setup/Registration.java @@ -2,6 +2,7 @@ import com.hollingsworth.arsnouveau.ArsNouveau; import de.sarenor.arsinstrumentum.ArsInstrumentum; +import de.sarenor.arsinstrumentum.items.CopyPasteSpellScroll; import de.sarenor.arsinstrumentum.items.RunicStorageStone; import de.sarenor.arsinstrumentum.items.ScrollOfSaveStarbuncle; import de.sarenor.arsinstrumentum.items.curios.armarium.WizardsArmarium; @@ -20,6 +21,7 @@ public class Registration { public static final RegistryObject WIZARDS_ARMARIUM = ITEMS.register(WizardsArmarium.WIZARDS_ARMARIUM_ID, WizardsArmarium::new); public static final RegistryObject SCROLL_OF_SAVE_STARBUNCLE = ITEMS.register(ScrollOfSaveStarbuncle.SCROLL_OF_SAVE_STARBUNCLE_ID, ScrollOfSaveStarbuncle::new); public static final RegistryObject RUNIC_STORAGE_STONE = ITEMS.register(RunicStorageStone.RUNIC_STORAGE_STONE_ID, RunicStorageStone::new); + public static final RegistryObject COPY_PASTE_SPELL_SCROLL = ITEMS.register(CopyPasteSpellScroll.COPY_PASTE_SPELL_SCROLL, CopyPasteSpellScroll::new); public static final RegistryObject FAKE_WILDEN_TRIBUTE = ITEMS.register(FAKE_WILDEN_TRIBUTE_ID, () -> new Item(new Item.Properties().tab(ArsNouveau.itemGroup))); public static void init(IEventBus bus) { diff --git a/src/main/resources/assets/ars_instrumentum/textures/items/copy_paste_spell_scroll.png b/src/main/resources/assets/ars_instrumentum/textures/items/copy_paste_spell_scroll.png new file mode 100644 index 0000000000000000000000000000000000000000..6d58d0769df29d1717e5c7fdc5ee0260dfeea099 GIT binary patch literal 795 zcmV+$1LXXPP)Px%)k#D_R9Hu2WEfz;IKcKZ;B>(D`I-MIahzx3bhz1yii%jxx_|#ZBTXFuvv}F! z#SBrgu?!%(y{n7i^5x46Aj?4>#Bc!2=eouY-~jmZ=NFh}Vq%5{2)dSkVDaC-eu8Os z4sI}Q>tBIlAvVit<^WFSo5rsyf`Ezv`xYEpFh9B^vkw1FfCd!jlnav2gQTi78Wsl{`>(f_VyJdZJ|2^ zBO8+IfViuWsM@}`1Wf<`2g#l!I{-b7V0>62g{6h3jR{~Wo6QhE+&VTLOuuT+0MjC6 zQ=lOQDMy|>yhB_FkmG`LZr)lGg#iM z;})2{eDNHZjw)P=6759ShOj6gm?01F9pNBH+W z0t@~A^@BQTV9+>V#s1G=A9a?vg6V(%{(@;ldjS#_uyzD2WGK!Bun?fT17H>_D5-!w z!^_JDrqSC2?Zu8@@yg!)V7fWq7EC|52Ppy3^FJ(P2$lnb#sMm78d!b!@!c!*41kwU zur@^34GVz*bHKXkN#OQ@kcb%AZOqJ&*728*@4z&y&4})BSc?hPf?{Tdl$6&l9s|>` zkRX@_2HXKKpTQi$$-xd5l97kx3Uu)O`!}rOcW&Llni~j)z@TveNlBdq#YBey31*U{ Z6adl1^DtL*zR3Up002ovPDHLkV1hV1ZHNE> literal 0 HcmV?d00001 diff --git a/src/main/resources/data/ars_instrumentum/patchouli_books/wizards_scratchpad/en_us/entries/categories/equipment/copy_paste_spell_scroll.json b/src/main/resources/data/ars_instrumentum/patchouli_books/wizards_scratchpad/en_us/entries/categories/equipment/copy_paste_spell_scroll.json new file mode 100644 index 0000000..9007c49 --- /dev/null +++ b/src/main/resources/data/ars_instrumentum/patchouli_books/wizards_scratchpad/en_us/entries/categories/equipment/copy_paste_spell_scroll.json @@ -0,0 +1,15 @@ +{ + "name": "Scroll of Spelltransfer", + "category": "ars_nouveau:equipment", + "icon": "ars_instrumentum:copy_paste_spell_scroll", + "pages": [ + { + "text": "The Scroll of Spelltransfer can be inscribed on the Scribe's Table and will hold one spell. Shift-Rightclicking while holding the Scroll of Spelltransfer in your main hand and a spellbook in the offhand will apply the inscribed spell to the currently selected spellslot of the book.", + "type": "patchouli:text" + }, + { + "type": "patchouli:crafting", + "recipe": "ars_instrumentum:copy_paste_spell_scroll" + } + ] +} \ No newline at end of file