diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 602d6f748b..ed24d8053c 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -82,14 +82,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra //region unit and event overrides, utility methods - @Remote(targets = Loc.server, called = Loc.server) - public static void onPlayerDamage(Player player, float amount){ - if(player == null) return; - - player.hitTime = hitDuration; - player.health -= amount; - } - @Remote(targets = Loc.server, called = Loc.server) public static void onPlayerDeath(Player player){ if(player == null) return; @@ -227,7 +219,10 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra @Override public void damage(float amount){ - Call.onPlayerDamage(this, calculateDamage(amount)); + hitTime = hitDuration; + if(!Net.client()){ + health -= amount; + } if(health <= 0 && !dead){ Call.onPlayerDeath(this); diff --git a/core/src/io/anuke/mindustry/net/NetworkIO.java b/core/src/io/anuke/mindustry/net/NetworkIO.java index 208d6c836f..0fbab76305 100644 --- a/core/src/io/anuke/mindustry/net/NetworkIO.java +++ b/core/src/io/anuke/mindustry/net/NetworkIO.java @@ -185,7 +185,6 @@ public class NetworkIO{ int height = stream.readShort(); //TODO send advanced map meta such as author, etc - //TODO scan for cores Map currentMap = new Map(map, new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null); currentMap.meta.tags.clear(); currentMap.meta.tags.putAll(tags); diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index ab0adf26e1..579dff792f 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.net; +import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Base64Coder; import com.badlogic.gdx.utils.TimeUtils; import io.anuke.mindustry.Vars; @@ -155,7 +156,7 @@ public class Packets{ public float x, y, pointerX, pointerY, rotation, baseRotation, xv, yv; public Tile mining; public boolean boosting, shooting; - public BuildRequest currentRequest; + public Array requests = new Array<>(); @Override public void write(ByteBuffer buffer){ @@ -180,17 +181,14 @@ public class Packets{ buffer.putInt(player.getMineTile() == null ? -1 : player.getMineTile().packedPosition()); - BuildRequest request = player.getCurrentRequest(); - - if(request != null){ + buffer.putShort((short)player.getPlaceQueue().size); + for(BuildRequest request : player.getPlaceQueue()){ buffer.put(request.remove ? (byte) 1 : 0); buffer.putInt(world.toPacked(request.x, request.y)); if(!request.remove){ buffer.put((byte) request.recipe.id); buffer.put((byte) request.rotation); } - }else{ - buffer.put((byte) -1); } } @@ -211,10 +209,13 @@ public class Packets{ rotation = buffer.getShort() / 2f; baseRotation = buffer.getShort() / 2f; mining = world.tile(buffer.getInt()); + requests.clear(); - byte type = buffer.get(); - if(type != -1){ + short reqamount = buffer.getShort(); + for(int i = 0; i < reqamount; i++){ + byte type = buffer.get(); int position = buffer.getInt(); + BuildRequest currentRequest; if(type == 1){ //remove currentRequest = new BuildRequest(position % world.width(), position / world.width()); @@ -223,8 +224,8 @@ public class Packets{ byte rotation = buffer.get(); currentRequest = new BuildRequest(position % world.width(), position / world.width(), rotation, Recipe.getByID(recipe)); } - }else{ - currentRequest = null; + + requests.add(currentRequest); } } }