Prevent (x)bow crafting with invalid materials crash #1261

This commit is contained in:
Bernhard Bonigl committed 2014-12-26 09:12:18 +01:00
1 parent 7eadf0df54
commit f3ba95bbea
1 file changed
+14
@@ -163,6 +163,13 @@ public class WeaponryHandler {
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;
@@ -184,6 +191,13 @@ public class WeaponryHandler {
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);