Posted June 18, 201510 yr I made a sword item that summons in mobs while taking 1 durability. problem is when it reaches zero it doesn't break, and keeps reducing the durability. when I use the .setdamage as soon as I click the item it reduces the durability to zero and still works until I try to hit a mob, then I breaks. how should I fix this. heres my code package com.OlympiansMod.Item; import com.OlympiansMod.entity.EntityUndead; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.util.DamageSource; import net.minecraft.world.World; public class DioceltiansSepter extends ItemSword{ public DioceltiansSepter(ToolMaterial p_i45356_1_) { super(p_i45356_1_); // TODO Auto-generated constructor stub } public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){ if(!player.capabilities.isCreativeMode){ itemstack.setItemDamage(itemstack.getItemDamage() + 1); player.attackEntityFrom(DamageSource.causeIndirectMagicDamage(player, player), 10); } if(!world.isRemote){ //for (int i = 0 ; i < 5 ; i++){ EntityUndead undead = new EntityUndead(world); undead.setPosition(player.posX + 1, player.posY, player.posZ); world.spawnEntityInWorld(undead); EntityUndead undead2 = new EntityUndead(world); undead2.setPosition(player.posX, player.posY, player.posZ + 1); world.spawnEntityInWorld(undead2); EntityUndead undead3 = new EntityUndead(world); undead3.setPosition(player.posX, player.posY, player.posZ - 2); world.spawnEntityInWorld(undead3); EntityUndead undead4 = new EntityUndead(world); undead4.setPosition(player.posX - 2, player.posY, player.posZ); world.spawnEntityInWorld(undead4); EntityUndead undead5 = new EntityUndead(world); undead5.setPosition(player.posX + 1.5, player.posY, player.posZ); world.spawnEntityInWorld(undead5); } //} return itemstack; } } Im serious don't look at it!!
June 18, 201510 yr You probably need to check yourself if the durability is below 0. Then break the item.
June 18, 201510 yr how do you get when the item breaks? When? Check to see if the durability is 0. How? I have no idea, check an item tool class, might have something in there.
June 19, 201510 yr Author ok the thing is extending ItemSword should already be checking the durability, and it is just not for rightclicking, so those clases don't help. any other ideas? Im serious don't look at it!!
June 19, 201510 yr What do you mean? Like I said... Do it yourself. Pseudo code: if(itemstack.getDurability() <= 0){ return null; //play breaking animation }else{ return itemstack; }
June 19, 201510 yr Author dude you failed there is a 10* easier way to do it.. lol itemstack.damageItem(1, player); check up on flint and steel Im serious don't look at it!!
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.