поправка к работе NibbleArray
This commit is contained in:
@@ -160,8 +160,8 @@ public class ChunkDataPacket implements ServerSidePacket {
|
|||||||
// </Palette>
|
// </Palette>
|
||||||
|
|
||||||
// <Data Array Length>
|
// <Data Array Length>
|
||||||
int dataArraySize = _16_16_16 * BITS_PER_BLOCK;
|
int dataArraySize = _16_16_16 * BITS_PER_BLOCK / Long.SIZE;
|
||||||
data.writeVarInt(dataArraySize / Long.SIZE);
|
data.writeVarInt(dataArraySize);
|
||||||
// </Data Array Length>
|
// </Data Array Length>
|
||||||
|
|
||||||
// <Data Array>
|
// <Data Array>
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ public class Bit13LongArray implements NibbleArray {
|
|||||||
private int nibbleIndex = 0;
|
private int nibbleIndex = 0;
|
||||||
private int lastWriteIndex = 0;
|
private int lastWriteIndex = 0;
|
||||||
|
|
||||||
public Bit13LongArray(int capacity) {
|
public Bit13LongArray(int longCapacity) {
|
||||||
this.buffer = ByteBuffer.allocate(capacity);
|
this.buffer = ByteBuffer.allocate(longCapacity * Long.SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -28,7 +28,7 @@ public class Bit13LongArray implements NibbleArray {
|
|||||||
//@formetter:on
|
//@formetter:on
|
||||||
|
|
||||||
if (tailValueIndex != lastWriteIndex) {
|
if (tailValueIndex != lastWriteIndex) {
|
||||||
buffer.asLongBuffer().put(longValue);
|
buffer.putLong(longValue);
|
||||||
lastWriteIndex++;
|
lastWriteIndex++;
|
||||||
longValue = 0L;
|
longValue = 0L;
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ public class Bit13LongArray implements NibbleArray {
|
|||||||
nibbleIndex++;
|
nibbleIndex++;
|
||||||
|
|
||||||
if (headValueIndex != tailValueIndex) {
|
if (headValueIndex != tailValueIndex) {
|
||||||
buffer.asLongBuffer().put(longValue);
|
buffer.putLong(longValue);
|
||||||
lastWriteIndex++;
|
lastWriteIndex++;
|
||||||
longValue = value >> (Long.SIZE - offsetValue);
|
longValue = value >> (Long.SIZE - offsetValue);
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,6 @@ public class Bit13LongArray implements NibbleArray {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ByteBuffer byteBuffer() {
|
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) {
|
if (halfValue == null) {
|
||||||
halfValue = (byte) (value << BITS);
|
halfValue = (byte) (value);
|
||||||
} else {
|
} else {
|
||||||
buffer.put((byte) (halfValue | value));
|
buffer.put((byte) (halfValue | value << BITS));
|
||||||
halfValue = null;
|
halfValue = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,6 @@ public class HalfByteArray implements NibbleArray {
|
|||||||
public ByteBuffer byteBuffer() {
|
public ByteBuffer byteBuffer() {
|
||||||
if (halfValue != null) {
|
if (halfValue != null) {
|
||||||
buffer.put(halfValue);
|
buffer.put(halfValue);
|
||||||
halfValue = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.buffer.rewind();
|
return this.buffer.rewind();
|
||||||
|
|||||||
Reference in New Issue
Block a user