Skip to content

Commit

Permalink
Surface Detonator crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Slotterleet committed May 4, 2024
1 parent 40c5f82 commit 9aa9a5b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fos/type/blocks/special/SurfaceExplosive.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public Block deepFloor() {
public void detonate() {
// pre-detonation init
tileOn().circle(range, t -> {
if (t == null) return;

tiles.add(t);
if (t.floor() != deepFloor())
t.setBlock(stoneWall);
Expand Down Expand Up @@ -136,7 +138,7 @@ public void detonate() {
} else {
for (int i = 0; i < 8; i++) {
Tile other = world.tiles.get(tile.x + Geometry.d8[i].x, tile.y + Geometry.d8[i].y);
if (other.block() == cliff) {
if (other != null && other.block() == cliff) {
tile.data -= (byte) (1 << i);
}
}
Expand All @@ -145,7 +147,7 @@ public void detonate() {
// liquid nearby? well then, more liquid, my friend
for (Point2 p : Geometry.d4) {
Tile other = world.tiles.get(tile.x + p.x, tile.y + p.y);
if (other.floor().liquidDrop != null) {
if (other != null && other.floor().liquidDrop != null) {
l = other.floor().liquidDrop;
break;
}
Expand All @@ -161,7 +163,7 @@ public void detonate() {
boolean valid = false;
for (Point2 p : Geometry.d4) {
Tile other = world.tiles.get(tile.x + p.x, tile.y + p.y);
if (other.floor() != deepFloor()) valid = true;
if (other != null && other.floor() != deepFloor()) valid = true;
}
if (!valid && tile.block() == cliff) {
tile.setBlock(air);
Expand Down

0 comments on commit 9aa9a5b

Please sign in to comment.