Write linear palette as map palette for now

This commit is contained in:
Nassim Jahnke 2021-09-16 12:17:21 +02:00
parent bfe6389377
commit eaa18f569a
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 17 additions and 14 deletions

View File

@ -101,13 +101,18 @@ public class ChunkSectionType1_18 extends Type<ChunkSection> {
}
private void writePalette(final ByteBuf buffer, final DataPalette palette) {
int bitsPerValue = 0;
while (palette.size() > 1 << bitsPerValue) {
bitsPerValue += 1;
}
int bitsPerValue;
if (palette.size() > 1) {
bitsPerValue = palette.type() == PaletteType.BLOCKS ? 4 : 2; //TODO implement linear palette
while (palette.size() > 1 << bitsPerValue) {
bitsPerValue += 1;
}
if (bitsPerValue > palette.type().highestBitsPerValue()) {
bitsPerValue = GLOBAL_PALETTE;
if (bitsPerValue > palette.type().highestBitsPerValue()) {
bitsPerValue = GLOBAL_PALETTE;
}
} else {
bitsPerValue = 0;
}
buffer.writeByte(bitsPerValue);

View File

@ -105,14 +105,6 @@ public final class WorldPackets {
handler(wrapper -> {
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
final Chunk oldChunk = wrapper.read(new Chunk1_17Type(tracker.currentWorldSectionHeight()));
/*for (int s = 0; s < chunk.getSections().length; s++) {
ChunkSection section = chunk.getSections()[s];
if (section == null) continue;
for (int i = 0; i < section.getPaletteSize(); i++) {
int old = section.getPaletteEntry(i);
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
}
}*/
final List<BlockEntity> blockEntities = new ArrayList<>(oldChunk.getBlockEntities().size());
for (final CompoundTag tag : oldChunk.getBlockEntities()) {
@ -143,6 +135,12 @@ public final class WorldPackets {
final DataPaletteImpl blockPalette = new DataPaletteImpl(PaletteType.BLOCKS);
blockPalette.addEntry(0);
section.addPalette(blockPalette);
} else {
/*final DataPalette blockpalette = section.palette(PaletteType.BLOCKS);
for (int j = 0; j < blockpalette.size(); j++) {
final int old = blockpalette.entry(j);
blockpalette.setEntry(j, protocol.getMappingData().getNewBlockStateId(old));
}*/
}
// Fill biome palette