Various crashes fixed
This commit is contained in:
@@ -202,6 +202,11 @@ public interface BuilderTrait extends Entity{
|
||||
//otherwise, update it.
|
||||
BuildEntity entity = tile.entity();
|
||||
|
||||
if(entity == null){
|
||||
getPlaceQueue().removeFirst();
|
||||
return;
|
||||
}
|
||||
|
||||
//deconstructing is 2x as fast
|
||||
if(current.remove){
|
||||
entity.deconstruct(unit, core, 2f / entity.buildCost * Timers.delta() * getBuildPower(tile));
|
||||
|
||||
@@ -429,7 +429,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
||||
@Override
|
||||
public void write(DataOutput data) throws IOException{
|
||||
super.write(data);
|
||||
data.writeInt(mineTile == null ? -1 : mineTile.packedPosition());
|
||||
data.writeInt(mineTile == null || !state.is(mine) ? -1 : mineTile.packedPosition());
|
||||
data.writeInt(state.is(repair) && target instanceof TileEntity ? ((TileEntity)target).tile.packedPosition() : -1);
|
||||
writeBuilding(data);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class FortressGenerator{
|
||||
int maxIndex = (int)(1 + ((float)gen.sector.difficulty / maxDifficulty * (structures.length-2)));
|
||||
|
||||
for(int i = maxIndex/2; i < maxIndex; i++){
|
||||
selected.add(structures[i]);
|
||||
selected.add(structures[Math.min(i, structures.length-1)]);
|
||||
}
|
||||
|
||||
float baseChance = 0.8f / selected.size;
|
||||
|
||||
@@ -242,7 +242,7 @@ public class WorldGenerator{
|
||||
int x = sectorX * sectorSize + localX + Short.MAX_VALUE;
|
||||
int y = sectorY * sectorSize + localY + Short.MAX_VALUE;
|
||||
|
||||
Block floor;
|
||||
Block floor = Blocks.stone;
|
||||
Block wall = Blocks.air;
|
||||
|
||||
double ridge = rid.getValue(x, y, 1f / 400f);
|
||||
@@ -283,7 +283,7 @@ public class WorldGenerator{
|
||||
if(iceridge > 0.25 && minDst > lerpDst/1.5f){
|
||||
elevation ++;
|
||||
}
|
||||
}else{
|
||||
}else if(minDst > lerpDst/1.5f){
|
||||
floor = Blocks.lava;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,8 +96,6 @@ public class ContentDisplay{
|
||||
table.row();
|
||||
table.add(Bundles.format("text.item.fluxiness", (int) (item.fluxiness * 100)));
|
||||
table.row();
|
||||
table.add(Bundles.format("text.item.hardness", item.hardness));
|
||||
table.row();
|
||||
}
|
||||
|
||||
public static void displayLiquid(Table table, Liquid liquid){
|
||||
|
||||
@@ -89,7 +89,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
table.background("inventory");
|
||||
table.setTouchable(Touchable.enabled);
|
||||
table.update(() -> {
|
||||
if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.total() == 0){
|
||||
if(state.is(State.menu) || tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.total() == 0){
|
||||
hide();
|
||||
}else{
|
||||
if(holding && lastItem != null){
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Conveyor extends Block{
|
||||
byte rotation = tile.getRotation();
|
||||
|
||||
int frame = entity.clogHeat <= 0.5f ? (int) ((Timers.time() / 4f) % 4) : 0;
|
||||
Draw.rect(regions[entity.blendbits][frame], tile.drawx(), tile.drawy(),
|
||||
Draw.rect(regions[Mathf.clamp(entity.blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], tile.drawx(), tile.drawy(),
|
||||
tilesize * entity.blendsclx, tilesize * entity.blendscly, rotation*90);
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ public class MassDriver extends Block{
|
||||
|
||||
protected boolean linkValid(Tile tile){
|
||||
MassDriverEntity entity = tile.entity();
|
||||
if(entity.link == -1) return false;
|
||||
if(entity == null || entity.link == -1) return false;
|
||||
Tile link = world.tile(entity.link);
|
||||
|
||||
return link != null && link.block() instanceof MassDriver && tile.distanceTo(link) <= range;
|
||||
|
||||
@@ -234,6 +234,7 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
protected boolean isValid(Tile tile){
|
||||
if(tile == null) return false;
|
||||
ItemStack drops = tile.floor().drops;
|
||||
return drops != null && drops.item.hardness <= tier;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ public class SolidPump extends Pump{
|
||||
|
||||
@Override
|
||||
protected boolean isValid(Tile tile){
|
||||
if(tile == null) return false;
|
||||
return !tile.floor().isLiquid;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ConsumeItem extends Consume{
|
||||
|
||||
@Override
|
||||
public boolean valid(Block block, TileEntity entity){
|
||||
return entity.items.has(item, amount);
|
||||
return entity != null && entity.items != null && entity.items.has(item, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user