Merge branch 'master' into packets
This commit is contained in:
commit
faf02acf62
25 files changed
+613
-231
No files matched your search
@@ -4,7 +4,7 @@ from minecraft.networking.packets import (
|
||||
|
||||
from minecraft.networking.types import (
|
||||
Integer, FixedPointInteger, UnsignedByte, Byte, Boolean, UUID, Short,
|
||||
VarInt, Double, Float, String, Enum,
|
||||
VarInt, Double, Float, String, Enum, Difficulty, Dimension, GameMode
|
||||
)
|
||||
|
||||
from .combat_event_packet import CombatEventPacket
|
||||
@@ -21,6 +21,7 @@ def get_packets(context):
|
||||
packets = {
|
||||
KeepAlivePacket,
|
||||
JoinGamePacket,
|
||||
ServerDifficultyPacket,
|
||||
ChatMessagePacket,
|
||||
PlayerPositionAndLookPacket,
|
||||
MapPacket,
|
||||
@@ -34,6 +35,7 @@ def get_packets(context):
|
||||
SpawnObjectPacket,
|
||||
BlockChangePacket,
|
||||
MultiBlockChangePacket,
|
||||
RespawnPacket,
|
||||
PluginMessagePacket,
|
||||
PlayerListHeaderAndFooterPacket,
|
||||
SoundEffectPacket,
|
||||
@@ -48,7 +50,8 @@ def get_packets(context):
|
||||
class KeepAlivePacket(AbstractKeepAlivePacket):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x21 if context.protocol_version >= 389 else \
|
||||
return 0x20 if context.protocol_version >= 471 else \
|
||||
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 \
|
||||
@@ -71,10 +74,39 @@ class JoinGamePacket(Packet):
|
||||
{'entity_id': Integer},
|
||||
{'game_mode': UnsignedByte},
|
||||
{'dimension': Integer if context.protocol_version >= 108 else Byte},
|
||||
{'difficulty': UnsignedByte},
|
||||
{'difficulty': UnsignedByte} if context.protocol_version < 464 else {},
|
||||
{'max_players': UnsignedByte},
|
||||
{'level_type': String},
|
||||
{'reduced_debug_info': Boolean}])
|
||||
{'render_distance': VarInt} if context.protocol_version >= 468 else {},
|
||||
{'reduced_debug_info': Boolean},
|
||||
])
|
||||
|
||||
# JoinGamePacket.Difficulty is an alias for Difficulty
|
||||
Difficulty = Difficulty
|
||||
|
||||
# JoinGamePacket.Gamemode is an alias for Gamemode
|
||||
GameMode = GameMode
|
||||
|
||||
# JoinGamePacket.Dimension is an alias for Dimension
|
||||
Dimension = Dimension
|
||||
|
||||
|
||||
class ServerDifficultyPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x0D if context.protocol_version >= 332 else \
|
||||
0x0E if context.protocol_version >= 318 else \
|
||||
0x0D if context.protocol_version >= 70 else \
|
||||
0x41
|
||||
|
||||
packet_name = 'server difficulty'
|
||||
get_definition = staticmethod(lambda context: [
|
||||
{'difficulty': UnsignedByte},
|
||||
{'is_locked': Boolean} if context.protocol_version >= 464 else {},
|
||||
])
|
||||
|
||||
# ServerDifficultyPacket.Difficulty is an alias for Difficulty
|
||||
Difficulty = Difficulty
|
||||
|
||||
|
||||
class ChatMessagePacket(Packet):
|
||||
@@ -100,7 +132,8 @@ class ChatMessagePacket(Packet):
|
||||
class DisconnectPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x1B if context.protocol_version >= 345 else \
|
||||
return 0x1A if context.protocol_version >= 471 else \
|
||||
0x1B if context.protocol_version >= 345 else \
|
||||
0x1A if context.protocol_version >= 332 else \
|
||||
0x1B if context.protocol_version >= 318 else \
|
||||
0x1A if context.protocol_version >= 107 else \
|
||||
@@ -146,7 +179,10 @@ class SpawnPlayerPacket(Packet):
|
||||
class EntityVelocityPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x41 if context.protocol_version >= 389 else \
|
||||
return 0x45 if context.protocol_version >= 471 else \
|
||||
0x41 if context.protocol_version >= 461 else \
|
||||
0x42 if context.protocol_version >= 451 else \
|
||||
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 \
|
||||
@@ -168,7 +204,10 @@ class EntityVelocityPacket(Packet):
|
||||
class UpdateHealthPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x44 if context.protocol_version >= 389 else \
|
||||
return 0x48 if context.protocol_version >= 471 else \
|
||||
0x44 if context.protocol_version >= 461 else \
|
||||
0x45 if context.protocol_version >= 451 else \
|
||||
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 \
|
||||
@@ -186,10 +225,44 @@ class UpdateHealthPacket(Packet):
|
||||
])
|
||||
|
||||
|
||||
class RespawnPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x3A if context.protocol_version >= 471 else \
|
||||
0x38 if context.protocol_version >= 461 else \
|
||||
0x39 if context.protocol_version >= 451 else \
|
||||
0x38 if context.protocol_version >= 389 else \
|
||||
0x37 if context.protocol_version >= 352 else \
|
||||
0x36 if context.protocol_version >= 345 else \
|
||||
0x35 if context.protocol_version >= 336 else \
|
||||
0x34 if context.protocol_version >= 332 else \
|
||||
0x35 if context.protocol_version >= 318 else \
|
||||
0x33 if context.protocol_version >= 70 else \
|
||||
0x07
|
||||
|
||||
packet_name = 'respawn'
|
||||
get_definition = staticmethod(lambda context: [
|
||||
{'dimension': Integer},
|
||||
{'difficulty': UnsignedByte} if context.protocol_version < 464 else {},
|
||||
{'game_mode': UnsignedByte},
|
||||
{'level_type': String},
|
||||
])
|
||||
|
||||
# RespawnPacket.Difficulty is an alias for Difficulty.
|
||||
Difficulty = Difficulty
|
||||
|
||||
# RespawnPacket.Dimension is an alias for Dimension.
|
||||
Dimension = Dimension
|
||||
|
||||
# RespawnPacket.Gamemode is an alias for Gamemode.
|
||||
GameMode = GameMode
|
||||
|
||||
|
||||
class PluginMessagePacket(AbstractPluginMessagePacket):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x19 if context.protocol_version >= 345 else \
|
||||
return 0x18 if context.protocol_version >= 471 else \
|
||||
0x19 if context.protocol_version >= 345 else \
|
||||
0x18 if context.protocol_version >= 332 else \
|
||||
0x19 if context.protocol_version >= 318 else \
|
||||
0x18 if context.protocol_version >= 70 else \
|
||||
@@ -199,7 +272,11 @@ class PluginMessagePacket(AbstractPluginMessagePacket):
|
||||
class PlayerListHeaderAndFooterPacket(Packet):
|
||||
@staticmethod
|
||||
def get_id(context):
|
||||
return 0x4E if context.protocol_version >= 393 else \
|
||||
return 0x53 if context.protocol_version >= 471 else \
|
||||
0x5F if context.protocol_version >= 461 else \
|
||||
0x50 if context.protocol_version >= 451 else \
|
||||
0x4F if context.protocol_version >= 441 else \
|
||||
0x4E if context.protocol_version >= 393 else \
|
||||
0x4A if context.protocol_version >= 338 else \
|
||||
0x49 if context.protocol_version >= 335 else \
|
||||
0x47 if context.protocol_version >= 110 else \
|
||||
|
||||
Reference in new issue
Block a user