From 1a114c1b95704decc591ea223bb3ca3874229155 Mon Sep 17 00:00:00 2001 From: Zachy Date: Sun, 12 Aug 2018 10:47:50 +0100 Subject: [PATCH] Implement clientbound.play.ServerDifficultyPacket --- .../packets/clientbound/play/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/minecraft/networking/packets/clientbound/play/__init__.py b/minecraft/networking/packets/clientbound/play/__init__.py index 5bf64b7..5a3cdad 100644 --- a/minecraft/networking/packets/clientbound/play/__init__.py +++ b/minecraft/networking/packets/clientbound/play/__init__.py @@ -21,6 +21,7 @@ def get_packets(context): packets = { KeepAlivePacket, JoinGamePacket, + ServerDifficultyPacket, ChatMessagePacket, PlayerPositionAndLookPacket, MapPacket, @@ -73,7 +74,21 @@ class JoinGamePacket(Packet): {'difficulty': UnsignedByte}, {'max_players': UnsignedByte}, {'level_type': String}, - {'reduced_debug_info': Boolean}]) + {'reduced_debug_info': Boolean} + ]) + + +class ServerDifficultyPacket(Packet): + def get_id(context): + return 0x0D if context.protocol_version >= 332 else \ + 0x0E if context.protocol_version >= 318 else \ + 0x0D if context.protocol_version >= 67 else \ + 0x41 + + packet_name = 'server difficulty' + get_definition = staticmethod(lambda context: [ + {'difficulty': UnsignedByte} + ]) class ChatMessagePacket(Packet):