From 58e972166ecb43ec96717cd0a346548cdbc5367c Mon Sep 17 00:00:00 2001 From: ceg Date: Sun, 25 Aug 2024 16:57:44 -0400 Subject: Fix crash when trying to break AE2 cables with a GT wrench (#2958) * Account for edge case when Platform.rayTrace returns a null value. * Account for edge case when Platform.rayTrace returns a null value. --------- Co-authored-by: Martin Robertz --- src/main/java/gregtech/common/tools/GT_Tool_Wrench.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/gregtech/common/tools/GT_Tool_Wrench.java b/src/main/java/gregtech/common/tools/GT_Tool_Wrench.java index 4dad749997..ae9f705b62 100644 --- a/src/main/java/gregtech/common/tools/GT_Tool_Wrench.java +++ b/src/main/java/gregtech/common/tools/GT_Tool_Wrench.java @@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.event.world.BlockEvent; @@ -211,7 +212,14 @@ public class GT_Tool_Wrench extends GT_Tool { try { LastEventFromThis = true; player.setSneaking(true); - final int sideHit = Platform.rayTrace(player, true, false).sideHit; + + final MovingObjectPosition movObjPosition = Platform.rayTrace(player, true, false); + if (movObjPosition == null) { + event.setCanceled(true); + return; + } + + final int sideHit = movObjPosition.sideHit; if (tile instanceof IPartHost) { if (sneak && PartPlacement.place( player.getHeldItem(), -- cgit