Fixed more building desync
This commit is contained in:
@@ -431,6 +431,7 @@ public class NetServer extends Module{
|
||||
while(remaining > 0){
|
||||
int used = Math.min(remaining, maxSnapshotSize);
|
||||
byte[] toSend;
|
||||
//re-use sent byte arrays when possible
|
||||
if(used == maxSnapshotSize){
|
||||
toSend = reusableSnapArray;
|
||||
System.arraycopy(bytes, offset, toSend, 0, Math.min(offset + maxSnapshotSize, bytes.length) - offset);
|
||||
|
||||
@@ -613,7 +613,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
if(lastShooting != isShooting){
|
||||
CallEntity.setShooting(isShooting);
|
||||
}
|
||||
}else if(isShooting()){ //desktop shooting, TODO
|
||||
}else if(isShooting()){
|
||||
Vector2 vec = Graphics.world(Vars.control.input(playerIndex).getMouseX(),
|
||||
Vars.control.input(playerIndex).getMouseY());
|
||||
pointerX = vec.x;
|
||||
|
||||
@@ -22,7 +22,6 @@ public class DefaultKeybinds {
|
||||
"select", Input.MOUSE_LEFT,
|
||||
"break", Input.MOUSE_RIGHT,
|
||||
"shoot", Input.MOUSE_LEFT,
|
||||
"rotate_alt", new Axis(Input.R, Input.E),
|
||||
"rotate", new Axis(Input.SCROLL),
|
||||
"dash", Input.SHIFT_LEFT,
|
||||
"drop_unit", Input.SHIFT_LEFT,
|
||||
|
||||
@@ -102,7 +102,7 @@ public class Build {
|
||||
Block previous = tile.block();
|
||||
|
||||
//remote players only
|
||||
if(!player.isLocal){
|
||||
if(player != null && !player.isLocal){
|
||||
player.getPlaceQueue().clear();
|
||||
player.getPlaceQueue().addFirst(new BuildRequest(x, y, rotation, recipe));
|
||||
}
|
||||
|
||||
@@ -55,8 +55,7 @@ public class BreakBlock extends Block {
|
||||
|
||||
@Override
|
||||
public void tapped(Tile tile, Player player) {
|
||||
player.clearBuilding();
|
||||
player.addBuildRequest(new BuildRequest(tile.x, tile.y));
|
||||
CallBlocks.onBreakSelect(player, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,6 +146,14 @@ public class BreakBlock extends Block {
|
||||
world.removeBlock(tile);
|
||||
}
|
||||
|
||||
@Remote(called = Loc.both, targets = Loc.both, in = In.blocks, forward = true)
|
||||
public static void onBreakSelect(Player player, Tile tile){
|
||||
if(player == null || !(tile.entity instanceof BreakEntity)) return;
|
||||
|
||||
player.getPlaceQueue().clear();
|
||||
player.addBuildRequest(new BuildRequest(tile.x, tile.y));
|
||||
}
|
||||
|
||||
public class BreakEntity extends TileEntity{
|
||||
private double[] accumulator;
|
||||
|
||||
|
||||
@@ -165,13 +165,13 @@ public class BuildBlock extends Block {
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, targets = Loc.both, in = In.blocks, forward = true)
|
||||
@Remote(called = Loc.both, targets = Loc.both, in = In.blocks, forward = true)
|
||||
public static void onBuildSelect(Player player, Tile tile){
|
||||
if(player == null || !(tile.entity instanceof BuildEntity)) return;
|
||||
|
||||
BuildEntity entity = tile.entity();
|
||||
|
||||
player.clearBuilding();
|
||||
player.getPlaceQueue().clear();
|
||||
player.addBuildRequest(new BuildRequest(tile.x, tile.y, tile.getRotation(), entity.recipe));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user