Jump to content

Recommended Posts

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

Posted

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-

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.