Skip to content

Commit

Permalink
Added Scroll of Spelltransfer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarenor committed Mar 5, 2022
1 parent 77be443 commit 103242d
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/de/sarenor/arsinstrumentum/datagen/Recipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,12 @@ protected void buildCraftingRecipes(Consumer<FinishedRecipe> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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<ItemStack> 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<Component> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +21,7 @@ public class Registration {
public static final RegistryObject<Item> WIZARDS_ARMARIUM = ITEMS.register(WizardsArmarium.WIZARDS_ARMARIUM_ID, WizardsArmarium::new);
public static final RegistryObject<Item> SCROLL_OF_SAVE_STARBUNCLE = ITEMS.register(ScrollOfSaveStarbuncle.SCROLL_OF_SAVE_STARBUNCLE_ID, ScrollOfSaveStarbuncle::new);
public static final RegistryObject<Item> RUNIC_STORAGE_STONE = ITEMS.register(RunicStorageStone.RUNIC_STORAGE_STONE_ID, RunicStorageStone::new);
public static final RegistryObject<Item> COPY_PASTE_SPELL_SCROLL = ITEMS.register(CopyPasteSpellScroll.COPY_PASTE_SPELL_SCROLL, CopyPasteSpellScroll::new);
public static final RegistryObject<Item> FAKE_WILDEN_TRIBUTE = ITEMS.register(FAKE_WILDEN_TRIBUTE_ID, () -> new Item(new Item.Properties().tab(ArsNouveau.itemGroup)));

public static void init(IEventBus bus) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit 103242d

Please sign in to comment.