diff --git a/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java b/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java index f9fb62ce..e5c317f5 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java +++ b/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java @@ -42,11 +42,12 @@ public class EffectSync { if (effect == null || !effect.getName().contentEquals(id)) { if (effect != null) { effect.setDead(); - effect = null; } effect = SpellRegistry.instance().createEffectFromNBT(comp); } else if (owned.getEntity().world.isRemote) { effect.readFromNBT(comp); + } else if (effect.isDirty()) { + set(effect); } } diff --git a/src/main/java/com/minelittlepony/unicopia/spell/AbstractSpell.java b/src/main/java/com/minelittlepony/unicopia/spell/AbstractSpell.java index 57c2769e..7d55e010 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/AbstractSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/AbstractSpell.java @@ -4,7 +4,8 @@ import net.minecraft.nbt.NBTTagCompound; public abstract class AbstractSpell implements IMagicEffect { - protected boolean isDead = false; + protected boolean isDead; + protected boolean isDirty; private int strength = 0; @@ -33,6 +34,16 @@ public abstract class AbstractSpell implements IMagicEffect { return isDead; } + @Override + public boolean isDirty() { + return isDirty; + } + + @Override + public void setDirty(boolean dirty) { + isDirty = dirty; + } + @Override public void writeToNBT(NBTTagCompound compound) { compound.setBoolean("dead", isDead); @@ -41,6 +52,7 @@ public abstract class AbstractSpell implements IMagicEffect { @Override public void readFromNBT(NBTTagCompound compound) { + setDirty(false); isDead = compound.getBoolean("dead"); strength = compound.getInteger("spell_strength"); } diff --git a/src/main/java/com/minelittlepony/unicopia/spell/IMagicEffect.java b/src/main/java/com/minelittlepony/unicopia/spell/IMagicEffect.java index cad455c1..63ba9e5d 100644 --- a/src/main/java/com/minelittlepony/unicopia/spell/IMagicEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/spell/IMagicEffect.java @@ -27,6 +27,16 @@ public interface IMagicEffect extends InbtSerialisable, ILevelled, IAligned { */ boolean getDead(); + /** + * Returns true if this effect has changes that need to be sent to the client. + */ + boolean isDirty(); + + /** + * Marks this effect as dirty. + */ + void setDirty(boolean dirty); + /** * Returns true if this effect can be crafted into a gem. */