Players holding the gem of light will also emit light!

This commit is contained in:
Sollace 2019-03-03 23:52:02 +02:00
parent 74f02b045c
commit 0c5a92bdae

View file

@ -1,15 +1,13 @@
package com.minelittlepony.unicopia.spell; package com.minelittlepony.unicopia.spell;
import com.minelittlepony.util.PosHelper; import com.minelittlepony.unicopia.player.IPlayer;
import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World; import net.minecraft.world.World;
public class SpellLight extends GenericSpell { public class SpellLight extends GenericSpell implements IHeldEffect {
private BlockPos lastPos; private BlockPos lastPos;
private ICaster<?> source; 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 @Override
public boolean update(ICaster<?> source) { public boolean update(ICaster<?> source) {
this.source = source; this.source = source;
@ -58,7 +63,25 @@ public class SpellLight extends GenericSpell {
return true; 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());
}
} }
} }