From eb1a6701de05041c25390e864ba78a24ae06e0c2 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 30 Oct 2014 22:34:56 +0100 Subject: [PATCH] Fix Projectile Weapons and arrows/bolts building creative items with materials that have no bow/arrow material stats --- src/main/java/tconstruct/library/weaponry/BowBaseAmmo.java | 5 +++++ src/main/java/tconstruct/weaponry/ammo/ArrowAmmo.java | 4 ++++ src/main/java/tconstruct/weaponry/ammo/BoltAmmo.java | 3 +++ src/main/java/tconstruct/weaponry/weapons/Crossbow.java | 5 +++++ 4 files changed, 17 insertions(+) diff --git a/src/main/java/tconstruct/library/weaponry/BowBaseAmmo.java b/src/main/java/tconstruct/library/weaponry/BowBaseAmmo.java index 9de56090..14457f25 100644 --- a/src/main/java/tconstruct/library/weaponry/BowBaseAmmo.java +++ b/src/main/java/tconstruct/library/weaponry/BowBaseAmmo.java @@ -1,6 +1,7 @@ package tconstruct.library.weaponry; import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.BowMaterial; import tconstruct.library.tools.BowstringMaterial; import tconstruct.weaponry.ammo.ArrowAmmo; import tconstruct.weaponry.entity.ArrowEntity; @@ -136,6 +137,10 @@ public abstract class BowBaseAmmo extends ProjectileWeapon { @Override public void buildTool (int id, String name, List list) { + // does the material have a bow material? + if(TConstructRegistry.getBowMaterial(id) == null) + return; + // all creative bows use regular bowstring ItemStack handleStack = new ItemStack(getHandleItem(), 1, 0); // regular bowstring ItemStack accessoryStack = getPartAmount() > 2 ? new ItemStack(getAccessoryItem(), 1, id) : null; diff --git a/src/main/java/tconstruct/weaponry/ammo/ArrowAmmo.java b/src/main/java/tconstruct/weaponry/ammo/ArrowAmmo.java index 2c8293bc..b2652a12 100644 --- a/src/main/java/tconstruct/weaponry/ammo/ArrowAmmo.java +++ b/src/main/java/tconstruct/weaponry/ammo/ArrowAmmo.java @@ -2,6 +2,7 @@ package tconstruct.weaponry.ammo; import tconstruct.TConstruct; import tconstruct.library.TConstructRegistry; +import tconstruct.library.tools.ArrowMaterial; import tconstruct.library.tools.CustomMaterial; import tconstruct.library.tools.FletchingMaterial; import tconstruct.library.tools.FletchlingLeafMaterial; @@ -97,6 +98,9 @@ public class ArrowAmmo extends AmmoItem { @Override public void buildTool (int id, String name, List list) { + if(TConstructRegistry.getArrowMaterial(id) == null) + return; + ItemStack handleStack = new ItemStack(getHandleItem(), 1, 0); // wooden shaft ItemStack accessoryStack = new ItemStack(getAccessoryItem(), 1, 0); // feather fletchling diff --git a/src/main/java/tconstruct/weaponry/ammo/BoltAmmo.java b/src/main/java/tconstruct/weaponry/ammo/BoltAmmo.java index 484f68cb..0e640f0a 100644 --- a/src/main/java/tconstruct/weaponry/ammo/BoltAmmo.java +++ b/src/main/java/tconstruct/weaponry/ammo/BoltAmmo.java @@ -82,6 +82,9 @@ public class BoltAmmo extends AmmoItem { @Override public void buildTool (int id, String name, List list) { + if(TConstructRegistry.getArrowMaterial(id) == null) + return; + // dual material head: we use wooden shafts ItemStack headStack = DualMaterialToolPart.createDualMaterial(getHeadItem(), 0, id); // wooden shaft, material head ItemStack handleStack = new ItemStack(getAccessoryItem(), 1, 0); // feather Fletchling diff --git a/src/main/java/tconstruct/weaponry/weapons/Crossbow.java b/src/main/java/tconstruct/weaponry/weapons/Crossbow.java index 11989d64..90a1f317 100644 --- a/src/main/java/tconstruct/weaponry/weapons/Crossbow.java +++ b/src/main/java/tconstruct/weaponry/weapons/Crossbow.java @@ -1,5 +1,6 @@ package tconstruct.weaponry.weapons; +import tconstruct.library.TConstructRegistry; import tconstruct.weaponry.TinkerWeaponry; import tconstruct.weaponry.ammo.BoltAmmo; import tconstruct.weaponry.entity.BoltEntity; @@ -415,6 +416,10 @@ public class Crossbow extends ProjectileWeapon { @Override public void buildTool (int id, String name, List list) { + // does the material have a bow material? + if(TConstructRegistry.getBowMaterial(id) == null) + return; + // all creative bows use regular bowstring ItemStack headStack = new ItemStack(getHeadItem(), 1, id); ItemStack handleStack = new ItemStack(getHandleItem(), 1, id);