mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Spells can now request an update by setting themselves as dirty on the server
This commit is contained in:
parent
96cbffef02
commit
2895e5881c
3 changed files with 25 additions and 2 deletions
|
@ -42,11 +42,12 @@ public class EffectSync<T extends EntityLivingBase> {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue