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

In am trying to calculate the difference between the player using an item and the entity the item is used on, however the itemInteractionForEntity method i tried using does not include a variable for EntityPlayer. How can i get a variable for the player that is using the item? Thank you!

 

 

 

 

 

Hey!

maybe you can use onItemRightClick(itemStack, world, entityPlayer) instead.

 

And inside the method body, do like this:

[spoiler=CODE]

float f = 1.0F;
        double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double)f;
        double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double)f + 1.62D - (double)par3EntityPlayer.yOffset;
        double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double)f;
        MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);

        if (movingobjectposition == null)
        {
            return par1ItemStack;
        }
        else if (movingobjectposition.entityHit instanceof EntityLiving)
            {
                // DO STUFF HERE, Entity hit
            }

 

 

This is using the getMovingObjectPositionFromPlayer() method which all items inherit from the Item class.

I got this code by looking at how ItemBucket get's milk from EntityCow upon using the item :)

Hope it helps ^^

If you guys dont get it.. then well ya.. try harder...

  • Author

Wow! I have been searching around forever trying to find a solution. Thanks alot!  ;D

Sometimes a change inn perspective is all that's needed ;)

 

If you guys dont get it.. then well ya.. try harder...

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.