Add support for Minecraft 1.13 and 1.13-pre3 to pre10 (protocols 385 to 393).
Add clientbound.login.PluginRequestPacket and serverbound.login.PluginResponsePacket.
This commit is contained in:
1 parent
745aa054b0
commit
adc8d15ddc
19 files changed
+258
-48
No files matched your search
@@ -1,7 +1,7 @@
|
||||
from minecraft.networking.packets import Packet
|
||||
|
||||
from minecraft.networking.types import (
|
||||
String, VarIntPrefixedByteArray
|
||||
VarInt, Boolean, String, VarIntPrefixedByteArray, TrailingByteArray
|
||||
)
|
||||
|
||||
|
||||
@@ -11,19 +11,67 @@ def get_packets(context):
|
||||
LoginStartPacket,
|
||||
EncryptionResponsePacket
|
||||
}
|
||||
if context.protocol_version >= 385:
|
||||
packets |= {
|
||||
PluginResponsePacket
|
||||
}
|
||||
return packets
|
||||
|
||||
|
||||
class LoginStartPacket(Packet):
|
||||
id = 0x00
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x00 if context.protocol_version >= 391 else \
|
||||
0x01 if context.protocol_version >= 385 else \
|
||||
0x00
|
||||
|
||||
packet_name = "login start"
|
||||
definition = [
|
||||
{'name': String}]
|
||||
|
||||
|
||||
class EncryptionResponsePacket(Packet):
|
||||
id = 0x01
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x01 if context.protocol_version >= 391 else \
|
||||
0x02 if context.protocol_version >= 385 else \
|
||||
0x01
|
||||
|
||||
packet_name = "encryption response"
|
||||
definition = [
|
||||
{'shared_secret': VarIntPrefixedByteArray},
|
||||
{'verify_token': VarIntPrefixedByteArray}]
|
||||
|
||||
|
||||
class PluginResponsePacket(Packet):
|
||||
""" NOTE: see comments on 'clientbound.login.PluginRequestPacket' for
|
||||
important information on the usage of this packet.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x02 if context.protocol_version >= 391 else \
|
||||
0x00
|
||||
|
||||
packet_name = 'login plugin response'
|
||||
fields = (
|
||||
'message_id', # str
|
||||
'successful', # bool
|
||||
'data', # bytes, or None if 'successful' is False
|
||||
)
|
||||
|
||||
def read(self, file_object):
|
||||
self.message_id = VarInt.read(file_object)
|
||||
self.successful = Boolean.read(file_object)
|
||||
if self.successful:
|
||||
self.data = TrailingByteArray.read(file_object)
|
||||
else:
|
||||
self.data = None
|
||||
|
||||
def write_fields(self, packet_buffer):
|
||||
VarInt.send(self.message_id, packet_buffer)
|
||||
successful = getattr(self, 'data', None) is not None
|
||||
successful = getattr(self, 'successful', successful)
|
||||
Boolean.send(successful, packet_buffer)
|
||||
if successful:
|
||||
TrailingByteArray.send(self.data, packet_buffer)
|
||||
@@ -32,7 +32,9 @@ def get_packets(context):
|
||||
class KeepAlivePacket(AbstractKeepAlivePacket):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x0B if context.protocol_version >= 345 else \
|
||||
return 0x0E if context.protocol_version >= 389 else \
|
||||
0x0C if context.protocol_version >= 386 else \
|
||||
0x0B if context.protocol_version >= 345 else \
|
||||
0x0A if context.protocol_version >= 343 else \
|
||||
0x0B if context.protocol_version >= 336 else \
|
||||
0x0C if context.protocol_version >= 318 else \
|
||||
@@ -43,7 +45,8 @@ class KeepAlivePacket(AbstractKeepAlivePacket):
|
||||
class ChatPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x01 if context.protocol_version >= 343 else \
|
||||
return 0x02 if context.protocol_version >= 389 else \
|
||||
0x01 if context.protocol_version >= 343 else \
|
||||
0x02 if context.protocol_version >= 336 else \
|
||||
0x03 if context.protocol_version >= 318 else \
|
||||
0x02 if context.protocol_version >= 107 else \
|
||||
@@ -67,7 +70,9 @@ class ChatPacket(Packet):
|
||||
class PositionAndLookPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x0E if context.protocol_version >= 345 else \
|
||||
return 0x11 if context.protocol_version >= 389 else \
|
||||
0x0F if context.protocol_version >= 386 else \
|
||||
0x0E if context.protocol_version >= 345 else \
|
||||
0x0D if context.protocol_version >= 343 else \
|
||||
0x0E if context.protocol_version >= 336 else \
|
||||
0x0F if context.protocol_version >= 332 else \
|
||||
@@ -96,7 +101,9 @@ class TeleportConfirmPacket(Packet):
|
||||
class AnimationPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x1D if context.protocol_version >= 345 else \
|
||||
return 0x27 if context.protocol_version >= 389 else \
|
||||
0x25 if context.protocol_version >= 386 else \
|
||||
0x1D if context.protocol_version >= 345 else \
|
||||
0x1C if context.protocol_version >= 343 else \
|
||||
0x1D if context.protocol_version >= 332 else \
|
||||
0x1C if context.protocol_version >= 318 else \
|
||||
@@ -114,7 +121,8 @@ class AnimationPacket(Packet):
|
||||
class ClientStatusPacket(Packet, Enum):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x02 if context.protocol_version >= 343 else \
|
||||
return 0x03 if context.protocol_version >= 389 else \
|
||||
0x02 if context.protocol_version >= 343 else \
|
||||
0x03 if context.protocol_version >= 336 else \
|
||||
0x04 if context.protocol_version >= 318 else \
|
||||
0x03 if context.protocol_version >= 80 else \
|
||||
@@ -137,7 +145,8 @@ class ClientStatusPacket(Packet, Enum):
|
||||
class PluginMessagePacket(AbstractPluginMessagePacket):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x09 if context.protocol_version >= 345 else \
|
||||
return 0x0A if context.protocol_version >= 389 else \
|
||||
0x09 if context.protocol_version >= 345 else \
|
||||
0x08 if context.protocol_version >= 343 else \
|
||||
0x09 if context.protocol_version >= 336 else \
|
||||
0x0A if context.protocol_version >= 317 else \
|
||||
@@ -161,7 +170,9 @@ class PlayerBlockPlacementPacket(Packet):
|
||||
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x1F if context.protocol_version >= 345 else \
|
||||
return 0x29 if context.protocol_version >= 389 else \
|
||||
0x27 if context.protocol_version >= 386 else \
|
||||
0x1F if context.protocol_version >= 345 else \
|
||||
0x1E if context.protocol_version >= 343 else \
|
||||
0x1F if context.protocol_version >= 332 else \
|
||||
0x1E if context.protocol_version >= 318 else \
|
||||
|
||||
@@ -8,7 +8,8 @@ from minecraft.networking.types import (
|
||||
class ClientSettingsPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x03 if context.protocol_version >= 343 else \
|
||||
return 0x04 if context.protocol_version >= 389 else \
|
||||
0x03 if context.protocol_version >= 343 else \
|
||||
0x04 if context.protocol_version >= 336 else \
|
||||
0x05 if context.protocol_version >= 318 else \
|
||||
0x04 if context.protocol_version >= 94 else \
|
||||
|
||||
Reference in new issue
Block a user