mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 15:29:20 -04:00
fix section counting in chunk bulk
This commit is contained in:
parent
00fc8ec051
commit
faae40e0dc
@ -42,7 +42,7 @@ public class PacketChunkBulk implements ClientboundPacket {
|
|||||||
|
|
||||||
|
|
||||||
//chunk
|
//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 totalBytes = 4096 * sections; // 16 * 16 * 16 * sections; Section Width * Section Height * Section Width * sections
|
||||||
int halfBytes = totalBytes / 2; // half bytes
|
int halfBytes = totalBytes / 2; // half bytes
|
||||||
|
|
||||||
|
@ -8,6 +8,13 @@ public class BitByte {
|
|||||||
return bitSet;
|
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) {
|
public static byte getLow4Bits(byte input) {
|
||||||
return (byte) (input & 0xF);
|
return (byte) (input & 0xF);
|
||||||
}
|
}
|
||||||
@ -16,4 +23,14 @@ public class BitByte {
|
|||||||
return (byte) ((input) >> 4 & 0xF);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user