Archived
0

fix: NetOutputStream.writeVarInt()

This commit is contained in:
2018-08-04 15:10:51 +03:00
parent 3750b1340d
commit 4206354760

View File

@@ -14,17 +14,16 @@ import java.util.UUID;
public abstract class NetOutputStream_p340 extends NetOutputStream { public abstract class NetOutputStream_p340 extends NetOutputStream {
@Override @Override
public void writeVarInt(int value) { public void writeVarInt(int value) {
do { while ((value & -128) != 0) {
byte temp = (byte)(value & 0b01111111); writeByte(value & 127 | 128);
// Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
value >>>= 7; value >>>= 7;
if (value != 0) {
temp |= 0b10000000;
} }
writeByte(temp);
} while (value != 0); writeByte(value);
} }
@Override @Override
public void writeString(String value) { public void writeString(String value) {
if (value.length() > Short.MAX_VALUE) { if (value.length() > Short.MAX_VALUE) {