Skip to content

Commit

Permalink
Prevent (x)bow crafting with invalid materials crash #1261
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Dec 26, 2014
1 parent 7eadf0d commit f3ba95b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/tconstruct/weaponry/WeaponryHandler.java
Expand Up @@ -163,6 +163,13 @@ public void onProjectileWeaponCrafted(ToolCraftEvent.NormalTool event)
bottom = TConstructRegistry.getBowMaterial(tags.getInteger("Accessory"));
string = (BowstringMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Handle"), BowstringMaterial.class);

// some materials seem to be incompatible
if(top == null || bottom == null || string == null)
{
event.setResult(Event.Result.DENY);
return;
}

drawSpeed = (int) ((top.drawspeed + bottom.drawspeed) / 2f * string.drawspeedModifier);
flightSpeed = (top.flightSpeedMax + bottom.flightSpeedMax)/2 * string.flightSpeedModifier;

Expand All @@ -184,6 +191,13 @@ else if(event.tool instanceof Crossbow)
top = TConstructRegistry.getBowMaterial(tags.getInteger("Head"));
string = (BowstringMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), BowstringMaterial.class);

// some materials seem to be incompatible
if(top == null || string == null)
{
event.setResult(Event.Result.DENY);
return;
}

drawSpeed = (int) ((float)top.drawspeed * string.drawspeedModifier);
flightSpeed = (top.flightSpeedMax * string.flightSpeedModifier);

Expand Down

0 comments on commit f3ba95b

Please sign in to comment.