diff --git a/aiocraft/mc/mctypes.py b/aiocraft/mc/mctypes.py index 7a57c0e..bac6fd0 100644 --- a/aiocraft/mc/mctypes.py +++ b/aiocraft/mc/mctypes.py @@ -62,6 +62,15 @@ class VarInt(Type): _pytype : type = int _maxBytes = 5 + @classmethod + async def read(cls, stream: asyncio.StreamReader) -> int: + buf = 0b10000000 + off = 0 + while (buf & 0b0000000) != 0: + buf |= (await stream.read(1)) >> (7*off) + off += 1 + return buf + @classmethod def serialize(cls, data:int) -> bytes: res : bytearray = bytearray()