Jump to content

[1.7.10][SOLVED]How to check if even.item equals to some item


TheCreepySheep

Recommended Posts

I'm trying to make my code check, if EntityItemPickupEvent item equals to dirt for example.

My code :

public class ItemPickupHandler
{
    @SubscribeEvent
    public void itemPickup(EntityItemPickupEvent event)
    {
        if (event.entity instanceof EntityPlayer){
            if (event.item == /*What now?*/){
                LogHelper.info("stuff happens");
            }
        }
    }
}

 

It does fire without the IF for special block/On any pickup.

 

Thanks in advance

TheCreepySheep

Link to comment
Share on other sites

Add an if statemant with: !event.item.worldObj.isRemote

And change your line to:              if (event.item.getEntityItem().getItem() == Item.getItemFromBlock(Blocks.dirt)){

If you want to check if its an item use Items.ITEM for Blocks use Item.getItemFromBlock(Blocks.BLOCK)

Link to comment
Share on other sites

Add an if statemant with: !event.item.worldObj.isRemote

And change your line to:              if (event.item.getEntityItem().getItem() == Item.getItemFromBlock(Blocks.dirt)){

If you want to check if its an item use Items.ITEM for Blocks use Item.getItemFromBlock(Blocks.BLOCK)

 

Thank you good sir!

It does exactly what I want.

Link to comment
Share on other sites

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.