Skip to content

Commit

Permalink
Prevent ammo creation when missing information through old 3rd party …
Browse files Browse the repository at this point in the history
…materials is encountered instead of crashing #1236
  • Loading branch information
bonii-xx committed Dec 21, 2014
1 parent 782d1e5 commit 139b1fb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/tconstruct/weaponry/WeaponryHandler.java
@@ -1,5 +1,6 @@
package tconstruct.weaponry;

import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import tconstruct.armor.player.TPlayerStats;
import tconstruct.tools.TinkerTools;
Expand Down Expand Up @@ -74,6 +75,13 @@ public void onAmmoCrafted(ToolCraftEvent.NormalTool event)
if(fletching == null)
fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchlingLeafMaterial.class);

// invalid materials
if(arrow == null || shaft == null || fletching == null)
{
event.setResult(Event.Result.DENY);
return;
}

int durability = (int)((float)head.durability() * shaft.durabilityModifier * fletching.durabilityModifier);
float weight = arrow.mass + shaft.weight;
float accuracy = fletching.accuracy;
Expand Down Expand Up @@ -106,6 +114,13 @@ else if(event.tool instanceof BoltAmmo)
if(fletching == null)
fletching = (FletchingMaterial) TConstructRegistry.getCustomMaterial(tags.getInteger("Accessory"), FletchlingLeafMaterial.class);

// invalid materials
if(head == null || core == null || fletching == null)
{
event.setResult(Event.Result.DENY);
return;
}

int durability = (int)((float)headMat.durability() * coreMat.handleDurability() * fletching.durabilityModifier);
float weight = head.mass + core.mass*1.5f;
float accuracy = (100f + fletching.accuracy)/2f;
Expand Down

0 comments on commit 139b1fb

Please sign in to comment.