Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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)
        {

                player.inventory.addItemStackToInventory(cookedBeef);
                --player.getCurrentEquippedItem().stackSize;

        }
        return true;
    }

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) {}

or:

    /**
     * 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!

...or public boolean onItemUse(ItemStack is, EntityPlayer pl, World world, int x, int y, int z, int side, float sx, float sy, float sz)

Was my first thought too, but it will be a little bit difficult to get this working with a vanilla item.

Here could be your advertisement!

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.