Skip to content

Commit

Permalink
Add a creative bolt that's used for shooting crossbows without ammo i…
Browse files Browse the repository at this point in the history
…n creative, just like the vanilla arrows for the bows #1233
  • Loading branch information
bonii-xx committed Feb 22, 2015
1 parent e972ee1 commit 67c05a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/java/tconstruct/weaponry/TinkerWeaponry.java
Expand Up @@ -77,6 +77,7 @@ public class TinkerWeaponry {
// Ammo
public static AmmoItem arrowAmmo;
public static AmmoItem boltAmmo;
public static ItemStack creativeBolt;

// Tool Parts
public static Item bowstring;
Expand Down Expand Up @@ -142,6 +143,21 @@ public void postInit(FMLPostInitializationEvent event)
MinecraftForge.EVENT_BUS.register(weaponryHandler);
FMLCommonHandler.instance().bus().register(weaponryHandler);


// "vanilla" bolt:
// iron-tipped wood-shaft with feather fletching
ItemStack headStack = DualMaterialToolPart.createDualMaterial(boltAmmo.getHeadItem(), TinkerTools.MaterialID.Wood, TinkerTools.MaterialID.Iron);
ItemStack handleStack = new ItemStack(boltAmmo.getAccessoryItem(), 1, 0); // feather fletchling

ItemStack tool = ToolBuilder.instance.buildTool(headStack, handleStack, null, null, "");
if (tool != null)
{
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
creativeBolt = tool;
}
else
TConstruct.logger.error("Couldn't build basic Tinker Bolt for creative crossbow shootnig");

proxy.init();
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/tconstruct/weaponry/weapons/Crossbow.java
@@ -1,5 +1,8 @@
package tconstruct.weaponry.weapons;

import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.init.Items;
import tconstruct.TConstruct;
import tconstruct.library.TConstructRegistry;
import tconstruct.weaponry.TinkerWeaponry;
Expand Down Expand Up @@ -261,6 +264,9 @@ public ItemStack searchForAmmo(EntityPlayer player, ItemStack weapon) {
return stack;
}

if(player.capabilities.isCreativeMode && TinkerWeaponry.creativeBolt != null)
return TinkerWeaponry.creativeBolt.copy();

return null;
}

Expand Down

0 comments on commit 67c05a9

Please sign in to comment.