Jump to content

[1.7.10] How to detect whether a player is looking at a block.


Recommended Posts

Hi, sorry I posting so late at night (If your on Mountain Time) but I have a few problems. Problem #1) I would like to know to detect if a player is looking at my custom block. Problem #2) I would like to draw some quads (I know how to do that) and make them rotate depending on the direction the player is looking. Like barriers (I know that's in 1.8 and uses particles, but that's besides the point).


Is there any way to do this? If so how? Could anyone point to some good tutorials, if any?

Link to comment
Share on other sites

Problem #1) Which block you are looking at, try this:


MovingObjectPosition mop = Minecraft.getMinecraft().objectMouseOver()


or you could try rayTracing, but i'ts proven to be a bit inaccurate over long distances.




Problem #2) Get the players looking vector, you could look at the code for the enchanting table, the book does something similar.

I require Java, both the coffee and the code :)

Link to comment
Share on other sites

  • 2 months later...

Ok, but how do I get the look angles from a Vec3 (where the player is looking)?

Ill just send you a bit of code that I use whenever I get home.


I know this is an older thread, but mind sharing that code with everyone if you can? I'm trying to solve this same problem.

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.