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

I'm trying to find 2 functions that I can call if a player is looking at a living entity (boolean) and that it returns the living entity the player is looking at.

Example (I know it's probably wrong but only a guess):

if(isLookingAtLivingEntity){
EntityLiving targetEntity = getLivingEntityLookingAt()
}

Any ideas?

 


 

Update: (27/6/13 GMT 00:18)

I haven't really given the scenario for help to actually be efficient.

So I'm gonig to give a basic overview:

I'm making a sword that when I'm facing a Living Entity, it will teleport the player to the entity when I right click. I've got the right click sorted, and the method of the teleportation sorted (moveEntity()) and I could probably get the calculate coordinates to teleport me. I just need a the living entity's position which I think I could get from a LivingEntity return from some function (which I didn't find) I could call. However, if there are other methods then that might be helpful.

Thanks, Melonize

Minecraft.getMinecraft().objectMouseOver.entityHit is the client side version of which entity the player is looking at

if(Minecraft.getMinecraft().objectMouseOver.entityHit != null){
    if(Minecraft.getMinecraft().objectMouseOver.entityHit instanceof EntityLiving){
        //here you know the player is looking at a entityliving
    }
}

 

 

this is only for client side, if you want server side, send a packet

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

  • Author

After search and questioning on other forums I found the rayTrace method. Thanks for the assistance anyways!

which is obliviously not necessary but ok, hf

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.