diff --git a/src/main/java/tconstruct/modifiers/tools/ModAttack.java b/src/main/java/tconstruct/modifiers/tools/ModAttack.java index 92337b18ad6..8c7309bb07c 100644 --- a/src/main/java/tconstruct/modifiers/tools/ModAttack.java +++ b/src/main/java/tconstruct/modifiers/tools/ModAttack.java @@ -3,6 +3,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import tconstruct.library.modifier.IModifyable; +import tconstruct.library.tools.ToolCore; + +import java.util.Arrays; public class ModAttack extends ItemModTypeFilter { @@ -11,7 +14,9 @@ public class ModAttack extends ItemModTypeFilter int threshold; String guiType; String modifierType; + boolean ammoOnly; + // Regular weapons public ModAttack(String type, int effect, ItemStack[] items, int[] value) { super(effect, "ModAttack", items, value); @@ -20,8 +25,22 @@ public ModAttack(String type, int effect, ItemStack[] items, int[] value) max = 72; threshold = 24; modifierType = "Tool"; + ammoOnly = false; } + // projectiles + public ModAttack(String type, int effect, ItemStack[] items, int[] value, boolean ammoOnly) + { + super(effect, "ModAttack", items, value); + tooltipName = "\u00a7fSharpness"; + guiType = type; + max = 48; + threshold = 24; + modifierType = "Tool"; + this.ammoOnly = ammoOnly; + } + + // gloves public ModAttack(String type, int effect, ItemStack[] items, int[] value, int max, int threshold, String modifierType) { super(effect, "ModAttack", items, value); @@ -30,11 +49,18 @@ public ModAttack(String type, int effect, ItemStack[] items, int[] value, int ma this.max = max; this.threshold = threshold; this.modifierType = modifierType; + ammoOnly = false; } @Override protected boolean canModify (ItemStack tool, ItemStack[] input) { + if(tool.getItem() instanceof ToolCore) + { + if(Arrays.asList(((ToolCore) tool.getItem()).getTraits()).contains("ammo") != ammoOnly) + return false; + } + if (tool.getItem() instanceof IModifyable) { IModifyable toolItem = (IModifyable) tool.getItem(); diff --git a/src/main/java/tconstruct/weaponry/TinkerWeaponry.java b/src/main/java/tconstruct/weaponry/TinkerWeaponry.java index 55469e7982c..015387c0ed8 100644 --- a/src/main/java/tconstruct/weaponry/TinkerWeaponry.java +++ b/src/main/java/tconstruct/weaponry/TinkerWeaponry.java @@ -24,6 +24,7 @@ import tconstruct.library.tools.FletchlingLeafMaterial; import tconstruct.library.util.IPattern; import tconstruct.library.util.IToolPart; +import tconstruct.modifiers.tools.ModAttack; import tconstruct.modifiers.tools.ModWindup; import tconstruct.modifiers.tools.ModAmmoRestock; import tconstruct.smeltery.TinkerSmeltery; @@ -102,11 +103,15 @@ public void init(FMLInitializationEvent event) registerBoltCasting(); setupCreativeTab(); + // Modifiers ItemStack redstoneItem = new ItemStack(Items.redstone); ItemStack redstoneBlock = new ItemStack(Blocks.redstone_block); ModifyBuilder.registerModifier(new ModWindup(2, new ItemStack[] { redstoneItem, redstoneBlock }, new int[] { 1, 9 })); ModifyBuilder.registerModifier(new ModAmmoRestock()); + TinkerTools.modAttack = new ModAttack("Quartz", 11, new ItemStack[] { new ItemStack(Items.quartz), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE) }, new int[] { 1, 4 }, true); + ModifyBuilder.registerModifier(TinkerTools.modAttack); + TConstructRegistry.registerActiveToolMod(new WeaponryActiveToolMod()); }