mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 18:34:56 -04:00
remove high and low bit set functions
This commit is contained in:
parent
e4fa1c0fd0
commit
d5278488e5
@ -60,8 +60,8 @@ public class PacketMapData implements ClientboundPacket {
|
||||
length--; // minus the dataData
|
||||
for (int i = 0; i < length / 3; i++) { // loop over all sets ( 1 set: 3 bytes)
|
||||
byte data = buffer.readByte();
|
||||
byte type = BitByte.getLow4Bits(data);
|
||||
MapPlayerDirection direction = MapPlayerDirection.byId(BitByte.getHigh4Bits(data));
|
||||
byte type = (byte) (data & 0xF);
|
||||
MapPlayerDirection direction = MapPlayerDirection.byId(data >>> 4);
|
||||
byte x = buffer.readByte();
|
||||
byte z = buffer.readByte();
|
||||
pins.add(new MapPinSet(MapPinType.byId(type), direction, x, z));
|
||||
@ -89,9 +89,9 @@ public class PacketMapData implements ClientboundPacket {
|
||||
byte x = buffer.readByte();
|
||||
byte z = buffer.readByte();
|
||||
if (buffer.getVersion().getVersionNumber() >= ProtocolVersion.VERSION_1_12_2.getVersionNumber()) {
|
||||
pins.add(new MapPinSet(MapPinType.byId(BitByte.getHigh4Bits(directionAndType)), MapPlayerDirection.byId(BitByte.getLow4Bits(directionAndType)), x, z));
|
||||
pins.add(new MapPinSet(MapPinType.byId(directionAndType >>> 4), MapPlayerDirection.byId(directionAndType & 0xF), x, z));
|
||||
} else {
|
||||
pins.add(new MapPinSet(MapPinType.byId(BitByte.getLow4Bits(directionAndType)), MapPlayerDirection.byId(BitByte.getHigh4Bits(directionAndType)), x, z));
|
||||
pins.add(new MapPinSet(MapPinType.byId(directionAndType & 0xF), MapPlayerDirection.byId(directionAndType >>> 4), x, z));
|
||||
}
|
||||
}
|
||||
short columns = BitByte.byteToUShort(buffer.readByte());
|
||||
|
@ -34,14 +34,6 @@ public class BitByte {
|
||||
return bitSet;
|
||||
}
|
||||
|
||||
public static byte getLow4Bits(byte input) {
|
||||
return (byte) (input & 0xF);
|
||||
}
|
||||
|
||||
public static byte getHigh4Bits(byte input) {
|
||||
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
|
||||
|
@ -63,16 +63,16 @@ public class ChunkUtil {
|
||||
// get block meta and shift and add (merge) id if needed
|
||||
if (arrayPos % 2 == 0) {
|
||||
// high bits
|
||||
singleMeta = BitByte.getLow4Bits(meta[arrayPos / 2]);
|
||||
singleMeta = (byte) (meta[arrayPos / 2] & 0xF);
|
||||
if (BitByte.isBitSet(addBitMask, c)) {
|
||||
singeBlockId = (short) ((singeBlockId << 4) | BitByte.getHigh4Bits(addBlockTypes[arrayPos / 2]));
|
||||
singeBlockId = (short) ((singeBlockId << 4) | (addBlockTypes[arrayPos / 2] >>> 4));
|
||||
}
|
||||
} else {
|
||||
// low 4 bits
|
||||
singleMeta = BitByte.getHigh4Bits(meta[arrayPos / 2]);
|
||||
singleMeta = (byte) (meta[arrayPos / 2] >>> 4);
|
||||
|
||||
if (BitByte.isBitSet(addBitMask, c)) {
|
||||
singeBlockId = (short) ((singeBlockId << 4) | BitByte.getLow4Bits(addBlockTypes[arrayPos / 2]));
|
||||
singeBlockId = (short) ((singeBlockId << 4) | (addBlockTypes[arrayPos / 2] & 0xF));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user