From 0c5a92bdae3f5cb9cd38aa622dec120589f7934f Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 3 Mar 2019 23:52:02 +0200 Subject: [PATCH] Players holding the gem of light will also emit light! --- .../unicopia/spell/SpellLight.java | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/spell/SpellLight.java b/src/main/java/com/minelittlepony/unicopia/spell/SpellLight.java index ebcb8131..72cef031 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/SpellLight.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/SpellLight.java @@ -1,15 +1,13 @@ package com.minelittlepony.unicopia.spell; -import com.minelittlepony.util.PosHelper; +import com.minelittlepony.unicopia.player.IPlayer; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumFacing; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.World; -public class SpellLight extends GenericSpell { +public class SpellLight extends GenericSpell implements IHeldEffect { private BlockPos lastPos; private ICaster source; @@ -32,6 +30,13 @@ public class SpellLight extends GenericSpell { } } + @Override + public void updateInHand(IPlayer caster, SpellAffinity affinity) { + if (caster.getPlayerSpecies().canCast()) { + update(caster); + } + } + @Override public boolean update(ICaster source) { this.source = source; @@ -58,7 +63,25 @@ public class SpellLight extends GenericSpell { return true; } - protected void resetLight(BlockPos pos) { + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + if (compound.hasKey("lastX")) { + lastPos = new BlockPos(compound.getInteger("lastX"), compound.getInteger("lastY"), compound.getInteger("lastZ")); + } else { + lastPos = null; + } + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + + if (lastPos != null) { + compound.setInteger("lastX", lastPos.getX()); + compound.setInteger("lastY", lastPos.getY()); + compound.setInteger("lastZ", lastPos.getZ()); + } } }