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

Data parsing from maps #43

Open
antithug opened this issue Jun 13, 2021 · 1 comment
Open

Data parsing from maps #43

antithug opened this issue Jun 13, 2021 · 1 comment

Comments

@antithug
Copy link

I'm using flying-squid and prismarine-web-client to view some existing maps. It's working well for the most part, except that some of the data seems to be missing, and I had to make a change to this package in order for it to work.

The maps I am using is Greefield v0.5.3.

First, the change I made ignores some chunks. Without the change, these chunks to not deserialize correctly on the web client. No data is written for the last section and this throws off the deserializer. Here is the change. This is in chunk.js in the 1.14 dir.

function readSection (chunk, section) {
  if (section.Y >= 0 && section.Y <= 16) {
    let chunkSection = chunk.sections[section.Y]
    if (!chunkSection) {
      chunkSection = new ChunkSection()
      chunk.sections[section.Y] = chunkSection
      chunk.sectionMask |= 1 << section.Y
    }
    // console.log('readSection', section.Y, chunk.sectionMask)

    readPalette(chunkSection, section.Palette)
    // Empty (filled with air) sections can be stored, but make the client crash if
    // they are sent over. Remove them as soon as possible

==> // if (chunkSection.palette.length === 0) console.log('strange chunk section', chunkSection)
==> if (chunkSection.palette.length === 0 || (chunkSection.palette.length === 1 && chunkSection.palette[0] === 0)) {
chunk.sections[section.Y] = null
chunk.sectionMask &= ~(1 << section.Y)
// console.log('empty section', chunk.sectionMask, section.Y)
return
}
readBlocks(chunkSection, section.BlockStates)

The sections with a non null but zero length palette cause problems, so I ignore them. With this fix in, Greenfield renders nicely.

Maybe someone can help me out and point me in the right direction?

@u9g
Copy link
Member

u9g commented Jul 5, 2021

  1. what version is the map made for
  2. what flying squid version were you using?

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

No branches or pull requests

2 participants