I have a pretty technical question about Minecraft,
So I'm building a Minecraft server wrapper, and want to add an option to edit the world when the server is offline. That means messing with the save file. I have managed to make it work for 1.8 because the blocks were saved as a list of IDs, but in 1.19 the blocks are saved in a palette (which I understand) and a data array, I understand the data it stores (indices that point to the palette), But I don't understand how to extract (I was able to do it but only by copy-paste) and modify data in there. I really want to understand the mechanics behind it so I can do it myself, I am aware that there are other libs that do that but I want to learn how to do it myself. I have tried different approaches, the most official one I tried is this wiki article:
Chunk Format - wiki.vg[
^] but it seemed to not work.
The question in more detail can be found here:
https://stackoverflow.com/questions/76440587/how-do-i-read-the-data-section-in-chunk-data-minecraft
What I have tried:
1. Tried to take each 4 bits of a long and shift them 8 and 4 bits to the left or right (all combs didn't work)
2. Tried taking 4 bits of each long and putting it inside a nibble function:
def nibble(byte_array, index):
value = byte_array[index // 2]
if index % 2:
return (value >> 4) &0x0F
else:
return value & 0x0F
3. Tried taking the HEX value of the bits and somehow convert it to a number.
No approach from the above worked...
P.S. If you need the code from the WIKI tell me, I couldn't find it but if you need it I'll write it again.