Some additional checks to prevent crashes for invalid/incomplete arrow entities #1262

This commit is contained in:
Bernhard Bonigl committed 2014-12-26 11:06:00 +01:00
1 parent 161c292462
commit 384fe28be9
1 file changed
+6
@@ -39,6 +39,9 @@ public class ArrowEntity extends ProjectileBase {
@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 class ArrowEntity extends ProjectileBase {
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()) {