From 923e39f3c1d739cf86fa98d179e6521ade71bdec Mon Sep 17 00:00:00 2001 From: Eryk Ruta <70776766+kingstefan26@users.noreply.github.com> Date: Fri, 4 Nov 2022 15:03:46 +0100 Subject: fix null pointer when opening mimic chest (#72) --- .../dungeonsguide/dungeon/mechanics/DungeonSecret.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java index d806b7c5..48ec30f6 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -58,10 +58,14 @@ public class DungeonSecret implements DungeonMechanic { IBlockState blockState = DungeonsGuide.getDungeonsGuide().getBlockCache().getBlockState(pos); if (blockState.getBlock() == Blocks.chest || blockState.getBlock() == Blocks.trapped_chest) { TileEntityChest chest = (TileEntityChest) dungeonRoom.getContext().getWorld().getTileEntity(pos); - if (chest.numPlayersUsing > 0) { - dungeonRoom.getRoomContext().put("c-" + pos.toString(), 2); + if(chest != null){ + if (chest.numPlayersUsing > 0) { + dungeonRoom.getRoomContext().put("c-" + pos.toString(), 2); + } else { + dungeonRoom.getRoomContext().put("c-" + pos.toString(), 1); + } } else { - dungeonRoom.getRoomContext().put("c-" + pos.toString(), 1); + System.out.println("Expected TileEntityChest at " + pos + " to not be null"); } } } else if (secretType == SecretType.ESSENCE) { -- cgit