Synch powerAverage on laser entities. Partial fix for #263

This commit is contained in:
SirSengir 2012-09-14 18:24:20 +02:00
parent 0fa5a9d38e
commit 92195e8613
2 changed files with 27 additions and 2 deletions

View file

@ -56,4 +56,29 @@ public class EntityEnergyLaser extends EntityLaser {
else
return DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_4.png";
}
@Override
protected void updateData() {
super.updateData();
powerAverage = (float)decodeDouble(dataWatcher.getWatchableObjectInt(15));
}
@Override
public void setPositions(Position head, Position tail) {
super.setPositions(head, tail);
dataWatcher.updateObject(15, Integer.valueOf(encodeDouble((double)powerAverage)));
}
@Override
protected void initClientSide() {
super.initClientSide();
dataWatcher.addObject(15, Integer.valueOf(0));
}
@Override
protected void initServerSide() {
super.initServerSide();
dataWatcher.addObject(15, encodeDouble((double)powerAverage));
}
}

View file

@ -160,11 +160,11 @@ public class EntityLaser extends Entity {
return texture;
}
private int encodeDouble(double d) {
protected int encodeDouble(double d) {
return (int) (d * 8000);
}
private double decodeDouble(int i) {
protected double decodeDouble(int i) {
return (i / 8000D);
}