untitled paste

unlisted ⁨1⁩ ⁨file⁩ 2021-07-12 00:52:56 UTC

pastefile1

Raw
        for (int storageReadIndex = 0; storageReadIndex < storageSize; storageReadIndex++) {
            byte paletteHeader = byteBuf.readByte();
            int paletteVersion = (paletteHeader | 1) >> 1;
            BitArrayVersion bitArrayVersion = BitArrayVersion.get(paletteVersion, true);

            int maxBlocksInSection = 4096;
            BitArray bitArray = bitArrayVersion.createPalette(maxBlocksInSection);
            int wordsSize = bitArrayVersion.getWordsForSize(maxBlocksInSection);

            for (int wordIterationIndex = 0; wordIterationIndex < wordsSize; wordIterationIndex++) {
                int word = byteBuf.readIntLE();
                bitArray.getWords()[wordIterationIndex] = word;
            }

            int paletteSize = VarInts.readInt(byteBuf);
            int[] sectionPalette = new int[paletteSize];
            for (int i = 0; i < paletteSize; i++) {
                int id = VarInts.readInt(byteBuf);
                sectionPalette[i] = id;
            }
            
            int index = 0;
            for (int x = 0; x < 16; x++) {
                for (int z = 0; z < 16; z++) {
                    for (int y = 0; y < 16; y++) {
                        int paletteIndex = bitArray.get(index);
                        int bedrockRuntimeId = sectionPalette[paletteIndex];
                        if (bedrockRuntimeId != BlockStateTranslator.AIR_BEDROCK_BLOCK_ID) {
                            chunk.set(x, y, z, BlockStateTranslator.BEDROCK_RUNTIME_ID_TO_JAVA_ID.get(bedrockRuntimeId));
                        }
                        index++;
                    }
                }
            }
        }