This is my first tutorial. Please correct me if I did anything wrong.
(It uses ModLoader)
I just started modding a few months ago, and now that 1.4.2 has come out, I had to update all my mods. First time I had to do that . So, even in 1.3, I couldn't find a very good bow tutorial. They were either broken, or didn't work so well. So, I found how to make it, although it doesn't function exactly as a normal bow. The FOV is not changed, and the animation appears in the hotbar. Anyways, without anymore delay, lets begin the tutorial!
So. First, you want to add the following code to your mod_****.class
public static final Item yourBowNameHere = (new ItemYourBowNameHere(ItemIDHere)).setItemName("yourBowNameHere");
public static int yourBowNameHere1 = ModLoader.addOverride("/gui/items.png", "/yourBowNameHere1.png");
public static int yourBowNameHere2 = ModLoader.addOverride("/gui/items.png", "/yourBowNameHere2.png");
public static int yourBowNameHere3 = ModLoader.addOverride("/gui/items.png", "/yourBowNameHere3.png");
public static int yourBowNameHere4 = ModLoader.addOverride("/gui/items.png", "/yourBowNameHere4.png");
-Remember to rename everything to what you want.
So what's happening in the code.
You're creating a new Item, and a new class. You'll get errors at this point, but that's okay. We're not done.
The new item that is created is ItemYourBowNameHere. You'll want to create a new ItemYourBowNameHere.class, but I'll show you what to put in there later.
The other 4 items,
public static int yourBowNameHere1 = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere1.png");
public static int yourBowNameHere2 = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere2.png");
public static int yourBowNameHere3 = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere3.png");
public static int yourBowNameHere4 = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere4.png");
, are just what I call temporary items, placeholders. They aren't those literally, but you can't actually do anything with them in-game.
Where it says "/yourBowNameHere(#).png", that sets the image file. So if you set it to "/Textures/bow1.png your texture will be in minecraft.jar/Textures/bow1.png
Now do the standard procedure for making items, for the main bow item.
In case you don't know how to do that, put this into your public void load(){}
codedBowNameHere.iconIndex = ModLoader.addOverride("/gui/items.png", "/yourBowTextureHere1.png");
ModLoader.addName(codedBowNameHere, "In-Game Bow Name Here");
ModLoader.addRecipe(new ItemStack(codedBowNameHere, 1), new Object[] {" ", " , " "});
What's happening is you're adding the coded version into the game, declaring it's texture (the previous textures are for the stages of the bow, more explained later), declaring it's in-game name, and creating the recipe. Look up other tutorials for creating recipes.
The next step, we're going to create the class for the bow. Everything that happens with the bow is coded here.
Create a new class, and name it ItemYourBowNameHere -Remember to rename it to what you want. Inside the class, paste the following code...
package net.minecraft.src;
import java.util.Random;
public class ItemYourBowNameHere extends ItemBow
{
private Random rand = new Random();
public ItemYourBowNameHere(int var1)
{
super(var1);
this.maxStackSize = 1;
this.setMaxDamage(UseAmountHere);
this.bFull3D = true;
this.setCreativeTab(CreativeTabs.tabCombat);
}
/**
* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
* update it's contents.
*/
public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
{
EntityPlayer var6 = (EntityPlayer)var3;
ItemStack var7 = var6.inventory.getCurrentItem();
if (var6.isUsingItem() && var7.itemID == mod_****.yourBowNameHere.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
if (var8 >= 18)
{
this.iconIndex = mod_****.yourBowNameHere4;
}
else if (var8 > 13)
{
this.iconIndex = mod_****.yourBowNameHere3;
}
else if (var8 > 0)
{
this.iconIndex = mod_****.yourBowNameHere2;
}
}
else
{
this.iconIndex = mod_****.yourBowNameHere.iconIndex;
}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
{
boolean var5 = var3.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
if (var5 || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
int var6 = this.getMaxItemUseDuration(var1) - var4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityArrow var8 = new EntityArrow(var2, var3, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
{
var8.setFire(100);
}
var1.damageItem(1, var3);
var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (!var5)
{
var3.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
}
else
{
var8.canBePickedUp = 2;
}
if (!var2.isRemote)
{
var2.spawnEntityInWorld(var8);
var8.setDamage(var8.getDamage() * 1.15D);
this.iconIndex = mod_****.yourBowNameHere1;
}
}
ItemStack var11 = var3.inventory.getCurrentItem();
if (var11.itemID != mod_****.yourBowNameHere.shiftedIndex)
{
this.iconIndex = mod_****.yourBowNameHere1;
}
}
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
}
And rename everything to what you called everything in your mod_**** class.
So what's happening in this class, is...
public ItemYourBowNameHere(int var1)
{
super(var1);
this.maxStackSize = 1;
In case you didn't read, it sets the max stack size for you bow. You probably want it to be 1. If you do more than that, when the bow is used, every bow in the stack will be damaged.
this.setMaxDamage(UseAmountHere);
Here, you set the amount of uses your bow has. For reference, the default bow has 351 uses.
this.bFull3D = true;
I think this just tells minecraft to render the item in your hand 3D. Correct me if I'm wrong.
this.setCreativeTab(CreativeTabs.tabCombat);
}
This sets the creative tab you want the bow to appear on. You probably want to keep it at tabComat.
Other tab options are:
Now back to the bow class. In the public void onUpdate part, we're adding the drawback animation.
if (var6.isUsingItem() && var7.itemID == mod_****.yourBowNameHere.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
if (var8 >= 18)
{
this.iconIndex = mod_****.yourBowNameHere4;
}
else if (var8 > 13)
{
this.iconIndex = mod_****.yourBowNameHere3;
}
else if (var8 > 0)
{
this.iconIndex = mod_****.yourBowNameHere2;
}
}
else
{
this.iconIndex = mod_****.yourBowNameHere.iconIndex;
}
What's happening, is you're taking those 4 'temporary' items you created in your mod_**** class, and using them. Each tick you draw back the bow, the more your bow will drawback. See the if [(var8 >=18]? That's the first step, yourBowNameHere4. I think I'm about to fail to explain something to you, but what it does is, it starts the drawback animation at 0 ticks, yourBowNameHere2. Then, 5 ticks later, [else if (var8 > 13)], it changes the item to yourBowNameHere3, which is the second step. 5 more ticks later, it switches to yourBowNameHere4, at 18 ticks. I think then, it waits until you release. If you aren't drawing the bow, it'll just be your bow, yourBowNameHere.
The next part is checking if you have an arrow in your inventory, spawning a new 'EntityArrow', launching it, and deleting the arrow in you inventory. If your bow is enchanted, it calculates what it needs to do, and applies that stuff.
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
That part, I think it's just saying if you try to eat the bow, go to var1, which I think is to start the drawback. Again, correct me if I'm wrong.
Don't know what
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
does.
This,
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
Again, I'm pretty sure it just starts the drawback.
public int getItemEnchantability()
{
return 1;
}
This part just sets how easy it is to enchant the bow, I think. So if you want it to be easier to get high enchantments, make it a higher number. Again, I'm not 100% sure that's what it is. Correct me if I'm wrong.
I think that's about it for the coding.
Your textures will need to be your bow name, and then numbered 1-4, along with another texture of the bow, with no number.
1 is the first stage, the default bow, 2 is the next drawback phase, 3 and 4 as well. Just so you know, 4 is the last phase, the tightest form of the bow.
Hope this helps. Again, this is my first tutorial. Please correct any of my mistakes, and if this helped, please please please hit that little green up arrow.
Please help. I'm using FML and this is the only error that comes up.
Also, if I remove "coded" it fixes that problem, but then it says "Item.iconIndex is not visible"
public static final Item codedDragonBow = (new ItemcodedDragonBow(ItemIDHere)).setItemName("codedDragonBow");
public static int codedDragonBow1 = ModLoader.addOverride("/gui/items.png", "/dragonBow1.png");
public static int codedDragonBow2 = ModLoader.addOverride("/gui/items.png", "/dragonBow2.png");
public static int codedDragonBow3 = ModLoader.addOverride("/gui/items.png", "/dragonBow3.png");
public static int codedDragonBow4 = ModLoader.addOverride("/gui/items.png", "/dragonBow4.png");
Make sure you have that OUTSIDE your load method, or whatever it's called.
Your other code, make sure it's inside the load part.
Again, I'm not so sure with FML. Only ever worked with ModLoader itself.
EDIT: I'm still not 100%, but maybe the variable means you can't use the word coded in your name. I'm not sure. First, make sure you have the new code I gave you. Whatever you're using, Eclipse, Notepad++, hit Ctrl + F to use the find and replace function. Find all the codedDragonBow 's and replace them with dragonBow. (In your mod_**** class)
Hey, I did all of the above, and it doesn't seem to work..... Minecraft won't crash or anything, the item just doesn't show up... Any ideas what might be wrong? There are no errors in the code.
package net.minecraft.src;
import java.util.Random;
public class mod_Quincybow {
public static final Item QuincyBow = (new ItemQuincyBow(183)).setItemName("qbow");
public static int QuincyBow1 = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow1.png");
public static int QuincyBow2 = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow2.png");
public static int QuincyBow3 = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow3.png");
public static int QuincyBow4 = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow4.png");
public void load(){
QuincyBow.iconIndex = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow.png");
ModLoader.addName(QuincyBow, "Quincy Bow");
ModLoader.addRecipe(new ItemStack(QuincyBow, 1), new Object[]{
" #*", "# *", " #*", Character.valueOf('#'), mod_Reiatsu.ReiatsuBlock, Character.valueOf('*'), mod_Reiatsu.Reiatsu});
}
}
package net.minecraft.src;
import java.util.Random;
public class ItemQuincyBow extends ItemBow
{
private Random rand = new Random();
public ItemQuincyBow(int var1)
{
super(var1);
this.maxStackSize = 1;
this.setMaxDamage(400);
this.bFull3D = true;
this.setCreativeTab(CreativeTabs.tabCombat);
}
public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
{
EntityPlayer var6 = (EntityPlayer)var3;
ItemStack var7 = var6.inventory.getCurrentItem();
if (var6.isUsingItem() && var7.itemID == mod_Quincybow.QuincyBow.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
if (var8 >= 18)
{
this.iconIndex = mod_Quincybow.QuincyBow4;
}
else if (var8 > 13)
{
this.iconIndex = mod_Quincybow.QuincyBow3;
}
else if (var8 > 0)
{
this.iconIndex = mod_Quincybow.QuincyBow2;
}
}
else
{
this.iconIndex = mod_Quincybow.QuincyBow.iconIndex;
}
}
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
{
boolean var5 = var3.capabilities.isCreativeMode ||
EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
if (var5 || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
int var6 = this.getMaxItemUseDuration(var1) - var4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityArrow var8 = new EntityArrow(var2, var3, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
{
var8.setFire(100);
}
var1.damageItem(1, var3);
var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (!var5)
{
var3.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
}
else
{
var8.canBePickedUp = 2;
}
if (!var2.isRemote)
{
var2.spawnEntityInWorld(var8);
var8.setDamage(var8.getDamage() * 1.15D);
this.iconIndex = mod_Quincybow.QuincyBow1;
}
}
ItemStack var11 = var3.inventory.getCurrentItem();
if (var11.itemID != mod_Quincybow.QuincyBow.shiftedIndex)
{
this.iconIndex = mod_Quincybow.QuincyBow1;
}
}
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
public int getItemEnchantability()
{
return 1;
}
}
I really appreciate your tutorial, I'm new to modding and a bow is one of the last pieces that brings my mod together. However, it is also causing two small issues that are keeping me from releasing it (One is being addressed in another thread).
I believe I have all my textures set up properly, but after I fire my bow, it changes to the texture of a quiver (the already-in-minecraft quiver). If I comment out some texture code in my mod_SigmaCore it comes with the texture of a blank helmet, but after its fired, it works fine and has the correct texture after that.
Here's my mod_SigmaCore and ItemQuartziteBow if they help, appologies for all the extra content in the core.
mod_SigmaCore
package net.minecraft.src;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Random;
public class mod_SigmaCore extends BaseMod
{
//Block IDs
public static final Block CopperOre = new BlockCopperOre(160, 0).setStepSound(Block.soundStoneFootstep).setBlockName("CopperOre").setHardness(3.0F).setResistance(5F).setLightValue(0.0F);
public static final Block BlockCopper = new BlockCopper(161, 1).setStepSound(Block.soundMetalFootstep).setBlockName("BlockCopper").setHardness(4.5F).setResistance(20F).setLightValue(0.0F);
public static final Block MythrilOre = new BlockMythrilOre(162, 2).setStepSound(Block.soundStoneFootstep).setBlockName("OreMythril").setHardness(3.0F).setResistance(5F).setLightValue(0.0F);
public static final Block BlockMythril = new BlockMythril(163, 3).setStepSound(Block.soundMetalFootstep).setBlockName("BlockMythril").setHardness(4.5F).setResistance(20F).setLightValue(0.0F);
public static final Block QuartzOre = new BlockQuartzOre(164, 4).setStepSound(Block.soundStoneFootstep).setBlockName("OreQuartz").setHardness(3.0F).setResistance(5F).setLightValue(0.0F);
public static final Block BlockQuartz = new BlockQuartz(165, 5).setStepSound(Block.soundGlassFootstep).setBlockName("BlockQuartz").setHardness(4.5F).setResistance(20F).setLightValue(0.2F);
//Item IDs
public static final Item MythrilShard = new ItemMythrilShard(5011).setItemName("MythrilShard");
public static final Item QuartzCrystal = new ItemQuartzCrystal(5012).setItemName("QuartzCrystal");
public static final Item CopperIngot = new ItemCopperIngot(5013).setItemName("CopperIngot");
public static final Item QuartzArrow = new ItemQuartzArrow(5014).setItemName("QuartzArrow");
public static final Item QuartziteBow = new ItemQuartziteBow(5015).setItemName("QuartziteBow");
//Bow Stuff
public static int QuartziteBow1 = ModLoader.addOverride("/gui/items.png", "/textures/QBow.png");
public static int QuartziteBow2 = ModLoader.addOverride("/gui/items.png", "/textures/QBow1.png");
public static int QuartziteBow3 = ModLoader.addOverride("/gui/items.png", "/textures/QBow2.png");
public static int QuartziteBow4 = ModLoader.addOverride("/gui/items.png", "/textures/QBow3.png");
//Tool IDs
public static final Item CopperPickaxe = new ItemPickaxe(5001, EnumToolMaterial.COPPER).setItemName("Copper Pickaxe");
public static final Item CopperAxe = new ItemAxe(5002, EnumToolMaterial.COPPER).setItemName("Copper Axe");
public static final Item CopperSpade = new ItemSpade(5003, EnumToolMaterial.COPPER).setItemName("Copper Spade");
public static final Item CopperSword = new ItemSword(5004, EnumToolMaterial.COPPER).setItemName("Copper Sword");
public static final Item CopperHoe = new ItemHoe(5005, EnumToolMaterial.COPPER).setItemName("Copper Hoe");
public static final Item MythrilPickaxe = new ItemPickaxe(5006, EnumToolMaterial.MYTHRIL).setItemName("Copper Pickaxe");
public static final Item MythrilAxe = new ItemAxe(5007, EnumToolMaterial.MYTHRIL).setItemName("Copper Axe");
public static final Item MythrilSpade = new ItemSpade(5008, EnumToolMaterial.MYTHRIL).setItemName("Copper Spade");
public static final Item MythrilSword = new ItemSword(5009, EnumToolMaterial.MYTHRIL).setItemName("Copper Sword");
public static final Item MythrilHoe = new ItemHoe(5010, EnumToolMaterial.MYTHRIL).setItemName("Copper Hoe");
//Armor IDs
public static final Item MythrilHelm = new ItemArmor(5016, EnumArmorMaterial.MYTHRIL, ModLoader.addArmor("MythrilArmor"), 0).setItemName("Mythril Helm");
public static final Item MythrilChestplate = new ItemArmor(5017, EnumArmorMaterial.MYTHRIL, ModLoader.addArmor("MythrilArmor"), 1).setItemName("Mythril Chestplate");
public static final Item MythrilLeggings = new ItemArmor(5018, EnumArmorMaterial.MYTHRIL, ModLoader.addArmor("MythrilArmor"), 2).setItemName("Mythril Leggings");
public static final Item MythrilGreaves = new ItemArmor(5019, EnumArmorMaterial.MYTHRIL, ModLoader.addArmor("MythrilArmor"), 3).setItemName("Mythril Greaves");
//Public Void
public void load()
{
//Blocks
CopperOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/CopperOre.png");
ModLoader.registerBlock(CopperOre);
ModLoader.addName(CopperOre, "Copper Ore");
BlockCopper.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/BlockCopper.png");
ModLoader.registerBlock(BlockCopper);
ModLoader.addName(BlockCopper, "Copper Block");
MythrilOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/MythrilOre.png");
ModLoader.registerBlock(MythrilOre);
ModLoader.addName(MythrilOre, "Mythril Ore");
BlockMythril.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/BlockMythril.png");
ModLoader.registerBlock(BlockMythril);
ModLoader.addName(BlockMythril, "Mythril Block");
QuartzOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/QuartzOre.png");
ModLoader.registerBlock(QuartzOre);
ModLoader.addName(QuartzOre, "Quartz Ore");
BlockQuartz.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/BlockQuartz.png");
ModLoader.registerBlock(BlockQuartz);
ModLoader.addName(BlockQuartz, "QuartzBlock");
//Items
MythrilShard.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilShard.png");
QuartzCrystal.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/QuartzCrystal.png");
CopperIngot.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperIngot.png");
QuartzArrow.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/QuartzArrow.png");
QuartziteBow.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/QBow.png");
ModLoader.addName(MythrilShard, "Mythril Shard");
ModLoader.addName(QuartzCrystal, "Quartz Crystal");
ModLoader.addName(CopperIngot, "Copper Ingot");
ModLoader.addName(QuartzArrow, "Quartz Arrow");
ModLoader.addName(QuartziteBow, "Quartzite Bow");
//You originally had .setCreativeTab, but it should be .setTabToDisplayOn
MythrilShard.setCreativeTab(CreativeTabs.tabMaterials);
QuartzCrystal.setCreativeTab(CreativeTabs.tabMaterials);
CopperIngot.setCreativeTab(CreativeTabs.tabMaterials);
QuartzArrow.setCreativeTab(CreativeTabs.tabTools);
//Recipes
ModLoader.addRecipe(new ItemStack(BlockCopper, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), mod_SigmaCore.CopperIngot});
ModLoader.addShapelessRecipe(new ItemStack(CopperIngot, 9), new Object[]{ BlockCopper });
ModLoader.addRecipe(new ItemStack(BlockMythril, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), mod_SigmaCore.MythrilShard});
ModLoader.addShapelessRecipe(new ItemStack(MythrilShard, 9), new Object[]{ BlockMythril });
ModLoader.addRecipe(new ItemStack(BlockQuartz, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), mod_SigmaCore.QuartzCrystal});
ModLoader.addShapelessRecipe(new ItemStack(QuartzCrystal, 9), new Object[]{ BlockQuartz });
ModLoader.addRecipe(new ItemStack(QuartzArrow, 1), new Object [] {"Q", "S", "F", Character.valueOf('Q'), mod_SigmaCore.QuartzCrystal, Character.valueOf('S'), Item.stick, Character.valueOf('F'), Item.feather});
ModLoader.addRecipe(new ItemStack(QuartziteBow, 1), new Object [] {" QS", "I S", " QS", Character.valueOf('Q'), mod_SigmaCore.QuartzCrystal, Character.valueOf('I'), Item.ingotIron, Character.valueOf('S'), Item.silk});
ModLoader.addRecipe(new ItemStack(Item.redstoneRepeater, 1), new Object[] {"SQS", Character.valueOf('S'), Block.stone, Character.valueOf('Q'), mod_SigmaCore.QuartzCrystal});
//Smelting
ModLoader.addSmelting(CopperOre.blockID, new ItemStack(CopperIngot, 1), 1.0F);
//Tools and weapons
ModLoader.addRecipe(new ItemStack(CopperPickaxe, 1), new Object [] {"###", " X ", " X ", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(CopperSpade, 1), new Object [] {"#", "X", "X", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(CopperSword, 1), new Object [] {"#", "#", "X", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(CopperAxe, 1), new Object [] {"##", "#X ", " X", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(CopperHoe, 1), new Object [] {"##", "X ", "X ", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilPickaxe, 1), new Object [] {"###", " X ", " X ", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilSpade, 1), new Object [] {"#", "X", "X", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilSword, 1), new Object [] {"#", "#", "X", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilAxe, 1), new Object [] {"##", "#X ", " X", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilHoe, 1), new Object [] {"##", "X ", "X ", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addName(CopperPickaxe, "Copper Pickaxe");
ModLoader.addName(CopperAxe, "Copper Axe");
ModLoader.addName(CopperSpade, "Copper Spade");
ModLoader.addName(CopperSword, "Copper Sword");
ModLoader.addName(CopperHoe, "Copper Hoe");
ModLoader.addName(MythrilPickaxe, "Mythril Pickaxe");
ModLoader.addName(MythrilAxe, "Mythril Axe");
ModLoader.addName(MythrilSpade, "Mythril Spade");
ModLoader.addName(MythrilSword, "Mythril Sword");
ModLoader.addName(MythrilHoe, "Mythril Hoe");
CopperPickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperPickaxe.png");
CopperAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperAxe.png");
CopperSpade.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperSpade.png");
CopperSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperSword.png");
CopperHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperHoe.png");
MythrilPickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilPickaxe.png");
MythrilAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilAxe.png");
MythrilSpade.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilSpade.png");
MythrilSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilSword.png");
MythrilHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilHoe.png");
//Armor
MythrilHelm.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilHelm.png");
MythrilChestplate.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilArmor.png");
MythrilLeggings.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilLeggings.png");
MythrilGreaves.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilGreaves.png");
ModLoader.addRecipe(new ItemStack(MythrilHelm, 1), new Object [] {"###", "# #", Character.valueOf('#'), MythrilShard});
ModLoader.addRecipe(new ItemStack(MythrilChestplate, 1), new Object [] {"# #", "###", "###", Character.valueOf('#'), MythrilShard});
ModLoader.addRecipe(new ItemStack(MythrilLeggings, 1), new Object [] {"###", "# #", "# #", Character.valueOf('#'), MythrilShard});
ModLoader.addRecipe(new ItemStack(MythrilGreaves, 1), new Object [] {"# #", "# #", Character.valueOf('#'), MythrilShard});
ModLoader.addName(MythrilHelm, "Mythril Helm");
ModLoader.addName(MythrilChestplate, "Mythril Chestplate");
ModLoader.addName(MythrilLeggings, "Mythril Leggings");
ModLoader.addName(MythrilGreaves, "Mythril Greaves");
}
//Ore Generation
public void generateSurface(World world, Random random, int i, int j)
{
for(int k = 0; k < 18; k++)
{
int randPosX = i + random.nextInt(16);
int randPosY = random.nextInt(70);
int randPosZ = j + random.nextInt(16);
(new WorldGenMinable(CopperOre.blockID, 12)).generate(world, random, randPosX, randPosY, randPosZ);
}
for(int k = 0; k < 2; k++)
{
int randPosX = i + random.nextInt(16);
int randPosY = random.nextInt(35);
int randPosZ = j + random.nextInt(16);
(new WorldGenMinable(MythrilOre.blockID, 8)).generate(world, random, randPosX, randPosY, randPosZ);
}
for(int k = 0; k < 2; k++)
{
int randPosX = i + random.nextInt(16);
int randPosY = random.nextInt(35);
int randPosZ = j + random.nextInt(16);
(new WorldGenMinable(QuartzOre.blockID, 20)).generate(world, random, randPosX, randPosY, randPosZ);
}
}
public String getVersion()
{
return "1.4.2";
}
}
ItemQuartziteBow
package net.minecraft.src;
import java.util.Random;
public class ItemQuartziteBow extends ItemBow
{
private Random rand = new Random();
public ItemQuartziteBow(int var1)
{
super(var1);
this.maxStackSize = 1;
this.setMaxDamage(500);
this.bFull3D = true;
this.setCreativeTab(CreativeTabs.tabCombat);
}
/**
* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
* update it's contents.
*/
public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
{
EntityPlayer var6 = (EntityPlayer)var3;
ItemStack var7 = var6.inventory.getCurrentItem();
if (var6.isUsingItem() && var7.itemID == mod_SigmaCore.QuartziteBow.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
if (var8 >= 18)
{
this.iconIndex = mod_SigmaCore.QuartziteBow4;
}
else if (var8 > 13)
{
this.iconIndex = mod_SigmaCore.QuartziteBow3;
}
else if (var8 > 0)
{
this.iconIndex = mod_SigmaCore.QuartziteBow2;
}
}
else
{
this.iconIndex = mod_SigmaCore.QuartziteBow.iconIndex;
}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
{
boolean var5 = var3.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
if (var5 || var3.inventory.hasItem(mod_SigmaCore.QuartzArrow.shiftedIndex))
{
int var6 = this.getMaxItemUseDuration(var1) - var4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityQuartzArrow var8 = new EntityQuartzArrow(var2, var3, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
{
var8.setFire(100);
}
var1.damageItem(1, var3);
var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (!var5)
{
var3.inventory.consumeInventoryItem(mod_SigmaCore.QuartzArrow.shiftedIndex);
}
else
{
var8.canBePickedUp = 2;
}
par2World.spawnEntityInWorld(var8);
}
ItemStack var11 = var3.inventory.getCurrentItem();
if (var11.itemID != mod_SigmaCore.QuartziteBow.shiftedIndex)
{
this.iconIndex = mod_SigmaCore.QuartziteBow1;
}
}
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(mod_SigmaCore.QuartzArrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
}
Thanks for your help!
Rollback Post to RevisionRollBack
Sigma_Phi - home of the long-winded answers to questions nobody asked.
Hey, I did all of the above, and it doesn't seem to work..... Minecraft won't crash or anything, the item just doesn't show up... Any ideas what might be wrong? There are no errors in the code.
package net.minecraft.src;
import java.util.Random;
public class mod_Quincybow {
public static final Item QuincyBow = (new ItemQuincyBow(183)).setItemName("qbow");
public static int QuincyBow1 = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow1.png");
public static int QuincyBow2 = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow2.png");
public static int QuincyBow3 = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow3.png");
public static int QuincyBow4 = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow4.png");
public void load(){
QuincyBow.iconIndex = ModLoader.addOverride("/gui/items.png", "/bleachmod/quincy_bow.png");
ModLoader.addName(QuincyBow, "Quincy Bow");
ModLoader.addRecipe(new ItemStack(QuincyBow, 1), new Object[]{
" #*", "# *", " #*", Character.valueOf('#'), mod_Reiatsu.ReiatsuBlock, Character.valueOf('*'), mod_Reiatsu.Reiatsu});
}
}
package net.minecraft.src;
import java.util.Random;
public class ItemQuincyBow extends ItemBow
{
private Random rand = new Random();
public ItemQuincyBow(int var1)
{
super(var1);
this.maxStackSize = 1;
this.setMaxDamage(400);
this.bFull3D = true;
this.setCreativeTab(CreativeTabs.tabCombat);
}
public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
{
EntityPlayer var6 = (EntityPlayer)var3;
ItemStack var7 = var6.inventory.getCurrentItem();
if (var6.isUsingItem() && var7.itemID == mod_Quincybow.QuincyBow.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
if (var8 >= 18)
{
this.iconIndex = mod_Quincybow.QuincyBow4;
}
else if (var8 > 13)
{
this.iconIndex = mod_Quincybow.QuincyBow3;
}
else if (var8 > 0)
{
this.iconIndex = mod_Quincybow.QuincyBow2;
}
}
else
{
this.iconIndex = mod_Quincybow.QuincyBow.iconIndex;
}
}
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
{
boolean var5 = var3.capabilities.isCreativeMode ||
EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
if (var5 || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
int var6 = this.getMaxItemUseDuration(var1) - var4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityArrow var8 = new EntityArrow(var2, var3, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
{
var8.setFire(100);
}
var1.damageItem(1, var3);
var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (!var5)
{
var3.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
}
else
{
var8.canBePickedUp = 2;
}
if (!var2.isRemote)
{
var2.spawnEntityInWorld(var8);
var8.setDamage(var8.getDamage() * 1.15D);
this.iconIndex = mod_Quincybow.QuincyBow1;
}
}
ItemStack var11 = var3.inventory.getCurrentItem();
if (var11.itemID != mod_Quincybow.QuincyBow.shiftedIndex)
{
this.iconIndex = mod_Quincybow.QuincyBow1;
}
}
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
public int getItemEnchantability()
{
return 1;
}
}
Pretty sure Items ID's have to be higher than 255. Make it higher than 500 to be safe. That should fix your problem.
(+1? :3)
I really appreciate your tutorial, I'm new to modding and a bow is one of the last pieces that brings my mod together. However, it is also causing two small issues that are keeping me from releasing it (One is being addressed in another thread).
I believe I have all my textures set up properly, but after I fire my bow, it changes to the texture of a quiver (the already-in-minecraft quiver). If I comment out some texture code in my mod_SigmaCore it comes with the texture of a blank helmet, but after its fired, it works fine and has the correct texture after that.
Here's my mod_SigmaCore and ItemQuartziteBow if they help, appologies for all the extra content in the core.
mod_SigmaCore
package net.minecraft.src;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Random;
public class mod_SigmaCore extends BaseMod
{
//Block IDs
public static final Block CopperOre = new BlockCopperOre(160, 0).setStepSound(Block.soundStoneFootstep).setBlockName("CopperOre").setHardness(3.0F).setResistance(5F).setLightValue(0.0F);
public static final Block BlockCopper = new BlockCopper(161, 1).setStepSound(Block.soundMetalFootstep).setBlockName("BlockCopper").setHardness(4.5F).setResistance(20F).setLightValue(0.0F);
public static final Block MythrilOre = new BlockMythrilOre(162, 2).setStepSound(Block.soundStoneFootstep).setBlockName("OreMythril").setHardness(3.0F).setResistance(5F).setLightValue(0.0F);
public static final Block BlockMythril = new BlockMythril(163, 3).setStepSound(Block.soundMetalFootstep).setBlockName("BlockMythril").setHardness(4.5F).setResistance(20F).setLightValue(0.0F);
public static final Block QuartzOre = new BlockQuartzOre(164, 4).setStepSound(Block.soundStoneFootstep).setBlockName("OreQuartz").setHardness(3.0F).setResistance(5F).setLightValue(0.0F);
public static final Block BlockQuartz = new BlockQuartz(165, 5).setStepSound(Block.soundGlassFootstep).setBlockName("BlockQuartz").setHardness(4.5F).setResistance(20F).setLightValue(0.2F);
//Item IDs
public static final Item MythrilShard = new ItemMythrilShard(5011).setItemName("MythrilShard");
public static final Item QuartzCrystal = new ItemQuartzCrystal(5012).setItemName("QuartzCrystal");
public static final Item CopperIngot = new ItemCopperIngot(5013).setItemName("CopperIngot");
public static final Item QuartzArrow = new ItemQuartzArrow(5014).setItemName("QuartzArrow");
public static final Item QuartziteBow = new ItemQuartziteBow(5015).setItemName("QuartziteBow");
//Bow Stuff
public static int QuartziteBow1 = ModLoader.addOverride("/gui/items.png", "/textures/QBow.png");
public static int QuartziteBow2 = ModLoader.addOverride("/gui/items.png", "/textures/QBow1.png");
public static int QuartziteBow3 = ModLoader.addOverride("/gui/items.png", "/textures/QBow2.png");
public static int QuartziteBow4 = ModLoader.addOverride("/gui/items.png", "/textures/QBow3.png");
//Tool IDs
public static final Item CopperPickaxe = new ItemPickaxe(5001, EnumToolMaterial.COPPER).setItemName("Copper Pickaxe");
public static final Item CopperAxe = new ItemAxe(5002, EnumToolMaterial.COPPER).setItemName("Copper Axe");
public static final Item CopperSpade = new ItemSpade(5003, EnumToolMaterial.COPPER).setItemName("Copper Spade");
public static final Item CopperSword = new ItemSword(5004, EnumToolMaterial.COPPER).setItemName("Copper Sword");
public static final Item CopperHoe = new ItemHoe(5005, EnumToolMaterial.COPPER).setItemName("Copper Hoe");
public static final Item MythrilPickaxe = new ItemPickaxe(5006, EnumToolMaterial.MYTHRIL).setItemName("Copper Pickaxe");
public static final Item MythrilAxe = new ItemAxe(5007, EnumToolMaterial.MYTHRIL).setItemName("Copper Axe");
public static final Item MythrilSpade = new ItemSpade(5008, EnumToolMaterial.MYTHRIL).setItemName("Copper Spade");
public static final Item MythrilSword = new ItemSword(5009, EnumToolMaterial.MYTHRIL).setItemName("Copper Sword");
public static final Item MythrilHoe = new ItemHoe(5010, EnumToolMaterial.MYTHRIL).setItemName("Copper Hoe");
//Armor IDs
public static final Item MythrilHelm = new ItemArmor(5016, EnumArmorMaterial.MYTHRIL, ModLoader.addArmor("MythrilArmor"), 0).setItemName("Mythril Helm");
public static final Item MythrilChestplate = new ItemArmor(5017, EnumArmorMaterial.MYTHRIL, ModLoader.addArmor("MythrilArmor"), 1).setItemName("Mythril Chestplate");
public static final Item MythrilLeggings = new ItemArmor(5018, EnumArmorMaterial.MYTHRIL, ModLoader.addArmor("MythrilArmor"), 2).setItemName("Mythril Leggings");
public static final Item MythrilGreaves = new ItemArmor(5019, EnumArmorMaterial.MYTHRIL, ModLoader.addArmor("MythrilArmor"), 3).setItemName("Mythril Greaves");
//Public Void
public void load()
{
//Blocks
CopperOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/CopperOre.png");
ModLoader.registerBlock(CopperOre);
ModLoader.addName(CopperOre, "Copper Ore");
BlockCopper.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/BlockCopper.png");
ModLoader.registerBlock(BlockCopper);
ModLoader.addName(BlockCopper, "Copper Block");
MythrilOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/MythrilOre.png");
ModLoader.registerBlock(MythrilOre);
ModLoader.addName(MythrilOre, "Mythril Ore");
BlockMythril.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/BlockMythril.png");
ModLoader.registerBlock(BlockMythril);
ModLoader.addName(BlockMythril, "Mythril Block");
QuartzOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/QuartzOre.png");
ModLoader.registerBlock(QuartzOre);
ModLoader.addName(QuartzOre, "Quartz Ore");
BlockQuartz.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/textures/BlockQuartz.png");
ModLoader.registerBlock(BlockQuartz);
ModLoader.addName(BlockQuartz, "QuartzBlock");
//Items
MythrilShard.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilShard.png");
QuartzCrystal.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/QuartzCrystal.png");
CopperIngot.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperIngot.png");
QuartzArrow.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/QuartzArrow.png");
QuartziteBow.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/QBow.png");
ModLoader.addName(MythrilShard, "Mythril Shard");
ModLoader.addName(QuartzCrystal, "Quartz Crystal");
ModLoader.addName(CopperIngot, "Copper Ingot");
ModLoader.addName(QuartzArrow, "Quartz Arrow");
ModLoader.addName(QuartziteBow, "Quartzite Bow");
//You originally had .setCreativeTab, but it should be .setTabToDisplayOn
MythrilShard.setCreativeTab(CreativeTabs.tabMaterials);
QuartzCrystal.setCreativeTab(CreativeTabs.tabMaterials);
CopperIngot.setCreativeTab(CreativeTabs.tabMaterials);
QuartzArrow.setCreativeTab(CreativeTabs.tabTools);
//Recipes
ModLoader.addRecipe(new ItemStack(BlockCopper, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), mod_SigmaCore.CopperIngot});
ModLoader.addShapelessRecipe(new ItemStack(CopperIngot, 9), new Object[]{ BlockCopper });
ModLoader.addRecipe(new ItemStack(BlockMythril, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), mod_SigmaCore.MythrilShard});
ModLoader.addShapelessRecipe(new ItemStack(MythrilShard, 9), new Object[]{ BlockMythril });
ModLoader.addRecipe(new ItemStack(BlockQuartz, 1), new Object [] {"###", "###", "###", Character.valueOf('#'), mod_SigmaCore.QuartzCrystal});
ModLoader.addShapelessRecipe(new ItemStack(QuartzCrystal, 9), new Object[]{ BlockQuartz });
ModLoader.addRecipe(new ItemStack(QuartzArrow, 1), new Object [] {"Q", "S", "F", Character.valueOf('Q'), mod_SigmaCore.QuartzCrystal, Character.valueOf('S'), Item.stick, Character.valueOf('F'), Item.feather});
ModLoader.addRecipe(new ItemStack(QuartziteBow, 1), new Object [] {" QS", "I S", " QS", Character.valueOf('Q'), mod_SigmaCore.QuartzCrystal, Character.valueOf('I'), Item.ingotIron, Character.valueOf('S'), Item.silk});
ModLoader.addRecipe(new ItemStack(Item.redstoneRepeater, 1), new Object[] {"SQS", Character.valueOf('S'), Block.stone, Character.valueOf('Q'), mod_SigmaCore.QuartzCrystal});
//Smelting
ModLoader.addSmelting(CopperOre.blockID, new ItemStack(CopperIngot, 1), 1.0F);
//Tools and weapons
ModLoader.addRecipe(new ItemStack(CopperPickaxe, 1), new Object [] {"###", " X ", " X ", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(CopperSpade, 1), new Object [] {"#", "X", "X", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(CopperSword, 1), new Object [] {"#", "#", "X", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(CopperAxe, 1), new Object [] {"##", "#X ", " X", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(CopperHoe, 1), new Object [] {"##", "X ", "X ", Character.valueOf('#'), CopperIngot, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilPickaxe, 1), new Object [] {"###", " X ", " X ", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilSpade, 1), new Object [] {"#", "X", "X", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilSword, 1), new Object [] {"#", "#", "X", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilAxe, 1), new Object [] {"##", "#X ", " X", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addRecipe(new ItemStack(MythrilHoe, 1), new Object [] {"##", "X ", "X ", Character.valueOf('#'), MythrilShard, Character.valueOf('X'), Item.stick});
ModLoader.addName(CopperPickaxe, "Copper Pickaxe");
ModLoader.addName(CopperAxe, "Copper Axe");
ModLoader.addName(CopperSpade, "Copper Spade");
ModLoader.addName(CopperSword, "Copper Sword");
ModLoader.addName(CopperHoe, "Copper Hoe");
ModLoader.addName(MythrilPickaxe, "Mythril Pickaxe");
ModLoader.addName(MythrilAxe, "Mythril Axe");
ModLoader.addName(MythrilSpade, "Mythril Spade");
ModLoader.addName(MythrilSword, "Mythril Sword");
ModLoader.addName(MythrilHoe, "Mythril Hoe");
CopperPickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperPickaxe.png");
CopperAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperAxe.png");
CopperSpade.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperSpade.png");
CopperSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperSword.png");
CopperHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/CopperHoe.png");
MythrilPickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilPickaxe.png");
MythrilAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilAxe.png");
MythrilSpade.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilSpade.png");
MythrilSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilSword.png");
MythrilHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilHoe.png");
//Armor
MythrilHelm.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilHelm.png");
MythrilChestplate.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilArmor.png");
MythrilLeggings.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilLeggings.png");
MythrilGreaves.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/MythrilGreaves.png");
ModLoader.addRecipe(new ItemStack(MythrilHelm, 1), new Object [] {"###", "# #", Character.valueOf('#'), MythrilShard});
ModLoader.addRecipe(new ItemStack(MythrilChestplate, 1), new Object [] {"# #", "###", "###", Character.valueOf('#'), MythrilShard});
ModLoader.addRecipe(new ItemStack(MythrilLeggings, 1), new Object [] {"###", "# #", "# #", Character.valueOf('#'), MythrilShard});
ModLoader.addRecipe(new ItemStack(MythrilGreaves, 1), new Object [] {"# #", "# #", Character.valueOf('#'), MythrilShard});
ModLoader.addName(MythrilHelm, "Mythril Helm");
ModLoader.addName(MythrilChestplate, "Mythril Chestplate");
ModLoader.addName(MythrilLeggings, "Mythril Leggings");
ModLoader.addName(MythrilGreaves, "Mythril Greaves");
}
//Ore Generation
public void generateSurface(World world, Random random, int i, int j)
{
for(int k = 0; k < 18; k++)
{
int randPosX = i + random.nextInt(16);
int randPosY = random.nextInt(70);
int randPosZ = j + random.nextInt(16);
(new WorldGenMinable(CopperOre.blockID, 12)).generate(world, random, randPosX, randPosY, randPosZ);
}
for(int k = 0; k < 2; k++)
{
int randPosX = i + random.nextInt(16);
int randPosY = random.nextInt(35);
int randPosZ = j + random.nextInt(16);
(new WorldGenMinable(MythrilOre.blockID, 8)).generate(world, random, randPosX, randPosY, randPosZ);
}
for(int k = 0; k < 2; k++)
{
int randPosX = i + random.nextInt(16);
int randPosY = random.nextInt(35);
int randPosZ = j + random.nextInt(16);
(new WorldGenMinable(QuartzOre.blockID, 20)).generate(world, random, randPosX, randPosY, randPosZ);
}
}
public String getVersion()
{
return "1.4.2";
}
}
ItemQuartziteBow
package net.minecraft.src;
import java.util.Random;
public class ItemQuartziteBow extends ItemBow
{
private Random rand = new Random();
public ItemQuartziteBow(int var1)
{
super(var1);
this.maxStackSize = 1;
this.setMaxDamage(500);
this.bFull3D = true;
this.setCreativeTab(CreativeTabs.tabCombat);
}
/**
* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
* update it's contents.
*/
public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
{
EntityPlayer var6 = (EntityPlayer)var3;
ItemStack var7 = var6.inventory.getCurrentItem();
if (var6.isUsingItem() && var7.itemID == mod_SigmaCore.QuartziteBow.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
if (var8 >= 18)
{
this.iconIndex = mod_SigmaCore.QuartziteBow4;
}
else if (var8 > 13)
{
this.iconIndex = mod_SigmaCore.QuartziteBow3;
}
else if (var8 > 0)
{
this.iconIndex = mod_SigmaCore.QuartziteBow2;
}
}
else
{
this.iconIndex = mod_SigmaCore.QuartziteBow.iconIndex;
}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
{
boolean var5 = var3.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
if (var5 || var3.inventory.hasItem(mod_SigmaCore.QuartzArrow.shiftedIndex))
{
int var6 = this.getMaxItemUseDuration(var1) - var4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityQuartzArrow var8 = new EntityQuartzArrow(var2, var3, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
{
var8.setFire(100);
}
var1.damageItem(1, var3);
var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (!var5)
{
var3.inventory.consumeInventoryItem(mod_SigmaCore.QuartzArrow.shiftedIndex);
}
else
{
var8.canBePickedUp = 2;
}
par2World.spawnEntityInWorld(var8);
}
ItemStack var11 = var3.inventory.getCurrentItem();
if (var11.itemID != mod_SigmaCore.QuartziteBow.shiftedIndex)
{
this.iconIndex = mod_SigmaCore.QuartziteBow1;
}
}
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(mod_SigmaCore.QuartzArrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
}
Thanks for your help!
Can't really see any way to fix it. Try changing the item ID of your bow, perhaps, idk why, the quiver is using 5015 or something. Yes, I know it's smart, but try making the textures of the bow step 1 and the bow on it's own separate.
Hope this helps. I am new to modding, so I can't find errors right off the bat. :|
is there a way to make it shoot a custom throrable entity?
Try looking in the bow class, and changing the EntityArrow parts to your throwable entity. Try experimenting. I'm not sure, but it definitely is possible.
My arrows are straight up invisible. No particles, nothing. They ARE there, they make impact sounds and kill things, but they don't render.
Here's my RenderQuartzArrow.
package net.minecraft.src;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class RenderQuartzArrow extends Render
{
public void renderQuartzArrow(EntityQuartzArrow par1EntityQuartzArrow, double par2, double par4, double par6, float par8, float par9)
{
this.loadTexture("/textures/QuartzArrows.png");
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glRotatef(par1EntityQuartzArrow.prevRotationYaw + (par1EntityQuartzArrow.rotationYaw - par1EntityQuartzArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(par1EntityQuartzArrow.prevRotationPitch + (par1EntityQuartzArrow.rotationPitch - par1EntityQuartzArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
Tessellator var10 = Tessellator.instance;
byte var11 = 0;
float var12 = 0.0F;
float var13 = 0.5F;
float var14 = (float)(0 + var11 * 10) / 32.0F;
float var15 = (float)(5 + var11 * 10) / 32.0F;
float var16 = 0.0F;
float var17 = 0.15625F;
float var18 = (float)(5 + var11 * 10) / 32.0F;
float var19 = (float)(10 + var11 * 10) / 32.0F;
float var20 = 0.05625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
float var21 = (float)par1EntityQuartzArrow.arrowShake - par9;
if (var21 > 0.0F)
{
float var22 = -MathHelper.sin(var21 * 3.0F) * var21;
GL11.glRotatef(var22, 0.0F, 0.0F, 1.0F);
}
GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
GL11.glScalef(var20, var20, var20);
GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
GL11.glNormal3f(var20, 0.0F, 0.0F);
var10.startDrawingQuads();
var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var18);
var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var18);
var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var19);
var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var19);
var10.draw();
GL11.glNormal3f(-var20, 0.0F, 0.0F);
var10.startDrawingQuads();
var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var18);
var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var18);
var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var19);
var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var19);
var10.draw();
for (int var23 = 0; var23 < 4; ++var23)
{
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glNormal3f(0.0F, 0.0F, var20);
var10.startDrawingQuads();
var10.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)var12, (double)var14);
var10.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)var13, (double)var14);
var10.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)var13, (double)var15);
var10.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)var12, (double)var15);
var10.draw();
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.renderQuartzArrow((EntityQuartzArrow)par1Entity, par2, par4, par6, par8, par9);
}
}
I basically took the render arrow and substituted (that really makes up a lot of low-level modding, huh?). My texture is correct and all.
Help is appreciated, you got your rep points
Rollback Post to RevisionRollBack
Sigma_Phi - home of the long-winded answers to questions nobody asked.
line 116 of your bow's class "Item.arrow.shiftedIndex"
You can change it to a custom arrow, if you wish by making it "mod_YourClass.YourArrow.shiftedIndex"
I could be wrong, so if there's problems, don't ask me...I was just going off what I think.
There's another "Item.arrow.shiftedIndex" at line 165. You might need to change that too, but I think it only effects if the bow is shot in creative mode (line 116 might only effect survival mode shooting, so I guess it's not needed, unless you want continuity between creative and survival in your mod)
line 116 of your bow's class "Item.arrow.shiftedIndex"
You can change it to a custom arrow, if you wish by making it "mod_YourClass.YourArrow.shiftedIndex"
I could be wrong, so if there's problems, don't ask me...I was just going off what I think.
There's another "Item.arrow.shiftedIndex" at line 165. You might need to change that too, but I think it only effects if the bow is shot in creative mode (line 116 might only effect survival mode shooting, so I guess it's not needed, unless you want continuity between creative and survival in your mod)
My arrows are straight up invisible. No particles, nothing. They ARE there, they make impact sounds and kill things, but they don't render.
Here's my RenderQuartzArrow.
package net.minecraft.src;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class RenderQuartzArrow extends Render
{
public void renderQuartzArrow(EntityQuartzArrow par1EntityQuartzArrow, double par2, double par4, double par6, float par8, float par9)
{
this.loadTexture("/textures/QuartzArrows.png");
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glRotatef(par1EntityQuartzArrow.prevRotationYaw + (par1EntityQuartzArrow.rotationYaw - par1EntityQuartzArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(par1EntityQuartzArrow.prevRotationPitch + (par1EntityQuartzArrow.rotationPitch - par1EntityQuartzArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
Tessellator var10 = Tessellator.instance;
byte var11 = 0;
float var12 = 0.0F;
float var13 = 0.5F;
float var14 = (float)(0 + var11 * 10) / 32.0F;
float var15 = (float)(5 + var11 * 10) / 32.0F;
float var16 = 0.0F;
float var17 = 0.15625F;
float var18 = (float)(5 + var11 * 10) / 32.0F;
float var19 = (float)(10 + var11 * 10) / 32.0F;
float var20 = 0.05625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
float var21 = (float)par1EntityQuartzArrow.arrowShake - par9;
if (var21 > 0.0F)
{
float var22 = -MathHelper.sin(var21 * 3.0F) * var21;
GL11.glRotatef(var22, 0.0F, 0.0F, 1.0F);
}
GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
GL11.glScalef(var20, var20, var20);
GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
GL11.glNormal3f(var20, 0.0F, 0.0F);
var10.startDrawingQuads();
var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var18);
var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var18);
var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var19);
var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var19);
var10.draw();
GL11.glNormal3f(-var20, 0.0F, 0.0F);
var10.startDrawingQuads();
var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var18);
var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var18);
var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var19);
var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var19);
var10.draw();
for (int var23 = 0; var23 < 4; ++var23)
{
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glNormal3f(0.0F, 0.0F, var20);
var10.startDrawingQuads();
var10.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)var12, (double)var14);
var10.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)var13, (double)var14);
var10.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)var13, (double)var15);
var10.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)var12, (double)var15);
var10.draw();
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.renderQuartzArrow((EntityQuartzArrow)par1Entity, par2, par4, par6, par8, par9);
}
}
I basically took the render arrow and substituted (that really makes up a lot of low-level modding, huh?). My texture is correct and all.
Help is appreciated, you got your rep points
Thanks so much for those points
I'm not even going to read that spoiler, because I know that your answer will be in this post: http://www.minecraft...0#entry17786787
If you want me to clarify anything, just ask.
My arrows are actually rendering as invisible too, and that post says that base classes will need to be edited. Since I'm using forge and would like my mod to be compatible with other mods, I don't want to edit any base classes.
My arrows are actually rendering as invisible too, and that post says that base classes will need to be edited. Since I'm using forge and would like my mod to be compatible with other mods, I don't want to edit any base classes.
Thanks for the link, but I'm not sure how far it'll get me- It's forge, and I'm only using modloader. My short term plans don't require forge, and I only have distant notions of converting. Thank you though.
Edit: Yeah, I don't want to modify base files either, if possible. I mean, my mod DOES already, but I'm learning how to work around my current modifications, so that maybe in a while I'll be able to have a version that doesn't.
Rollback Post to RevisionRollBack
Sigma_Phi - home of the long-winded answers to questions nobody asked.
My arrows are actually rendering as invisible too, and that post says that base classes will need to be edited. Since I'm using forge and would like my mod to be compatible with other mods, I don't want to edit any base classes.
Yes, I was quite worried when I first added my own mob. I looked into it, and editing those base classes will NOT, I repeat, will NOT interfere with other mods (I lied. 99.99%). Doesn't matter if you're using forge.
I highly suggest using the help from that post. It works.
Thanks for the link, but I'm not sure how far it'll get me- It's forge, and I'm only using modloader. My short term plans don't require forge, and I only have distant notions of converting. Thank you though.
Edit: Yeah, I don't want to modify base files either, if possible. I mean, my mod DOES already, but I'm learning how to work around my current modifications, so that maybe in a while I'll be able to have a version that doesn't.
Read above. Also, it doesn't matter whether or not you are using forge. It has nothing to with modloader/forge. Either will work.
/**
* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
* update it's contents.
*/
public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
{
EntityPlayer var6 = (EntityPlayer)var3;
ItemStack var7 = var6.inventory.getCurrentItem();
if (var6.isUsingItem() && var7.itemID == mod_MoreBows.IronBow.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
{
boolean var5 = var3.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
if (var11.itemID != mod_MoreBows.GoldBow.shiftedIndex)
{
this.iconIndex = mod_MoreBows.GoldBow1;
}
}
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
}
For some reason my bow only has 10 uses!!?!?! can i cant figure out how to fix this... Please Help!
package net.minecraft.src;
import java.util.Random;
public class ItemIronBow extends ItemBow
{
private Random rand = new Random();
public ItemIronBow(int var1)
{
super(var1);
this.maxStackSize = 1;
this.setMaxDamage(10);
this.bFull3D = true;
this.setCreativeTab(CreativeTabs.tabCombat);
}
/**
* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
* update it's contents.
*/
public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
{
EntityPlayer var6 = (EntityPlayer)var3;
ItemStack var7 = var6.inventory.getCurrentItem();
if (var6.isUsingItem() && var7.itemID == mod_MoreBows.IronBow.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
if (var8 >= 18)
{
this.iconIndex = mod_MoreBows2.IronBow4;
}
else if (var8 > 13)
{
this.iconIndex = mod_MoreBows2.IronBow3;
}
else if (var8 > 0)
{
this.iconIndex = mod_MoreBows2.IronBow2;
}
}
else
{
this.iconIndex = mod_MoreBows2.IronBow.iconIndex;
}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
{
boolean var5 = var3.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
if (var5 || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
int var6 = this.getMaxItemUseDuration(var1) - var4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityArrow var8 = new EntityArrow(var2, var3, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
{
var8.setFire(100);
}
var1.damageItem(1, var3);
var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (!var5)
{
var3.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
}
else
{
var8.canBePickedUp = 2;
}
if (!var2.isRemote)
{
var2.spawnEntityInWorld(var8);
var8.setDamage(var8.getDamage() * 2.15D);
this.iconIndex = mod_MoreBows.GoldBow1;
}
}
ItemStack var11 = var3.inventory.getCurrentItem();
if (var11.itemID != mod_MoreBows.GoldBow.shiftedIndex)
{
this.iconIndex = mod_MoreBows.GoldBow1;
}
}
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
}
Thank you for that tutorial really helpful!
Now i used the template/code you have here to make a Crossbow and i need my Crossbow to shoot a Bolt instead of arrow, can you by any chance help me with that?
(It uses ModLoader)
I just started modding a few months ago, and now that 1.4.2 has come out, I had to update all my mods. First time I had to do that . So, even in 1.3, I couldn't find a very good bow tutorial. They were either broken, or didn't work so well. So, I found how to make it, although it doesn't function exactly as a normal bow. The FOV is not changed, and the animation appears in the hotbar. Anyways, without anymore delay, lets begin the tutorial!
So. First, you want to add the following code to your mod_****.class
-Remember to rename everything to what you want.
So what's happening in the code.
You're creating a new Item, and a new class. You'll get errors at this point, but that's okay. We're not done.
The new item that is created is ItemYourBowNameHere. You'll want to create a new ItemYourBowNameHere.class, but I'll show you what to put in there later.
The other 4 items,
, are just what I call temporary items, placeholders. They aren't those literally, but you can't actually do anything with them in-game.
Where it says "/yourBowNameHere(#).png", that sets the image file. So if you set it to "/Textures/bow1.png your texture will be in minecraft.jar/Textures/bow1.png
Now do the standard procedure for making items, for the main bow item.
In case you don't know how to do that, put this into your public void load(){}
What's happening is you're adding the coded version into the game, declaring it's texture (the previous textures are for the stages of the bow, more explained later), declaring it's in-game name, and creating the recipe. Look up other tutorials for creating recipes.
The next step, we're going to create the class for the bow. Everything that happens with the bow is coded here.
Create a new class, and name it ItemYourBowNameHere -Remember to rename it to what you want. Inside the class, paste the following code...
And rename everything to what you called everything in your mod_**** class.
So what's happening in this class, is...
In case you didn't read, it sets the max stack size for you bow. You probably want it to be 1. If you do more than that, when the bow is used, every bow in the stack will be damaged.
Here, you set the amount of uses your bow has. For reference, the default bow has 351 uses.
I think this just tells minecraft to render the item in your hand 3D. Correct me if I'm wrong.
This sets the creative tab you want the bow to appear on. You probably want to keep it at tabComat.
Other tab options are:
Now back to the bow class. In the public void onUpdate part, we're adding the drawback animation.
What's happening, is you're taking those 4 'temporary' items you created in your mod_**** class, and using them. Each tick you draw back the bow, the more your bow will drawback. See the if [(var8 >=18]? That's the first step, yourBowNameHere4. I think I'm about to fail to explain something to you, but what it does is, it starts the drawback animation at 0 ticks, yourBowNameHere2. Then, 5 ticks later, [else if (var8 > 13)], it changes the item to yourBowNameHere3, which is the second step. 5 more ticks later, it switches to yourBowNameHere4, at 18 ticks. I think then, it waits until you release. If you aren't drawing the bow, it'll just be your bow, yourBowNameHere.
The next part is checking if you have an arrow in your inventory, spawning a new 'EntityArrow', launching it, and deleting the arrow in you inventory. If your bow is enchanted, it calculates what it needs to do, and applies that stuff.
That part, I think it's just saying if you try to eat the bow, go to var1, which I think is to start the drawback. Again, correct me if I'm wrong.
Don't know what
does.
This,
Again, I'm pretty sure it just starts the drawback.
This part just sets how easy it is to enchant the bow, I think. So if you want it to be easier to get high enchantments, make it a higher number. Again, I'm not 100% sure that's what it is. Correct me if I'm wrong.
I think that's about it for the coding.
Your textures will need to be your bow name, and then numbered 1-4, along with another texture of the bow, with no number.
1 is the first stage, the default bow, 2 is the next drawback phase, 3 and 4 as well. Just so you know, 4 is the last phase, the tightest form of the bow.
Hope this helps. Again, this is my first tutorial. Please correct any of my mistakes, and if this helped, please please please hit that little green up arrow.
-peon. Ah. Now I can stop typing
It should
Sorry, I don't know Forge.
It comes up with an error saying that codedBowNameHere cannot be resolved to a variable. Here's my edit of the code:
Please help. I'm using FML and this is the only error that comes up.
Also, if I remove "coded" it fixes that problem, but then it says "Item.iconIndex is not visible"
Make sure you have that OUTSIDE your load method, or whatever it's called.
Your other code, make sure it's inside the load part.
Again, I'm not so sure with FML. Only ever worked with ModLoader itself.
EDIT: I'm still not 100%, but maybe the variable means you can't use the word coded in your name. I'm not sure. First, make sure you have the new code I gave you. Whatever you're using, Eclipse, Notepad++, hit Ctrl + F to use the find and replace function. Find all the codedDragonBow 's and replace them with dragonBow. (In your mod_**** class)
Bleach Mod
I really appreciate your tutorial, I'm new to modding and a bow is one of the last pieces that brings my mod together. However, it is also causing two small issues that are keeping me from releasing it (One is being addressed in another thread).
I believe I have all my textures set up properly, but after I fire my bow, it changes to the texture of a quiver (the already-in-minecraft quiver). If I comment out some texture code in my mod_SigmaCore it comes with the texture of a blank helmet, but after its fired, it works fine and has the correct texture after that.
Here's my mod_SigmaCore and ItemQuartziteBow if they help, appologies for all the extra content in the core.
mod_SigmaCore
ItemQuartziteBow
Thanks for your help!
Sigma_Phi - home of the long-winded answers to questions nobody asked.
Pretty sure Items ID's have to be higher than 255. Make it higher than 500 to be safe. That should fix your problem.
(+1? :3)
Can't really see any way to fix it. Try changing the item ID of your bow, perhaps, idk why, the quiver is using 5015 or something. Yes, I know it's smart, but try making the textures of the bow step 1 and the bow on it's own separate.
Hope this helps. I am new to modding, so I can't find errors right off the bat. :|
Try looking in the bow class, and changing the EntityArrow parts to your throwable entity. Try experimenting. I'm not sure, but it definitely is possible.
I'm still having problems getting my custom arrow to render, but that's another issue.
Thanks again!
Sigma_Phi - home of the long-winded answers to questions nobody asked.
Hm, what do you mean getting it to render?
No problem (I really want some reputation points, could ya help me out? :P)
Here's my RenderQuartzArrow.
I basically took the render arrow and substituted (that really makes up a lot of low-level modding, huh?). My texture is correct and all.
Help is appreciated, you got your rep points
Sigma_Phi - home of the long-winded answers to questions nobody asked.
line 116 of your bow's class "Item.arrow.shiftedIndex"
You can change it to a custom arrow, if you wish by making it "mod_YourClass.YourArrow.shiftedIndex"
I could be wrong, so if there's problems, don't ask me...I was just going off what I think.
There's another "Item.arrow.shiftedIndex" at line 165. You might need to change that too, but I think it only effects if the bow is shot in creative mode (line 116 might only effect survival mode shooting, so I guess it's not needed, unless you want continuity between creative and survival in your mod)
Oh crud. Ty for that. I missread his post ._.
Thanks so much for those points
I'm not even going to read that spoiler, because I know that your answer will be in this post:
http://www.minecraftforum.net/topic/1417041-mod-entity-problem-updated-with-forge/page__st__100#entry17786787
If you want me to clarify anything, just ask.
My arrows are actually rendering as invisible too, and that post says that base classes will need to be edited. Since I'm using forge and would like my mod to be compatible with other mods, I don't want to edit any base classes.
Thanks for the link, but I'm not sure how far it'll get me- It's forge, and I'm only using modloader. My short term plans don't require forge, and I only have distant notions of converting. Thank you though.
Edit: Yeah, I don't want to modify base files either, if possible. I mean, my mod DOES already, but I'm learning how to work around my current modifications, so that maybe in a while I'll be able to have a version that doesn't.
Sigma_Phi - home of the long-winded answers to questions nobody asked.
Yes, I was quite worried when I first added my own mob. I looked into it, and editing those base classes will NOT, I repeat, will NOT interfere with other mods (I lied. 99.99%). Doesn't matter if you're using forge.
I highly suggest using the help from that post. It works.
Read above. Also, it doesn't matter whether or not you are using forge. It has nothing to with modloader/forge. Either will work.
package net.minecraft.src;
import java.util.Random;
public class ItemIronBow extends ItemBow
{
private Random rand = new Random();
public ItemIronBow(int var1)
{
super(var1);
this.maxStackSize = 1;
this.setMaxDamage(10);
this.bFull3D = true;
this.setCreativeTab(CreativeTabs.tabCombat);
}
/**
* Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
* update it's contents.
*/
public void onUpdate(ItemStack var1, World var2, Entity var3, int var4, boolean var5)
{
EntityPlayer var6 = (EntityPlayer)var3;
ItemStack var7 = var6.inventory.getCurrentItem();
if (var6.isUsingItem() && var7.itemID == mod_MoreBows.IronBow.shiftedIndex)
{
int var8 = var1.getMaxItemUseDuration() - var6.getItemInUseCount();
if (var8 >= 18)
{
this.iconIndex = mod_MoreBows2.IronBow4;
}
else if (var8 > 13)
{
this.iconIndex = mod_MoreBows2.IronBow3;
}
else if (var8 > 0)
{
this.iconIndex = mod_MoreBows2.IronBow2;
}
}
else
{
this.iconIndex = mod_MoreBows2.IronBow.iconIndex;
}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack var1, World var2, EntityPlayer var3, int var4)
{
boolean var5 = var3.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, var1) > 0;
if (var5 || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
int var6 = this.getMaxItemUseDuration(var1) - var4;
float var7 = (float)var6 / 20.0F;
var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;
if ((double)var7 < 0.1D)
{
return;
}
if (var7 > 1.0F)
{
var7 = 1.0F;
}
EntityArrow var8 = new EntityArrow(var2, var3, var7 * 2.0F);
if (var7 == 1.0F)
{
var8.setIsCritical(true);
}
int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, var1);
if (var9 > 0)
{
var8.setDamage(var8.getDamage() + (double)var9 * 0.5D + 0.5D);
}
int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, var1);
if (var10 > 0)
{
var8.setKnockbackStrength(var10);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, var1) > 0)
{
var8.setFire(100);
}
var1.damageItem(1, var3);
var2.playSoundAtEntity(var3, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);
if (!var5)
{
var3.inventory.consumeInventoryItem(Item.arrow.shiftedIndex);
}
else
{
var8.canBePickedUp = 2;
}
if (!var2.isRemote)
{
var2.spawnEntityInWorld(var8);
var8.setDamage(var8.getDamage() * 2.15D);
this.iconIndex = mod_MoreBows.GoldBow1;
}
}
ItemStack var11 = var3.inventory.getCurrentItem();
if (var11.itemID != mod_MoreBows.GoldBow.shiftedIndex)
{
this.iconIndex = mod_MoreBows.GoldBow1;
}
}
public ItemStack onFoodEaten(ItemStack var1, World var2, EntityPlayer var3)
{
return var1;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack var1)
{
return 72000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack var1)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (var3.capabilities.isCreativeMode || var3.inventory.hasItem(Item.arrow.shiftedIndex))
{
var3.setItemInUse(var1, this.getMaxItemUseDuration(var1));
}
return var1;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}
}
Replace the 10 in...
To whatever you want the damage to be.
(Rep points please? :3)
Now i used the template/code you have here to make a Crossbow and i need my Crossbow to shoot a Bolt instead of arrow, can you by any chance help me with that?
Bleach Mod