diff --git a/protocol/src/main/java/mc/protocol/packets/play/server/ChunkDataPacket.java b/protocol/src/main/java/mc/protocol/packets/play/server/ChunkDataPacket.java
index 70ec3a9..ca75325 100644
--- a/protocol/src/main/java/mc/protocol/packets/play/server/ChunkDataPacket.java
+++ b/protocol/src/main/java/mc/protocol/packets/play/server/ChunkDataPacket.java
@@ -160,8 +160,8 @@ public class ChunkDataPacket implements ServerSidePacket {
//
//
- int dataArraySize = _16_16_16 * BITS_PER_BLOCK;
- data.writeVarInt(dataArraySize / Long.SIZE);
+ int dataArraySize = _16_16_16 * BITS_PER_BLOCK / Long.SIZE;
+ data.writeVarInt(dataArraySize);
//
//
diff --git a/protocol/src/main/java/mc/protocol/utils/Bit13LongArray.java b/protocol/src/main/java/mc/protocol/utils/Bit13LongArray.java
index f3041cb..b8add1d 100644
--- a/protocol/src/main/java/mc/protocol/utils/Bit13LongArray.java
+++ b/protocol/src/main/java/mc/protocol/utils/Bit13LongArray.java
@@ -11,8 +11,8 @@ public class Bit13LongArray implements NibbleArray {
private int nibbleIndex = 0;
private int lastWriteIndex = 0;
- public Bit13LongArray(int capacity) {
- this.buffer = ByteBuffer.allocate(capacity);
+ public Bit13LongArray(int longCapacity) {
+ this.buffer = ByteBuffer.allocate(longCapacity * Long.SIZE);
}
@Override
@@ -28,7 +28,7 @@ public class Bit13LongArray implements NibbleArray {
//@formetter:on
if (tailValueIndex != lastWriteIndex) {
- buffer.asLongBuffer().put(longValue);
+ buffer.putLong(longValue);
lastWriteIndex++;
longValue = 0L;
}
@@ -37,7 +37,7 @@ public class Bit13LongArray implements NibbleArray {
nibbleIndex++;
if (headValueIndex != tailValueIndex) {
- buffer.asLongBuffer().put(longValue);
+ buffer.putLong(longValue);
lastWriteIndex++;
longValue = value >> (Long.SIZE - offsetValue);
}
@@ -45,6 +45,6 @@ public class Bit13LongArray implements NibbleArray {
@Override
public ByteBuffer byteBuffer() {
- return this.buffer.rewind();
+ return this.buffer.putLong(longValue).rewind();
}
}
diff --git a/protocol/src/main/java/mc/protocol/utils/HalfByteArray.java b/protocol/src/main/java/mc/protocol/utils/HalfByteArray.java
index ad0192e..d227757 100644
--- a/protocol/src/main/java/mc/protocol/utils/HalfByteArray.java
+++ b/protocol/src/main/java/mc/protocol/utils/HalfByteArray.java
@@ -19,9 +19,9 @@ public class HalfByteArray implements NibbleArray {
}
if (halfValue == null) {
- halfValue = (byte) (value << BITS);
+ halfValue = (byte) (value);
} else {
- buffer.put((byte) (halfValue | value));
+ buffer.put((byte) (halfValue | value << BITS));
halfValue = null;
}
}
@@ -30,7 +30,6 @@ public class HalfByteArray implements NibbleArray {
public ByteBuffer byteBuffer() {
if (halfValue != null) {
buffer.put(halfValue);
- halfValue = null;
}
return this.buffer.rewind();