diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index ec6dc2b0fc..8d3ac0bd19 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -478,7 +478,7 @@ public class NetClient implements ApplicationListener{ Log.warn("Block ID mismatch at @: @ != @. Skipping block snapshot.", tile, tile.build.block.id, block); break; } - tile.build.readAll(Reads.get(input), tile.build.version()); + tile.build.readSync(Reads.get(input), tile.build.version()); } }catch(Exception e){ Log.err(e); diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index e6a7c75de1..5f4be71024 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -913,7 +913,7 @@ public class NetServer implements ApplicationListener{ dataStream.writeInt(entity.pos()); dataStream.writeShort(entity.block.id); - entity.writeAll(Writes.get(dataStream)); + entity.writeSync(Writes.get(dataStream)); if(syncStream.size() > maxSnapshotSize){ dataStream.close(); diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 9751fbd4c7..16a9af2fc3 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -261,6 +261,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, read(read, revision); } + public void writeSync(Writes write){ + writeAll(write); + } + + public void readSync(Reads read, byte revision){ + readAll(read, revision); + } + @CallSuper public void write(Writes write){ //overriden by subclasses! diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 0baea25f93..e9f5331bbe 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -140,6 +140,7 @@ public class Turret extends ReloadTurret{ quickRotate = false; outlinedIcon = 1; drawLiquidLight = false; + sync = true; } @Override @@ -664,6 +665,17 @@ public class Turret extends ReloadTurret{ public byte version(){ return 1; } + + @Override + public void readSync(Reads read, byte revision){ + //maintain rotation and reload when syncing so clients don't see turrets snapping around + float oldRot = rotation, oldReload = reloadCounter; + + readAll(read, revision); + + rotation = oldRot; + reloadCounter = oldReload; + } } public static class BulletEntry{