Jump to content

Get what block player is looking out?


Recommended Posts

You can try using 'getMovingObjectPositionFromPlayer' method to return a MovingObjectPosition, but that will only get you a tile if it is within reach distance. Otherwise, you will need to use vector's from the player's look position:

Vec3 vec3 = player.getPosition(1.0F);
Vec3 vec3a = player.getLook(1.0F);
Vec3 vec3b = vec3.addVector(vec3a.xCoord * distance, vec3a.yCoord * distance, vec3a.zCoord * distance);

MovingObjectPosition movingobjectposition = world.clip(vec3, vec3b);

There may be a better/simpler way than this, but this worked for my purposes. The MovingObjectPosition will contain information on the tile hit, if any. Be sure to null-check.

Link to comment
Share on other sites

  • Guest locked this topic
This topic is now closed to further replies.


  • Create New...

Important Information

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