From 384fe28be90f146e00dfb29a1789cd6a0c503da9 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Fri, 26 Dec 2014 11:06:00 +0100 Subject: [PATCH] Some additional checks to prevent crashes for invalid/incomplete arrow entities #1262 --- src/main/java/tconstruct/weaponry/entity/ArrowEntity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/tconstruct/weaponry/entity/ArrowEntity.java b/src/main/java/tconstruct/weaponry/entity/ArrowEntity.java index 8513ef954e4..82ed65c1f89 100644 --- a/src/main/java/tconstruct/weaponry/entity/ArrowEntity.java +++ b/src/main/java/tconstruct/weaponry/entity/ArrowEntity.java @@ -39,6 +39,9 @@ protected double getSlowdown() { @Override protected double getGravity() { + if(returnStack == null || !returnStack.hasTagCompound()) + return super.getGravity(); + float mass = returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("Mass"); mass /= 36f; // why 36? simple because it's roughly 0.05 with flint head and wooden arrow shaft! Yes, that's the only reason. return mass; @@ -51,6 +54,9 @@ public void onHitBlock(MovingObjectPosition movingobjectposition) { if(defused) return; + if(returnStack == null || !returnStack.hasTagCompound()) + return; + // we might break! oh noez! float chance = returnStack.getTagCompound().getCompoundTag("InfiTool").getFloat("BreakChance"); if(chance > TConstruct.random.nextFloat()) {