Archived
0

Sonar: [squid:S3776] make the method easier

This commit is contained in:
2019-02-11 15:12:41 +03:00
parent 3a25bc34f4
commit 96a69f1bca

View File

@@ -268,7 +268,7 @@ public class ChunkDataPacket implements SCPacket {
this.skyLight.set(bx, by, bz, skyLight); this.skyLight.set(bx, by, bz, skyLight);
} }
void writeToNetStream(final NetOutputStream netOutputStream) { private int getBitsPerBlock() {
int bitsPerBlock = 4; int bitsPerBlock = 4;
if (palette.size() > 15) { if (palette.size() > 15) {
if (palette.size() <= 31) if (palette.size() <= 31)
@@ -281,15 +281,12 @@ public class ChunkDataPacket implements SCPacket {
bitsPerBlock = 8; bitsPerBlock = 8;
} }
// <Palette> return bitsPerBlock;
netOutputStream.writeUnsignedByte(bitsPerBlock); // Bits Per Block }
netOutputStream.writeVarInt(palette.size()); // Size of palette
palette.forEach(netOutputStream::writeVarInt); // Palette private void writePalette(final int bitsPerBlock,
// </Palette> final NetOutputStream netOutputStream) {
// <Data Array>
final int dataLength = (4096/*16*16*16*/ * bitsPerBlock) / 64/*size of long in bits*/;
netOutputStream.writeVarInt(dataLength); // Size of Data Array
// <Array>
long value = 0; long value = 0;
int lastPos = 0; int lastPos = 0;
boolean fairy = false; boolean fairy = false;
@@ -324,6 +321,21 @@ public class ChunkDataPacket implements SCPacket {
} }
} }
netOutputStream.writeLong(value); netOutputStream.writeLong(value);
}
void writeToNetStream(final NetOutputStream netOutputStream) {
final int bitsPerBlock = getBitsPerBlock();
// <Palette>
netOutputStream.writeUnsignedByte(bitsPerBlock); // Bits Per Block
netOutputStream.writeVarInt(palette.size()); // Size of palette
palette.forEach(netOutputStream::writeVarInt); // Palette
// </Palette>
// <Data Array>
final int dataLength = (4096/*16*16*16*/ * bitsPerBlock) / 64/*size of long in bits*/;
netOutputStream.writeVarInt(dataLength); // Size of Data Array
// <Array>
writePalette(bitsPerBlock, netOutputStream);
// </Array> // </Array>
// </Data Array> // </Data Array>
// <Block Light> // <Block Light>