diff --git a/minecraft/__init__.py b/minecraft/__init__.py index 722abed..d037b49 100644 --- a/minecraft/__init__.py +++ b/minecraft/__init__.py @@ -232,6 +232,7 @@ SUPPORTED_MINECRAFT_VERSIONS = { '20w10a': 705, '20w11a': 706, '20w12a': 707, + '20w13a': 708, } # Those Minecraft versions supported by pyCraft which are "release" versions, diff --git a/minecraft/networking/types/basic.py b/minecraft/networking/types/basic.py index 99aeba0..b2b1166 100644 --- a/minecraft/networking/types/basic.py +++ b/minecraft/networking/types/basic.py @@ -253,6 +253,14 @@ class VarIntPrefixedByteArray(Type): socket.send(struct.pack(str(len(value)) + "s", value)) +# https://stackoverflow.com/questions/1604464/twos-complement-in-python +def twos_comp(val, bits): + """compute the 2's complement of int value val""" + if (val & (1 << (bits - 1))) != 0: # if sign bit is set + val = val - (1 << bits) # compute negative value + return val # return positive value as is + + class UUIDIntegerArray(Type): """ Minecraft sends an array of 4 integers to represent the most significant and least significant bits (as longs) of a UUID @@ -263,7 +271,7 @@ class UUIDIntegerArray(Type): def read(file_object): ints = struct.unpack("4i", file_object.read(4 * 4)) packed = struct.pack("qq", player_uuid.bytes) - socket.send(struct.pack("4i", msb & 0xffffffff, msb >> 32, - lsb & 0xffffffff, lsb >> 32)) + socket.send(struct.pack(">4i", msb >> 32, + twos_comp(msb & 0xffffffff, 32), + lsb >> 32, + twos_comp(lsb & 0xffffffff, 32) + ) + ) class TrailingByteArray(Type):