Separate names with a comma.
Comments in 'Plugin Development' started by Asparanc, Aug 7, 2015.
How to get chunkX and chunckY from player position ? It's for a claim system.
I assume you mean chunk x,z as there is no y.
PosX >> 4
PosZ >> 4
You could also divide by 16.
Okay thx and yes Z not Y it's a fail x)
But if the player is in x = 158 z = 115 (not multiple of 16) ot will give the correct
he correct chunkX and chunkZ where the playzr stand ? And all players in the same chunk will get the same chunkX and ChunkZ with :
X >> 4
Z >> 4
>> is a bit shift so it automatically rounds down. It would be slightly faster than a division which may do a float conversion which you then need to cast to int.
Ok i've ask it because it look like so easy ^^ just >> 4 and you have chunkX (or Z) ^^
Exactly because it is easy, that's why they made it 16 blocks per chunk instead of 20 blocks per chunk. Because you can't achieve the same thing with 20. You'll have to divide by 20 and cast to int in that case.
Unless you were using a base-20 computer
You didn't fail at all. Any Voxel based game has 16x16x16 render chunks. Don't forget that Minecraft has a build height of 256 blocks so there are also 16 chunks vertically (Render Chunks).
See the green part. It's an entire chunk. As you can see it has only X and Z coordinates. But if you see in the Hierarchy the chunk has 16 subitems: they are Render Chunks and they are 16x16x16 in size and they have only the Y coordinate (from 0 to 15)