Jump to content

onItemRightClick on a block Help


Recommended Posts

So basically im trying to have it when certain items are right clicked on my block the item in hand is taken is replaced with a new one. I was also thinking i could do the same type of thing where if the player throws the item on my block they get a new item and the thrown on is destroyed, i figured i could do that with a item event handler, something like the Twilight Forest mod does to create the portal. but i have not been successful ether way. i've also tried PlayerInteractionEvent


Any help is great, thanks


currently what im trying

public boolean onItemRightClick(ItemStack stack, World world, EntityPlayer player, PlayerInteractEvent event)

        ItemStack beef = new ItemStack(Items.beef);
        ItemStack cookedBeef = new ItemStack(Items.cooked_beef);

        if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem() == beef)


        return true;

Link to comment
Share on other sites

Copied from the Block class:

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz) {}


     * Called whenever an entity is walking on top of this block. Args: world, x, y, z, entity     //check if the entity is your item?
    public void onEntityWalking(World p_149724_1_, int p_149724_2_, int p_149724_3_, int p_149724_4_, Entity p_149724_5_) {}

Here could be your advertisement!

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.

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.


  • Create New...

Important Information

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