Skip to content

Commit

Permalink
Some additional checks to prevent crashes for invalid/incomplete arro…
Browse files Browse the repository at this point in the history
…w entities #1262
  • Loading branch information
bonii-xx committed Dec 26, 2014
1 parent 161c292 commit 384fe28
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/tconstruct/weaponry/entity/ArrowEntity.java
Expand Up @@ -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;
Expand All @@ -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()) {
Expand Down

0 comments on commit 384fe28

Please sign in to comment.