Voxelmetric / Voxelmetric1

Legacy Voxelmetric framework
Other
251 stars 96 forks source link

Check free blocks around a block #37

Closed Dalez closed 9 years ago

Dalez commented 9 years ago

I'm not sure if there is this feature already, but it would be a good feature to check what blocks are free around a certain block. For instance, if you Raycast onto a block, it would return the blocks next to it that would be free. For example: xxx xBx xyy

B = Block x = There is no block here (well, there is air) y = There is a block here

It would be cool to have a feature for only "air" and also to return all blocks. You could then check if the block is free, and add a block next to it (I'm planning on this for farming).

Would be nice to have this with the random update/schedule system that is being made now too.

alex-irt commented 9 years ago

Hey @Dalez you can do this using the GetBlockPos and GetBlock, I don't think a specific helper function is needed though because it's not that common a use case. You can use GetBlockPos with a raycast to get the position of the block you're pointing at and then in a for loop get all the blocks around it. Here's a gist that might do what you're wanting: https://gist.github.com/AlexSTV/2f061e0b1ebdb0581132

Dalez commented 9 years ago

Awesome! I did think that there was a way to do it, but I couldn't figure it out (as it wasn't getting the correct values for some reason).

I'll use the code above and see if this is suitable. Thanks!