diff --git a/src/main/java/org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java b/src/main/java/org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java index af2e051b..9c71c128 100644 --- a/src/main/java/org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java +++ b/src/main/java/org/spacehq/packetlib/io/buffer/ByteBufferNetInput.java @@ -77,17 +77,17 @@ public class ByteBufferNetInput implements NetInput { @Override public long readVarLong() throws IOException { - int value = 0; + long value = 0; int size = 0; int b; while(((b = this.readByte()) & 0x80) == 0x80) { - value |= (b & 0x7F) << (size++ * 7); + value |= (long) (b & 0x7F) << (size++ * 7); if(size > 10) { throw new IOException("VarLong too long (length must be <= 10)"); } } - return value | ((b & 0x7F) << (size * 7)); + return value | ((long) (b & 0x7F) << (size * 7)); } @Override diff --git a/src/main/java/org/spacehq/packetlib/io/stream/StreamNetInput.java b/src/main/java/org/spacehq/packetlib/io/stream/StreamNetInput.java index 69d1d1b4..3433f4fe 100644 --- a/src/main/java/org/spacehq/packetlib/io/stream/StreamNetInput.java +++ b/src/main/java/org/spacehq/packetlib/io/stream/StreamNetInput.java @@ -93,17 +93,17 @@ public class StreamNetInput implements NetInput { @Override public long readVarLong() throws IOException { - int value = 0; + long value = 0; int size = 0; int b; while(((b = this.readByte()) & 0x80) == 0x80) { - value |= (b & 0x7F) << (size++ * 7); + value |= (long) (b & 0x7F) << (size++ * 7); if(size > 10) { throw new IOException("VarLong too long (length must be <= 10)"); } } - return value | ((b & 0x7F) << (size * 7)); + return value | ((long) (b & 0x7F) << (size * 7)); } @Override