Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@xmcl/world - Chunk corruption fix for palette sizes >=16 #250

Merged
merged 5 commits into from
Jan 14, 2023

Conversation

John-Dean
Copy link
Contributor

@John-Dean John-Dean changed the title /world - Chunk corruption fix for palette sizes >=16 @xmcl/world - Chunk corruption fix for palette sizes >=16 Jan 10, 2023
@John-Dean
Copy link
Contributor Author

Added a second minor commit to support the new Minecraft Chunk format (aliased Palette/BlockStates with block_states.palette and block_states.data respectively)

Added a new exported function to directly export the section's block array directly for non-legacy section formats, otherwise returns a blank array.

Addition of new Minecraft chunk format
Exported ability to get section block array directly
Removal of all old functions
const blockStates = section.BlockStates;
const bitLen = computeBitLen(section.Palette, blockStates);
return seek(blockStates, bitLen, index);
if ("Blocks" in section) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry maybe I missed something,

Added a new exported function to directly export the section's block array directly for non-legacy section formats, otherwise returns a blank array.

Which function do you mean here?

I just want to make sure we still have legacy support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries I should have been more clear.

When it detects a new chunk format (not the legacy one) it uses getSectionBlockIdArray to get the block id array (variable was previously called vector).

I have also marked this function as exported so you can choose to use this directly.

This should be a non-breaking change that both maintains backwards support with older versions, fixes the chunk corruption and adds the new exported function getSectionBlockIdArray useable on sections with a non-legacy format.

Please let me know if this doesn't make sense.

Copy link
Collaborator

@ci010 ci010 Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries I should have been more clear.

When it detects a new chunk format (not the legacy one) it uses getSectionBlockIdArray to get the block id array (variable was previously called vector).

I have also marked this function as exported so you can choose to use this directly.

This should be a non-breaking change that both maintains backwards support with older versions, fixes the chunk corruption and adds the new exported function getSectionBlockIdArray useable on sections with a non-legacy format.

Please let me know if this doesn't make sense.

Sure, let's update the branch with master and run tests for it. As long as the old tests for 1.12.2 and 1.14.4 don't fail, it will be totally ok for me.

@ci010
Copy link
Collaborator

ci010 commented Jan 12, 2023

Also, can you add new test files (.mca) under mock/saves/<your-tested-version>? With test file, we can later refactor code with knowledge that if the change is breaking the old test.

You just need a single chunk r.0.0.mca (or more mca file if you need, but please keep size minimal) and the mock.txt which contains the actual block data from Minecraft there.

To generate the mock.txt (containing the dump data). You can run following script in MinecraftForge environment for your test level. https://gist.github.com/ci010/27415d55a3e72399924433b759924f2e

@John-Dean
Copy link
Contributor Author

Hu @ci010 I've merged the master branch with this and I've added in some test .mca files - but I have no idea how to generate the mock.txt files (I've never used Forge and upon installing it I couldn't work out how to run the .java file you provided).

I've explicitly made sure the test regions have >16 types of block in at least 1 region so we can test the palette corruption fixes.

Can you either generate the mock.txt file or post a walkthrough of how to generate them?

Thanks,
John

@ci010
Copy link
Collaborator

ci010 commented Jan 14, 2023

Hu @ci010 I've merged the master branch with this and I've added in some test .mca files - but I have no idea how to generate the mock.txt files (I've never used Forge and upon installing it I couldn't work out how to run the .java file you provided).

I've explicitly made sure the test regions have >16 types of block in at least 1 region so we can test the palette corruption fixes.

Can you either generate the mock.txt file or post a walkthrough of how to generate them?

Thanks, John

Sure, let me add the mock.txt files then

@ci010 ci010 merged commit 55493a8 into Voxelum:master Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants