Jump to content

[1.6.2] [Solved] Selecting entity ID returns an incorrect value


RaTheBadger

Recommended Posts

Hello. I'm trying to make an item which changes its own damage value to the entity ID of a mob, when the mob is right clicked.

For example, its damage value would be 52 for a spider, 61 for a blaze, etc.

 

However, when I right click a mob with the item, the damage value becomes something completely different; 3732, 167, or any other sort of seemingly random value.

I think that the problem might be that it's returning that specific entity's ID, rather than the ID of the type of entity it is.

 

How should I fix this?

 

Relevant code:

    public boolean func_111207_a(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase)
    {
    	if (par1ItemStack.getItemDamage() == 0)
    	{
    		if (par3EntityLivingBase instanceof EntityLiving)
    		{
    			EntityLiving entityliving = (EntityLiving)par3EntityLivingBase;
    			par1ItemStack.setItemDamage(par3EntityLivingBase.entityId);
    			return true;
    		}
        
       		else
        	{
            	return super.func_111207_a(par1ItemStack, par2EntityPlayer, par3EntityLivingBase);
        	}
    	}
    	
    	else
    	{
    		return false;
    	}
    }

Thanks again.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.