Fixed crash / Made power nodes no longer link when adjacent

This commit is contained in:
Anuken
2018-10-26 09:54:55 -04:00
parent 6c076863db
commit 0cc59adad7
2 changed files with 12 additions and 13 deletions

View File

@@ -9,9 +9,10 @@ import io.anuke.ucore.core.Effects;
import io.anuke.ucore.entities.trait.SolidTrait;
public interface CarryTrait extends TeamTrait, SolidTrait, TargetTrait{
@Remote(called = Loc.both, targets = Loc.both, forward = true)
static void dropSelf(Player player){
if(player.getCarrier() != null){
if(player != null && player.getCarrier() != null){
player.getCarrier().dropCarry();
}
}
@@ -40,24 +41,16 @@ public interface CarryTrait extends TeamTrait, SolidTrait, TargetTrait{
}
}
/**
* Returns the thing this carrier is carrying.
*/
/**Returns the thing this carrier is carrying.*/
CarriableTrait getCarry();
/**
* Sets the carrying unit. Internal use only! Use {@link #carry(CarriableTrait)} to set state.
*/
/**Sets the carrying unit. Internal use only! Use {@link #carry(CarriableTrait)} to set state.*/
void setCarry(CarriableTrait unit);
/**
* Returns maximum mass this carrier can carry.
*/
/**Returns maximum mass this carrier can carry.*/
float getCarryWeight();
/**
* Drops the unit that is being carried, if applicable.
*/
/**Drops the unit that is being carried, if applicable.*/
default void dropCarry(){
carry(null);
}

View File

@@ -99,6 +99,12 @@ public class PowerNode extends PowerBlock{
public void playerPlaced(Tile tile){
Tile before = world.tile(lastPlaced);
if(linkValid(tile, before) && before.block() instanceof PowerNode){
for(Tile near : before.entity.proximity()){
if(near.target() == tile){
lastPlaced = tile.packedPosition();
return;
}
}
Call.linkPowerNodes(null, tile, before);
}