Posted March 1, 20205 yr 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 March 2, 20205 yr by Shiranai Solved
March 1, 20205 yr 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.
March 2, 20205 yr Author 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?
March 2, 20205 yr 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.
March 2, 20205 yr Author 2 minutes ago, Draco18s said: RayTrace() is going to be worse, because instead of checking at 1 unit distances, it checks at 0.1 unit distances. Oh, i always thought raytracing was a pretty resource sparing thing. Thanks
March 2, 20205 yr 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.
May 6, 20205 yr I managed to do it this way. It's kinda messy but hopefully it will help you. https://pastebin.com/Q0mVsJRi RayTraceUtil.getTargetBlock(player, world, maxdistance) This should give you the block you are looking at. I'm new to modding so I'm not shure how correct this is. Edited May 6, 20205 yr by Zagreo added link
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.