mcworldlib icon indicating copy to clipboard operation
mcworldlib copied to clipboard

Support parsing block_states with version greater than 1.18

Open suzakuwcx opened this issue 1 year ago • 7 comments

Fix relate issue: #10, cite: https://minecraft.wiki/w/Chunk_format

But in contrast, this pr will cause that deprecating the support for old versions. So maybe creating a new branch is a better idea?

image

suzakuwcx avatar Jul 04 '24 14:07 suzakuwcx

Thank you, this is such a welcome contribution!

Btw, is the difference only in the capitalization of names (sections vs Sections) or were there other structural changes? If it is, it might be easy to create a unified get_blocks() that is compatible with both the old and the new standard. Even some minor structural changes (palette / data being under block_state or directly in Sections) might be handled without too complex logic.

If not, I'd prefer the old function to remain intact, possibly provisionally renamed as get_blocks_old(), remove any compatibility logic in get_blocks(), and add documentation (as docstrings or plain comments) on which game versions each one operates.

In the future, if desired, get_blocks() may become a wrapper that automatically chooses the appropriate function based on the actual save file version.

MestreLion avatar Sep 29 '24 05:09 MestreLion

Also, would you mind adding a "Fix #10" suffix to the commit message so that bug is properly closed and linked to this fix?

MestreLion avatar Sep 29 '24 05:09 MestreLion

Thanks, I would try your suggestion to make backward compatible and update suffix.

About difference, it is not the only capitalization, base on my experiment on 1.21 and wiki description, the different is:

  • Name change: "section" -> "Section", "BlockStates" -> "block_states", "Palette" -> "palette"
  • Structure change: "palette" now is under "block_state" (before is under "section")
  • If only one block in "palette", the "data" field will be remove
  • sometime a strange "Y=-5" Section will appear and this is useless

suzakuwcx avatar Sep 29 '24 13:09 suzakuwcx

Now I modify get_blocks() as a wrapper and it will choose correct function to parse

I test the test case and now they goes well

blocks() image

pretty() image

suzakuwcx avatar Oct 10 '24 02:10 suzakuwcx

When is this getting merged? I would love to see this implemented, as there are currently no working MC world manipulation python libraries.

SorkoPiko avatar Nov 13 '24 20:11 SorkoPiko

@SorkoPiko

When is this getting merged? I would love to see this implemented, as there are currently no working MC world manipulation python libraries.

I didn't have the time to properly review or test it yet. The new block state format changes more than just renaming/reorganizing keys in the NBT structure, and this PR also deals with backward-compatibility at run time, so not very trivial. If anyone can/wants to test this, or even step up as a co-maintainer of this project, I would appreciate!

MestreLion avatar Nov 23 '24 03:11 MestreLion

To anyone in the future: PR seems to work for 1.21.8. (atleast the few methods I tested), recommend just cloning and replacing your current mcworldlib folder with the one from suzaku's repo

corgi-in-tights avatar Aug 22 '25 18:08 corgi-in-tights