Fixed some multiplayer crashes

This commit is contained in:
Anuken
2018-07-10 21:04:14 -04:00
parent bba418c79d
commit bce0101278
8 changed files with 13 additions and 15 deletions
@@ -473,7 +473,9 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
updateMech();
}
avoidOthers(8f);
if(isLocal) {
avoidOthers(8f);
}
if(!isShooting()) {
updateBuilding(this);
@@ -199,7 +199,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
}
public void avoidOthers(float avoidRange){
if(Net.client()) return;
EntityPhysics.getNearby(getGroup(), x, y, avoidRange*2f, t -> {
if(t == this || (t instanceof Unit && (((Unit) t).isDead() || (((Unit) t).isFlying() != isFlying()) || ((Unit) t).getCarrier() == this) || getCarrier() == t)) return;
@@ -41,6 +41,7 @@ public interface CarryTrait extends TeamTrait, SolidTrait, TargetTrait{
@Remote(called = Loc.both, targets = Loc.both, forward = true, in = In.entities)
static void setCarryOf(Player player, CarryTrait trait, CarriableTrait unit){
if(trait == null) return;
if(player != null){ //when a server recieves this called from a player, set the carrier to the player.
trait = player;
}
@@ -283,7 +283,9 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
return;
}
avoidOthers(8f);
if(!Net.client()){
avoidOthers(8f);
}
if(squad != null){
squad.update();