package protocolsupport.protocol.legacyremapper.chunk;

import io.netty.buffer.ByteBuf;
import protocolsupport.api.ProtocolVersion;
import protocolsupport.protocol.typeremapper.id.IdRemapper;
import protocolsupport.protocol.typeremapper.id.RemappingTable.ArrayBasedIdRemappingTable;
import protocolsupport.utils.netty.Allocator;
import protocolsupport.utils.netty.ChannelUtils;

public class ChunkTransformerVaries extends ChunkTransformer {

	protected static final int bitsPerBlock_19_110 = 13;

	@Override
	protected byte[] toLegacyData0(ProtocolVersion version) {
		ArrayBasedIdRemappingTable table = IdRemapper.BLOCK.getTable(version);
		ByteBuf chunkdata = Allocator.allocateBuffer();
		try {
			for (int i = 0; i < columnsCount; i++) {
				ChunkSection section = sections[i];
				chunkdata.writeByte(bitsPerBlock_19_110);
				ChannelUtils.writeVarInt(chunkdata, 0);
				BlockStorageReader storage = section.blockdata;
				BlockStorageWriter blockstorage = new BlockStorageWriter(bitsPerBlock_19_110, blocksInSection);
				for (int block = 0; block < blocksInSection; block++) {
					blockstorage.setBlockState(block, table.getRemap(storage.getBlockState(block)));
				}
				long[] ldata = blockstorage.getBlockData();
				ChannelUtils.writeVarInt(chunkdata, ldata.length);
				for (long l : ldata) {
					chunkdata.writeLong(l);
				}
				chunkdata.writeBytes(section.blocklight);
				if (hasSkyLight) {
					chunkdata.writeBytes(section.skylight);
				}
			}
			if (hasBiomeData) {
				chunkdata.writeBytes(biomeData);
			}
			return ChannelUtils.toArray(chunkdata);
		} finally {
			chunkdata.release();
		}
	}

}

@@ -477,22 +477,26 @@
 erBlock_
+_1_9__
 1
-9
 _11
-0
  = 13;%0A%0A
@@ -817,22 +817,26 @@
 erBlock_
+_1_9__
 1
-9
 _11
-0
 );%0A%09%09%09%09C
@@ -1004,14 +1004,18 @@
 ock_
+_1_9__
 1
-9
 _11
-0
 , bl

Rename variable