From f89c71f3145ea38e8b138acea7ac5b265a67ae39 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Tue, 21 Apr 2020 18:55:13 +0100 Subject: [PATCH] Make spell scrolls implement IWorkbenchItem and have 1 slot This means the book doesn't leave the workbench until the scrolls are taken out, which is good for automation - however, canPlace always returns false so they can't be put back in, kinda like the furnace output --- .../electroblob/wizardry/item/ItemScroll.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/electroblob/wizardry/item/ItemScroll.java b/src/main/java/electroblob/wizardry/item/ItemScroll.java index c1947d35..6c061f5d 100644 --- a/src/main/java/electroblob/wizardry/item/ItemScroll.java +++ b/src/main/java/electroblob/wizardry/item/ItemScroll.java @@ -11,6 +11,7 @@ import electroblob.wizardry.util.SpellModifiers; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.*; @@ -22,7 +23,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemScroll extends Item implements ISpellCastingItem { +public class ItemScroll extends Item implements ISpellCastingItem, IWorkbenchItem { /** The maximum number of ticks a continuous spell scroll can be cast for (by holding the use item button). */ public static final int CASTING_TIME = 120; @@ -222,4 +223,24 @@ public class ItemScroll extends Item implements ISpellCastingItem { public net.minecraft.client.gui.FontRenderer getFontRenderer(ItemStack stack){ return Wizardry.proxy.getFontRenderer(stack); } + + @Override + public int getSpellSlotCount(ItemStack stack){ + return 1; // Stop spell books immediately leaving the workbench when a scroll is enchanted + } + + @Override + public boolean canPlace(ItemStack stack){ + return false; // Prevent players putting scrolls back in the workbench + } + + @Override + public boolean onApplyButtonPressed(EntityPlayer player, Slot centre, Slot crystals, Slot upgrade, Slot[] spellBooks){ + return false; + } + + @Override + public boolean showTooltip(ItemStack stack){ + return false; + } }