Jump to content

[1.15.2 | Solved] How to Raytrace from Block to Block and get facing


Shiranai

Recommended Posts

I am trying to raytrace from the position of a block and i want to find the position of a block in a specific direction but all the raytracing methods i've found need an entity.

I also need to find which way the block is facing (north, east, down, ...).

 

Edited by Shiranai
Solved
Link to comment
Share on other sites

If your raytrace is orthogonal (directly north, directly east, directly SW), just iterate over BlockPos values.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

On 3/1/2020 at 8:49 PM, Draco18s said:

If your raytrace is orthogonal (directly north, directly east, directly SW), just iterate over BlockPos values.

Yeah, i'm doing that at the moment. It does feel kinda hacky though if you have to do it over long distances. I am currently checking in every direction. How can i get the direction the block is facing, so i can check a specific direction?

Link to comment
Share on other sites

29 minutes ago, Shiranai said:

How can i get the direction the block is facing

BlockState#get(Property<T>)

30 minutes ago, Shiranai said:

Yeah, i'm doing that at the moment. It does feel kinda hacky though if you have to do it over long distances.

RayTrace() is going to be worse, because instead of checking at 1 unit distances, it checks at 0.1 unit distances.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 hour ago, Shiranai said:

i always thought raytracing was a pretty resource sparing thing

 

No, no it is not.

https://www.reddit.com/r/raytracing/comments/c08qxz/ray_tracing_is_computationally_expensive_are/

While most "raytracing" things refer to rendering, the same process is applied by physics calculations (of which Minecraft's implementations qualify as). You have to use a very small delta otherwise you're bound to miss corners when moving diagonally at arbitrary angles.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

  • 2 months later...

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.



×
×
  • Create New...

Important Information

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