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:
joo committed 2018-07-19 09:50:13 +01:00
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
VarInt, String, VarIntPrefixedByteArray, TrailingByteArray
)
@@ -11,20 +11,34 @@ def get_packets(context):
DisconnectPacket,
EncryptionRequestPacket,
LoginSuccessPacket,
SetCompressionPacket
SetCompressionPacket,
}
if context.protocol_version >= 385:
packets |= {
PluginRequestPacket,
}
return packets
class DisconnectPacket(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 = "disconnect"
definition = [
{'json_data': String}]
class EncryptionRequestPacket(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 request"
definition = [
{'server_id': String},
@@ -33,7 +47,12 @@ class EncryptionRequestPacket(Packet):
class LoginSuccessPacket(Packet):
id = 0x02
@staticmethod
def get_id(context):
return 0x02 if context.protocol_version >= 391 else \
0x03 if context.protocol_version >= 385 else \
0x02
packet_name = "login success"
definition = [
{'UUID': String},
@@ -41,7 +60,39 @@ class LoginSuccessPacket(Packet):
class SetCompressionPacket(Packet):
id = 0x03
@staticmethod
def get_id(context):
return 0x03 if context.protocol_version >= 391 else \
0x04 if context.protocol_version >= 385 else \
0x03
packet_name = "set compression"
definition = [
{'threshold': VarInt}]
class PluginRequestPacket(Packet):
""" NOTE: pyCraft's default behaviour on receiving a 'PluginRequestPacket'
is to send a corresponding 'PluginResponsePacket' with
'successful=False'. To override this, set a packet listener that:
(1) has the keyword argument 'early=True' set when calling
'register_packet_listener'; and
(2) raises 'minecraft.networking.connection.IgnorePacket' after
sending a corresponding 'PluginResponsePacket'.
Otherwise, one 'PluginRequestPacket' may result in multiple responses,
which contravenes Minecraft's protocol.
"""
@staticmethod
def get_id(context):
return 0x04 if context.protocol_version >= 391 else \
0x00
packet_name = 'login plugin request'
definition = [
{'message_id': VarInt},
{'channel': String},
{'data': TrailingByteArray}]