Jump to content

Recommended Posts

Posted (edited)

I'm able to successfully find the first block along a ray by using this line:

HitResult hitResult = MC.level.clip(new ClipContext(vectorNear, vectorFar, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, null));

However, while there is an option to include ClipContext.Fluid.NONE to ignore fluid blocks like water and lava, there isn't a similar one to ignore non-solid blocks such as grass, flowers, etc.

Is there a way to achieve the same outcome but ignore these blocks? I am able to tell if a particular block is solid or not using this line:

Minecraft.level.getBlockState(blockPos).getMaterial().isSolidBlocking()

EDIT: to clarify, I want to get the next solid block BEHIND the non-solid one, using Fluid.NONE instead causes it to return nothing

Edited by SoLegendary
clarify goal
Posted
1 hour ago, SoLegendary said:
ClipContext.Block.OUTLINE

change the ClipContext.Block, since OUTLINE use the default VoxelShape, if you want to ignore non-solid Blocks you can use COLLIDER it use the collision VoxelShape

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.