Jump to content

Recommended Posts

Posted

I am working on a mod for mc 1.18.2 that allows multiple smaller blocks to be combined in a single blockspace.
To do this I have created a block with block entity, where the block entity stores the blockstates of the smaller blocks that make up the bigger combined block.

In order to add additional (small) blocks to an existing combined block I want to check if the block Im trying to add itersects/overlaps with any part of the existing combined block it it were added.

I am trying to do this by comparing the VoxelShapes of the two blockstate with each other, but I cannot figure out how to do this.

How can I compare two VoxelShapes with each other?

It is enough if I can check somehow if two VoxelShapes are equal, but this does not appear to be possible...

I have tried using

shape1.equals(shape2)

as well as

shape1 == shape2

Both of these do not seem to return true, if the shapes are equal.
I have looked into the VoxelShape class and the DiscreteVoxelShape class, as well as the Shapes clasee, but was not able to find anything that would help me in comparing two VoxelShapes.

Posted

After doing some more testing, I determined that comparing two VoxelShapes never returns true, even if I compare a variable of type VoxelShape with itself it returns false.

I was able to circumvent this by calling toAabbs() on both VoxelShapes and comparing the resulting lists of AABBs using the .equals method. This works correctly as far as I can tell.

So instead of

shape1 == shape2

I now use

shape1.toAabbs().equals(shape2.toAabbs())

 

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.