поправка к работе NibbleArray
This commit is contained in:
@@ -160,8 +160,8 @@ public class ChunkDataPacket implements ServerSidePacket {
|
||||
// </Palette>
|
||||
|
||||
// <Data Array Length>
|
||||
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);
|
||||
// </Data Array Length>
|
||||
|
||||
// <Data Array>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user