tutorial:pixel_raycast
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:pixel_raycast [2020/08/26 08:22] – [General case: Arbitrary pixel] Updated to use RayCast instead of RayTrace snakefangox | tutorial:pixel_raycast [2023/11/30 22:33] (current) – [For arbitrary reach] Naming fix famrofexl | ||
---|---|---|---|
Line 34: | Line 34: | ||
==== For arbitrary reach ==== | ==== For arbitrary reach ==== | ||
- | The code above allows for the normal reach, 3 blocks for survival and 4.5 in creative. If you want the raycast to reach farther you need to use the general case below. | + | The code above allows for the normal reach, 3 blocks for survival and 4.5 in creative. If you want the raycast to reach farther you need to replace <code java> HitResult hit = client.crosshairTarget;</ |
+ | |||
+ | <code java [enable_line_numbers=" | ||
+ | double maxReach = 1000; //The farthest target the cameraEntity can detect | ||
+ | float tickDelta = 1.0F; //Used for tracking animation progress; no tracking is 1.0F | ||
+ | boolean includeFluids = true; //Whether to detect fluids as blocks | ||
+ | |||
+ | HitResult hit = client.cameraEntity.raycast(maxReach, | ||
+ | </ | ||
===== General case: Arbitrary pixel ===== | ===== General case: Arbitrary pixel ===== | ||
Line 191: | Line 199: | ||
==== Performance considerations ==== | ==== Performance considerations ==== | ||
- | This is EXPENSIVE, if you do it too many times, it WILL get slow. Especially for long reaches. If you *need* to do many raycasts in a single frame, [[https:// | + | This is EXPENSIVE, if you do it too many times, it WILL get slow. Especially for long reaches. If you **need** to do many raycasts in a single frame, [[https:// |
tutorial/pixel_raycast.txt · Last modified: 2023/11/30 22:33 by famrofexl