Giter Site home page Giter Site logo

Comments (4)

Querz avatar Querz commented on June 12, 2024

setPaletteIndex does not change the size of the blockStates array (as stated in the javadoc). You will have to know its size beforehand or adjust its size manually.

from nbt.

toddharrison avatar toddharrison commented on June 12, 2024

So if set it to the max number of blocks, will it reduce when I run the cleanup or will I need to do that as well? I suppose I could also do preprocessing, but I was doing it in a streaming manner instead for performance.

from nbt.

Querz avatar Querz commented on June 12, 2024

You could set the initial length of the blockStates to its maximum length (4096) and at the end after creating a new Section object call cleanupPaletteAndBlockStates, but then you could also just set the palette indexes manually without using setPaletteIndex, something like this:

CompoundTag sectionData = new CompoundTag();
long[] blockStates = new long[4096];
ListTag<CompoundTag> palette = new ListTag<>(CompoundTag.class);

for (int index = 0; index < 4096; index++) {
  // calculate paletteIndex here
  blockStates[index] = paletteIndex; // setting palette index manually
}

sectionData.put("Palette", palette);
sectionData.put("BlockStates", blockStates);

Section section = new Section(sectionData, 2584);
section.cleanupPaletteAndBlockStates();

from nbt.

toddharrison avatar toddharrison commented on June 12, 2024

Thanks! Giving it a shot. Want me to close this?

from nbt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.