diff options
author | Linnea Gräf <nea@nea.moe> | 2024-02-29 09:54:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 09:54:54 +0100 |
commit | 191bf59f649e7bbbb55ee66d084429de1fdcc9e4 (patch) | |
tree | b8ab2b4324befb9d88cd9304a5a907b71deff890 /src/main/java | |
parent | 03c397d77f5f84e3c054b42ccd6a0b76331fa557 (diff) | |
download | NotEnoughUpdates-191bf59f649e7bbbb55ee66d084429de1fdcc9e4.tar.gz NotEnoughUpdates-191bf59f649e7bbbb55ee66d084429de1fdcc9e4.tar.bz2 NotEnoughUpdates-191bf59f649e7bbbb55ee66d084429de1fdcc9e4.zip |
Fix rare NPE in crystal hollow chest highlighter (#1019)
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java index 7351509b..7292bb7f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/CrystalHollowChestHighlighter.java @@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.SpecialColour; +import lombok.val; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -62,13 +63,16 @@ public class CrystalHollowChestHighlighter extends GenericBlockHighlighter { } public static void checkForChest(BlockPos pos, IBlockState blockState) { - IBlockState oldState = Minecraft.getMinecraft().theWorld.getBlockState(pos); + val world = Minecraft.getMinecraft().theWorld; + val player = Minecraft.getMinecraft().thePlayer; + if (world == null || player == null) return; + IBlockState oldState = world.getBlockState(pos); if ((oldState.getBlock() == Blocks.air || oldState.getBlock() == Blocks.stone) && blockState.getBlock() == Blocks.chest) { // Only add if in a 10x10x10 area. Minimises other players' chests being caught - if (Minecraft.getMinecraft().thePlayer.getEntityBoundingBox().expand(10, 10, 10).isVecInside(new Vec3(pos))) { + if (player.getEntityBoundingBox().expand(10, 10, 10).isVecInside(new Vec3(pos))) { markedBlocks.add(pos); } } |