[BUG] world.getTerrainData always returns 0
-
- English
- LordFoobar
- Closed
-
-
Hmm.. I was wondering about this, since the getTerrainData() function should work properly. But I found the issue in this case, "ChunkUtils:getChunkAndBlockPosition()" does not return the expected block position: The x, y and z values of the blockposition have an offset of two (it has technical reasons, since we use this function internally too). I already changed this (the fix will be available with the next update). In the meantime, you could subtract the value "2" from the blockposition as a workaround, like this:
[lua]local terrainId = world:getTerrainData(chunkPos.x, chunkPos.y, chunkPos.z, blockPos.x - 2, blockPos.y - 2, blockPos.z - 2);[/lua] -
Hmm.. I was wondering about this, since the getTerrainData() function should work properly. But I found the issue in this case, "ChunkUtils:getChunkAndBlockPosition()" does not return the expected block position: The x, y and z values of the blockposition have an offset of two (it has technical reasons, since we use this function internally too). I already changed this (the fix will be available with the next update). In the meantime, you could subtract the value "2" from the blockposition as a workaround, like this:
[lua]local terrainId = world:getTerrainData(chunkPos.x, chunkPos.y, chunkPos.z, blockPos.x - 2, blockPos.y - 2, blockPos.z - 2);[/lua]I was wondering why the - 2 as I have seen this at a few places already.
Cheers!
-
dont forget to also add at lest -0.5 onto the y or the plants will look as if they are floating so y will be - 2.5 in the end
-
I'm actually using a "fractal" approach to find the actual correct y value
-
I'm actually using a "fractal" approach to find the actual correct y value
sounds awesome cant wait to see your improved planting script it sounds epic
-
I was wondering why the - 2 as I have seen this at a few places already.
That's because each chunk has room for the edge terraininformation (2 adjacent blocks) of its neighbour chunks (it's necessary for terraingeneration and faceculling). On the one hand it's necessary to generate all chunks at the "end of your view distance" without unnecessary chunk requests from the server, on the other hand it's due to performance reasons (adjacent block lookup is much faster compared to accessing a different chunk, though there is a tiny memory penalty, but the result is worth it^^).
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!