From 8a098b399b40967d672b6d5db448d28f09b4bfa8 Mon Sep 17 00:00:00 2001 From: Sillyfrog Date: Thu, 13 Aug 2020 22:19:04 +1000 Subject: [PATCH] Support for v1.16.2 --- minecraft/__init__.py | 1 + .../packets/clientbound/play/__init__.py | 23 +++++++++++++------ .../clientbound/play/block_change_packet.py | 3 ++- .../clientbound/play/combat_event_packet.py | 3 ++- .../clientbound/play/explosion_packet.py | 3 ++- .../clientbound/play/face_player_packet.py | 3 ++- .../packets/clientbound/play/map_packet.py | 3 ++- .../play/player_list_item_packet.py | 3 ++- .../play/player_position_and_look_packet.py | 3 ++- 9 files changed, 31 insertions(+), 14 deletions(-) diff --git a/minecraft/__init__.py b/minecraft/__init__.py index 6419504..db169c0 100644 --- a/minecraft/__init__.py +++ b/minecraft/__init__.py @@ -249,6 +249,7 @@ SUPPORTED_MINECRAFT_VERSIONS = { '1.16 Release Candidate 1':734, '1.16': 735, '1.16.1': 736, + '1.16.2': 751, } # Those Minecraft versions supported by pyCraft which are "release" versions, diff --git a/minecraft/networking/packets/clientbound/play/__init__.py b/minecraft/networking/packets/clientbound/play/__init__.py index a99bbdd..2f81d9f 100644 --- a/minecraft/networking/packets/clientbound/play/__init__.py +++ b/minecraft/networking/packets/clientbound/play/__init__.py @@ -64,7 +64,8 @@ def get_packets(context): class KeepAlivePacket(AbstractKeepAlivePacket): @staticmethod def get_id(context): - return 0x20 if context.protocol_version >= 722 else \ + return 0x1F if context.protocol_version >= 751 else \ + 0x20 if context.protocol_version >= 722 else \ 0x21 if context.protocol_version >= 550 else \ 0x20 if context.protocol_version >= 471 else \ 0x21 if context.protocol_version >= 389 else \ @@ -78,7 +79,8 @@ class KeepAlivePacket(AbstractKeepAlivePacket): class JoinGamePacket(Packet): @staticmethod def get_id(context): - return 0x25 if context.protocol_version >= 722 else \ + return 0x24 if context.protocol_version >= 751 else \ + 0x25 if context.protocol_version >= 722 else \ 0x26 if context.protocol_version >= 550 else \ 0x25 if context.protocol_version >= 389 else \ 0x24 if context.protocol_version >= 345 else \ @@ -90,7 +92,9 @@ class JoinGamePacket(Packet): packet_name = "join game" get_definition = staticmethod(lambda context: [ {'entity_id': Integer}, + {'is_hardcore': Boolean} if context.protocol_version >= 751 else {}, {'game_mode': UnsignedByte}, + {'previous_game_mode': UnsignedByte} if context.protocol_version >= 722 else {}, {'dimension': Integer if context.protocol_version >= 108 else Byte}, {'hashed_seed': Long} if context.protocol_version >= 552 else {}, {'difficulty': UnsignedByte} if context.protocol_version < 464 else {}, @@ -154,7 +158,8 @@ class ChatMessagePacket(Packet): class DisconnectPacket(Packet): @staticmethod def get_id(context): - return 0x1A if context.protocol_version >= 722 else \ + return 0x19 if context.protocol_version >= 751 else \ + 0x1A if context.protocol_version >= 722 else \ 0x1B if context.protocol_version >= 550 else \ 0x1A if context.protocol_version >= 471 else \ 0x1B if context.protocol_version >= 345 else \ @@ -244,7 +249,8 @@ class EntityVelocityPacket(Packet): class EntityPositionDeltaPacket(Packet): @staticmethod def get_id(context): - return 0x28 if context.protocol_version >= 722 else \ + return 0x27 if context.protocol_version >= 751 else \ + 0x28 if context.protocol_version >= 722 else \ 0x29 if context.protocol_version >= 578 else \ 0xFF @@ -302,7 +308,8 @@ class UpdateHealthPacket(Packet): class RespawnPacket(Packet): @staticmethod def get_id(context): - return 0x3A if context.protocol_version >= 722 else \ + return 0x39 if context.protocol_version >= 751 else \ + 0x3A if context.protocol_version >= 722 else \ 0x3B if context.protocol_version >= 550 else \ 0x3A if context.protocol_version >= 471 else \ 0x38 if context.protocol_version >= 461 else \ @@ -337,7 +344,8 @@ class RespawnPacket(Packet): class PluginMessagePacket(AbstractPluginMessagePacket): @staticmethod def get_id(context): - return 0x18 if context.protocol_version >= 722 else \ + return 0x17 if context.protocol_version >= 751 else \ + 0x18 if context.protocol_version >= 722 else \ 0x19 if context.protocol_version >= 550 else \ 0x18 if context.protocol_version >= 471 else \ 0x19 if context.protocol_version >= 345 else \ @@ -372,7 +380,8 @@ class PlayerListHeaderAndFooterPacket(Packet): class EntityLookPacket(Packet): @staticmethod def get_id(context): - return 0x2A if context.protocol_version >= 722 else \ + return 0x29 if context.protocol_version >= 751 else \ + 0x2A if context.protocol_version >= 722 else \ 0x2B if context.protocol_version >= 550 else \ 0x2A if context.protocol_version >= 389 else \ 0x29 if context.protocol_version >= 345 else \ diff --git a/minecraft/networking/packets/clientbound/play/block_change_packet.py b/minecraft/networking/packets/clientbound/play/block_change_packet.py index ddfae88..396c59c 100644 --- a/minecraft/networking/packets/clientbound/play/block_change_packet.py +++ b/minecraft/networking/packets/clientbound/play/block_change_packet.py @@ -47,7 +47,8 @@ class BlockChangePacket(Packet): class MultiBlockChangePacket(Packet): @staticmethod def get_id(context): - return 0x0F if context.protocol_version >= 722 else \ + return 0x3B if context.protocol_version >= 751 else \ + 0x0F if context.protocol_version >= 722 else \ 0x10 if context.protocol_version >= 550 else \ 0x0F if context.protocol_version >= 343 else \ 0x10 if context.protocol_version >= 332 else \ diff --git a/minecraft/networking/packets/clientbound/play/combat_event_packet.py b/minecraft/networking/packets/clientbound/play/combat_event_packet.py index 7bf3794..8d7e80c 100644 --- a/minecraft/networking/packets/clientbound/play/combat_event_packet.py +++ b/minecraft/networking/packets/clientbound/play/combat_event_packet.py @@ -8,7 +8,8 @@ from minecraft.networking.types import ( class CombatEventPacket(Packet): @staticmethod def get_id(context): - return 0x32 if context.protocol_version >= 722 else \ + return 0x31 if context.protocol_version >= 751 else \ + 0x32 if context.protocol_version >= 722 else \ 0x33 if context.protocol_version >= 550 else \ 0x32 if context.protocol_version >= 471 else \ 0x30 if context.protocol_version >= 451 else \ diff --git a/minecraft/networking/packets/clientbound/play/explosion_packet.py b/minecraft/networking/packets/clientbound/play/explosion_packet.py index 3c9f8e5..c47a48d 100644 --- a/minecraft/networking/packets/clientbound/play/explosion_packet.py +++ b/minecraft/networking/packets/clientbound/play/explosion_packet.py @@ -7,7 +7,8 @@ from minecraft.networking.packets import Packet class ExplosionPacket(Packet): @staticmethod def get_id(context): - return 0x1C if context.protocol_version >= 722 else \ + return 0x1B if context.protocol_version >= 751 else \ + 0x1C if context.protocol_version >= 722 else \ 0x1D if context.protocol_version >= 550 else \ 0x1C if context.protocol_version >= 471 else \ 0x1E if context.protocol_version >= 389 else \ diff --git a/minecraft/networking/packets/clientbound/play/face_player_packet.py b/minecraft/networking/packets/clientbound/play/face_player_packet.py index e015792..6db4a07 100644 --- a/minecraft/networking/packets/clientbound/play/face_player_packet.py +++ b/minecraft/networking/packets/clientbound/play/face_player_packet.py @@ -8,7 +8,8 @@ from minecraft.networking.packets import Packet class FacePlayerPacket(Packet): @staticmethod def get_id(context): - return 0x34 if context.protocol_version >= 722 else \ + return 0x33 if context.protocol_version >= 751 else \ + 0x34 if context.protocol_version >= 722 else \ 0x35 if context.protocol_version >= 550 else \ 0x34 if context.protocol_version >= 471 else \ 0x32 if context.protocol_version >= 451 else \ diff --git a/minecraft/networking/packets/clientbound/play/map_packet.py b/minecraft/networking/packets/clientbound/play/map_packet.py index 089c376..ae45f5e 100644 --- a/minecraft/networking/packets/clientbound/play/map_packet.py +++ b/minecraft/networking/packets/clientbound/play/map_packet.py @@ -8,7 +8,8 @@ from minecraft.networking.types import ( class MapPacket(Packet): @staticmethod def get_id(context): - return 0x26 if context.protocol_version >= 722 else \ + return 0x25 if context.protocol_version >= 751 else \ + 0x26 if context.protocol_version >= 722 else \ 0x27 if context.protocol_version >= 550 else \ 0x26 if context.protocol_version >= 389 else \ 0x25 if context.protocol_version >= 345 else \ diff --git a/minecraft/networking/packets/clientbound/play/player_list_item_packet.py b/minecraft/networking/packets/clientbound/play/player_list_item_packet.py index ec62131..f9ebd8e 100644 --- a/minecraft/networking/packets/clientbound/play/player_list_item_packet.py +++ b/minecraft/networking/packets/clientbound/play/player_list_item_packet.py @@ -9,7 +9,8 @@ from minecraft.networking.types import ( class PlayerListItemPacket(Packet): @staticmethod def get_id(context): - return 0x33 if context.protocol_version >= 722 else \ + return 0x32 if context.protocol_version >= 751 else \ + 0x33 if context.protocol_version >= 722 else \ 0x34 if context.protocol_version >= 550 else \ 0x33 if context.protocol_version >= 471 else \ 0x31 if context.protocol_version >= 451 else \ diff --git a/minecraft/networking/packets/clientbound/play/player_position_and_look_packet.py b/minecraft/networking/packets/clientbound/play/player_position_and_look_packet.py index ac4a3fb..9df7be7 100644 --- a/minecraft/networking/packets/clientbound/play/player_position_and_look_packet.py +++ b/minecraft/networking/packets/clientbound/play/player_position_and_look_packet.py @@ -9,7 +9,8 @@ from minecraft.networking.types import ( class PlayerPositionAndLookPacket(Packet, BitFieldEnum): @staticmethod def get_id(context): - return 0x35 if context.protocol_version >= 722 else \ + return 0x34 if context.protocol_version >= 751 else \ + 0x35 if context.protocol_version >= 722 else \ 0x36 if context.protocol_version >= 550 else \ 0x35 if context.protocol_version >= 471 else \ 0x33 if context.protocol_version >= 451 else \