fix section counting in chunk bulk

This commit is contained in:
bixilon 2020-06-05 22:43:40 +02:00
parent 00fc8ec051
commit faae40e0dc
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 18 additions and 1 deletions

View File

@ -42,7 +42,7 @@ public class PacketChunkBulk implements ClientboundPacket {
//chunk
byte sections = (byte) Integer.bitCount(sectionBitMask);
byte sections = BitByte.getBitCount(sectionBitMask);
int totalBytes = 4096 * sections; // 16 * 16 * 16 * sections; Section Width * Section Height * Section Width * sections
int halfBytes = totalBytes / 2; // half bytes

View File

@ -8,6 +8,13 @@ public class BitByte {
return bitSet;
}
public static boolean isBitSetShort(short in, int pos) {
boolean bitSet;
int mask = 1 << pos;
bitSet = ((in & mask) == mask);
return bitSet;
}
public static byte getLow4Bits(byte input) {
return (byte) (input & 0xF);
}
@ -16,4 +23,14 @@ public class BitByte {
return (byte) ((input) >> 4 & 0xF);
}
public static byte getBitCount(short input) {
byte ret = 0;
for (int i = 0; i < Short.BYTES * 8; i++) { // bytes to bits
if (isBitSetShort(input, i)) {
ret++;
}
}
return ret;
}
}