Posted July 5, 201312 yr hello everybody, i tried to made a sort of weapon wich doesn't have any ammo or somethin els and i can make it shoot without the ammo buth i can't get the itemdamage decrease , i tried some things (you will see them in the code ) but they didn't work and so yeah... i've come here... can somebody help me to make this item decrease his damage whenever the player is using it? package invizzble.mods.nc.items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import invizzble.mods.nc.entities.projectiles.EntityStaffODarknessAmmo; import invizzble.mods.nc.lib.Strings; import invizzble.mods.nc.lib.ToolIds; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ToolStaffODarkness extends Item{ public ToolStaffODarkness (int id){ super (id ); this.setUnlocalizedName(Strings.STAFFODARKNESS_NAME); this.setMaxStackSize(1); this.setCreativeTab(CreativeTabs.tabCombat); this.setMaxDamage(20); } @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) { if(this.getMaxDamage() > 0) { int maxdamage; maxdamage= this.getMaxDamage(); par2World.playSoundAtEntity(par3EntityPlayer, "StaffODarkness", 0.5F, 0.4F); { par2World.spawnEntityInWorld(new EntityStaffODarknessAmmo(par2World, par3EntityPlayer)); } maxdamage--; this.setMaxDamage(maxdamage) ; } if (this.getMaxDamage() == 0){ par3EntityPlayer.inventory.consumeInventoryItem(ToolIds.STAFFODARKNESS_DEFAULT); } return par1ItemStack; } @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister iconRegister)//updateIcons { itemIcon = iconRegister.registerIcon("NC:StaffODarkness"); } } anyway thanks for reading http://i.imgur.com/sKDS7bj.png[/img] http://www.minecraftforum.net/topic/1877292-15x-forge-smp-nightmarecraft-alpha-10-it-started-with-a-dream-new/
July 5, 201312 yr Author I actually just found it before you posted this i looked up in the sword class and there i saw the code i wanted to use and now it's like this package invizzble.mods.nc.items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import invizzble.mods.nc.entities.projectiles.EntityStaffODarknessAmmo; import invizzble.mods.nc.lib.Strings; import invizzble.mods.nc.lib.ToolIds; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ToolStaffODarkness extends Item{ public ToolStaffODarkness (int id){ super (id ); this.setUnlocalizedName(Strings.STAFFODARKNESS_NAME); this.setMaxStackSize(1); this.setCreativeTab(CreativeTabs.tabCombat); this.setMaxDamage(20); } @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) { if(this.getMaxDamage() > 0) { par2World.playSoundAtEntity(par3EntityPlayer, "StaffODarkness", 0.5F, 0.4F); { par2World.spawnEntityInWorld(new EntityStaffODarknessAmmo(par2World, par3EntityPlayer)); } this.DamageItem(par1ItemStack, par3EntityPlayer); } if (this.getMaxDamage() == 0){ par3EntityPlayer.inventory.consumeInventoryItem(ToolIds.STAFFODARKNESS_DEFAULT); } return par1ItemStack; } public void DamageItem(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase){ par1ItemStack.damageItem(1, par2EntityLivingBase); } @SideOnly(Side.CLIENT) @Override public void registerIcons(IconRegister iconRegister)//updateIcons { itemIcon = iconRegister.registerIcon("NC:StaffODarkness"); } } It works but if you see something that isn't correct ,, say it please to me http://i.imgur.com/sKDS7bj.png[/img] http://www.minecraftforum.net/topic/1877292-15x-forge-smp-nightmarecraft-alpha-10-it-started-with-a-dream-new/
July 5, 201312 yr Ok your code is ok but i explain you the constructor so you see your error by yourself. public ItemStack onItemRightClick(ItemStack par1, World par2, EntityPlayer par3); par1 = ItemStack which is the player Currently holding. par2 = World of the player par3 = The Player which is holding this stack your errors are everytime you using this insteadof par1 Hope it helps
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.