Jump to content

Recommended Posts

Posted

I made an item that when you right click on an animal it drops the egg for that animal.  For some reason when this happens it drops the actual egg that the player can pick up, but it also drops another egg that the player can't do anything to. 

 

Here's the main interaction code I have.

 

public boolean itemInteractionForEntity(ItemStack itemstack, EntityLiving entity)
    {        
        if(entity instanceof EntityAnimal || entity instanceof EntityWaterMob)
        {        	
        	int spawnID = 0;
        	
        	if(entity instanceof EntityBat)
        		spawnID = 65;
        	else if(entity instanceof EntityChicken)
        		spawnID = 93;
        	else if(entity instanceof EntityCow)	
        		spawnID = 92;
        	else if(entity instanceof EntityMooshroom)
        		spawnID = 96;
        	else if(entity instanceof EntityOcelot)
        		spawnID = 98;
        	else if(entity instanceof EntityPig)
        		spawnID = 90;
        	else if(entity instanceof EntitySheep)
        		spawnID = 91;
        	else if(entity instanceof EntitySquid)
        		spawnID = 94;
        	else if(entity instanceof EntityWolf)
        		spawnID = 95;
        	else
        		return false;
        	
        	entity.setDead();
        	entity.entityDropItem(new ItemStack(383, 1, spawnID), 0.0F);
        	
        	
            return true;     
        }
        
        return false;
    }

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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