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
|
||||
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}]
|
||||
@@ -46,7 +46,8 @@ def get_packets(context):
|
||||
class KeepAlivePacket(AbstractKeepAlivePacket):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x20 if context.protocol_version >= 345 else \
|
||||
return 0x21 if context.protocol_version >= 389 else \
|
||||
0x20 if context.protocol_version >= 345 else \
|
||||
0x1F if context.protocol_version >= 332 else \
|
||||
0x20 if context.protocol_version >= 318 else \
|
||||
0x1F if context.protocol_version >= 107 else \
|
||||
@@ -56,7 +57,8 @@ class KeepAlivePacket(AbstractKeepAlivePacket):
|
||||
class JoinGamePacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x24 if context.protocol_version >= 345 else \
|
||||
return 0x25 if context.protocol_version >= 389 else \
|
||||
0x24 if context.protocol_version >= 345 else \
|
||||
0x23 if context.protocol_version >= 332 else \
|
||||
0x24 if context.protocol_version >= 318 else \
|
||||
0x23 if context.protocol_version >= 107 else \
|
||||
@@ -142,7 +144,8 @@ class SpawnPlayerPacket(Packet):
|
||||
class EntityVelocityPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x40 if context.protocol_version >= 352 else \
|
||||
return 0x41 if context.protocol_version >= 389 else \
|
||||
0x40 if context.protocol_version >= 352 else \
|
||||
0x3F if context.protocol_version >= 345 else \
|
||||
0x3E if context.protocol_version >= 336 else \
|
||||
0x3D if context.protocol_version >= 332 else \
|
||||
@@ -163,7 +166,8 @@ class EntityVelocityPacket(Packet):
|
||||
class UpdateHealthPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x43 if context.protocol_version >= 352 else \
|
||||
return 0x44 if context.protocol_version >= 389 else \
|
||||
0x43 if context.protocol_version >= 352 else \
|
||||
0x42 if context.protocol_version >= 345 else \
|
||||
0x41 if context.protocol_version >= 336 else \
|
||||
0x40 if context.protocol_version >= 318 else \
|
||||
|
||||
@@ -8,7 +8,8 @@ from minecraft.networking.types import (
|
||||
class CombatEventPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x2E if context.protocol_version >= 345 else \
|
||||
return 0x2F if context.protocol_version >= 389 else \
|
||||
0x2E if context.protocol_version >= 345 else \
|
||||
0x2D if context.protocol_version >= 336 else \
|
||||
0x2C if context.protocol_version >= 332 else \
|
||||
0x2D if context.protocol_version >= 318 else \
|
||||
|
||||
@@ -5,7 +5,8 @@ from minecraft.networking.packets import Packet
|
||||
class ExplosionPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x1D if context.protocol_version >= 345 else \
|
||||
return 0x1E if context.protocol_version >= 389 else \
|
||||
0x1D if context.protocol_version >= 345 else \
|
||||
0x1C if context.protocol_version >= 332 else \
|
||||
0x1D if context.protocol_version >= 318 else \
|
||||
0x1C if context.protocol_version >= 80 else \
|
||||
|
||||
@@ -8,7 +8,8 @@ from minecraft.networking.types import (
|
||||
class MapPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x25 if context.protocol_version >= 345 else \
|
||||
return 0x26 if context.protocol_version >= 389 else \
|
||||
0x25 if context.protocol_version >= 345 else \
|
||||
0x24 if context.protocol_version >= 334 else \
|
||||
0x25 if context.protocol_version >= 318 else \
|
||||
0x24 if context.protocol_version >= 107 else \
|
||||
|
||||
@@ -8,7 +8,8 @@ from minecraft.networking.types import (
|
||||
class PlayerListItemPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x2F if context.protocol_version >= 345 else \
|
||||
return 0x30 if context.protocol_version >= 389 else \
|
||||
0x2F if context.protocol_version >= 345 else \
|
||||
0x2E if context.protocol_version >= 336 else \
|
||||
0x2D if context.protocol_version >= 332 else \
|
||||
0x2E if context.protocol_version >= 318 else \
|
||||
|
||||
@@ -8,7 +8,8 @@ from minecraft.networking.types import (
|
||||
class PlayerPositionAndLookPacket(Packet, BitFieldEnum):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x31 if context.protocol_version >= 352 else \
|
||||
return 0x32 if context.protocol_version >= 389 else \
|
||||
0x31 if context.protocol_version >= 352 else \
|
||||
0x30 if context.protocol_version >= 345 else \
|
||||
0x2F if context.protocol_version >= 336 else \
|
||||
0x2E if context.protocol_version >= 332 else \
|
||||
|
||||
Reference in new issue
Block a user