Jump to content

Recommended Posts

Posted

Since 1.15 introduced a lot of significant changes as opposed to 1.12, I cannot figure out how to RayTrace an entity from a range further than what pointedEntity allows (~4 blocks)

I am able to raytrace blocks from an increased range using BlockRayTraceResult, but I am unsure how to apply this to entities. I want to be able to target an entity from a range of about 50 blocks.

Please let me know where to start. Thank You.

 

Posted

Howdy

Have you looked at ProjectileHelper::rayTraceEntities? 

You should be able to adapt the code in there to do what you want.  50 blocks is a very long way,though.   It might be more efficient to use a different algorithm which filters entities manually, i.e.

for each entity in world {

vec3d entityPosition = entity - origin

check if position is in the correct octant (x +ve or -ve, y +ve or -ve, z + or -ve etc)

if so {

  vec3d distanceFromEntityToRay = cross product (position, ray) / norm (ray)

  if distanceFromEntityToRay < 5 then include in detailed raytrace otherwise exclude

}

}

you'll need to know a bit of vector math to do that...

 

-TGG

 

 

Posted (edited)

hmm the code i used in my old mod came from the source code of a different mod, but im not sure if it can be adapted to 1.15, i believe it involved vector math aswell might have to give it a go 
Thank you for the pointers though!

 

Edit: Found some code from another mod that I believe I can adapt to my specific use case

Edited by -TheLittleGuy

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.

Announcements



×
×
  • Create New...

Important Information

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