Add support for v1.15
This commit is contained in:
1 parent
6f2f25656c
commit
e1afabcba5
12 files changed
+50
-23
No files matched your search
@@ -197,6 +197,7 @@ SUPPORTED_MINECRAFT_VERSIONS = {
|
|||||||
'1.14.4-pre6': 496,
|
'1.14.4-pre6': 496,
|
||||||
'1.14.4-pre7': 497,
|
'1.14.4-pre7': 497,
|
||||||
'1.14.4': 498,
|
'1.14.4': 498,
|
||||||
|
'1.15': 573,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Those Minecraft versions supported by pyCraft which are "release" versions,
|
# Those Minecraft versions supported by pyCraft which are "release" versions,
|
||||||
|
|||||||
@@ -642,6 +642,7 @@ class PacketReactor(object):
|
|||||||
# If we know the structure of the packet, attempt to parse it
|
# If we know the structure of the packet, attempt to parse it
|
||||||
# otherwise just skip it
|
# otherwise just skip it
|
||||||
if packet_id in self.clientbound_packets:
|
if packet_id in self.clientbound_packets:
|
||||||
|
# print("XXX packet_id 0x{:02X}".format(packet_id))
|
||||||
packet = self.clientbound_packets[packet_id]()
|
packet = self.clientbound_packets[packet_id]()
|
||||||
packet.context = self.connection.context
|
packet.context = self.connection.context
|
||||||
packet.read(packet_data)
|
packet.read(packet_data)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ from minecraft.networking.packets import (
|
|||||||
from minecraft.networking.types import (
|
from minecraft.networking.types import (
|
||||||
Integer, FixedPointInteger, Angle, UnsignedByte, Byte, Boolean, UUID,
|
Integer, FixedPointInteger, Angle, UnsignedByte, Byte, Boolean, UUID,
|
||||||
Short, VarInt, Double, Float, String, Enum, Difficulty, Dimension,
|
Short, VarInt, Double, Float, String, Enum, Difficulty, Dimension,
|
||||||
GameMode, Vector, Direction, PositionAndLook, multi_attribute_alias,
|
GameMode, Long, Vector, Direction, PositionAndLook,
|
||||||
|
multi_attribute_alias,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .combat_event_packet import CombatEventPacket
|
from .combat_event_packet import CombatEventPacket
|
||||||
@@ -61,7 +62,8 @@ def get_packets(context):
|
|||||||
class KeepAlivePacket(AbstractKeepAlivePacket):
|
class KeepAlivePacket(AbstractKeepAlivePacket):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x20 if context.protocol_version >= 471 else \
|
return 0x21 if context.protocol_version >= 573 else \
|
||||||
|
0x20 if context.protocol_version >= 471 else \
|
||||||
0x21 if context.protocol_version >= 389 else \
|
0x21 if context.protocol_version >= 389 else \
|
||||||
0x20 if context.protocol_version >= 345 else \
|
0x20 if context.protocol_version >= 345 else \
|
||||||
0x1F if context.protocol_version >= 332 else \
|
0x1F if context.protocol_version >= 332 else \
|
||||||
@@ -73,7 +75,8 @@ class KeepAlivePacket(AbstractKeepAlivePacket):
|
|||||||
class JoinGamePacket(Packet):
|
class JoinGamePacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x25 if context.protocol_version >= 389 else \
|
return 0x26 if context.protocol_version >= 573 else \
|
||||||
|
0x25 if context.protocol_version >= 389 else \
|
||||||
0x24 if context.protocol_version >= 345 else \
|
0x24 if context.protocol_version >= 345 else \
|
||||||
0x23 if context.protocol_version >= 332 else \
|
0x23 if context.protocol_version >= 332 else \
|
||||||
0x24 if context.protocol_version >= 318 else \
|
0x24 if context.protocol_version >= 318 else \
|
||||||
@@ -85,11 +88,13 @@ class JoinGamePacket(Packet):
|
|||||||
{'entity_id': Integer},
|
{'entity_id': Integer},
|
||||||
{'game_mode': UnsignedByte},
|
{'game_mode': UnsignedByte},
|
||||||
{'dimension': Integer if context.protocol_version >= 108 else Byte},
|
{'dimension': Integer if context.protocol_version >= 108 else Byte},
|
||||||
|
{'hashed_seed': Long} if context.protocol_version >= 573 else {},
|
||||||
{'difficulty': UnsignedByte} if context.protocol_version < 464 else {},
|
{'difficulty': UnsignedByte} if context.protocol_version < 464 else {},
|
||||||
{'max_players': UnsignedByte},
|
{'max_players': UnsignedByte},
|
||||||
{'level_type': String},
|
{'level_type': String},
|
||||||
{'render_distance': VarInt} if context.protocol_version >= 468 else {},
|
{'render_distance': VarInt} if context.protocol_version >= 468 else {},
|
||||||
{'reduced_debug_info': Boolean},
|
{'reduced_debug_info': Boolean},
|
||||||
|
{'respawn_screen': Boolean} if context.protocol_version >= 573 else {},
|
||||||
])
|
])
|
||||||
|
|
||||||
# These aliases declare the Enum type corresponding to each field:
|
# These aliases declare the Enum type corresponding to each field:
|
||||||
@@ -101,7 +106,8 @@ class JoinGamePacket(Packet):
|
|||||||
class ServerDifficultyPacket(Packet):
|
class ServerDifficultyPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x0D if context.protocol_version >= 332 else \
|
return 0x0E if context.protocol_version >= 573 else \
|
||||||
|
0x0D if context.protocol_version >= 332 else \
|
||||||
0x0E if context.protocol_version >= 318 else \
|
0x0E if context.protocol_version >= 318 else \
|
||||||
0x0D if context.protocol_version >= 70 else \
|
0x0D if context.protocol_version >= 70 else \
|
||||||
0x41
|
0x41
|
||||||
@@ -119,7 +125,8 @@ class ServerDifficultyPacket(Packet):
|
|||||||
class ChatMessagePacket(Packet):
|
class ChatMessagePacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x0E if context.protocol_version >= 343 else \
|
return 0x0F if context.protocol_version >= 573 else \
|
||||||
|
0x0E if context.protocol_version >= 343 else \
|
||||||
0x0F if context.protocol_version >= 332 else \
|
0x0F if context.protocol_version >= 332 else \
|
||||||
0x10 if context.protocol_version >= 317 else \
|
0x10 if context.protocol_version >= 317 else \
|
||||||
0x0F if context.protocol_version >= 107 else \
|
0x0F if context.protocol_version >= 107 else \
|
||||||
@@ -139,7 +146,8 @@ class ChatMessagePacket(Packet):
|
|||||||
class DisconnectPacket(Packet):
|
class DisconnectPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x1A if context.protocol_version >= 471 else \
|
return 0x1B if context.protocol_version >= 573 else \
|
||||||
|
0x1A if context.protocol_version >= 471 else \
|
||||||
0x1B if context.protocol_version >= 345 else \
|
0x1B if context.protocol_version >= 345 else \
|
||||||
0x1A if context.protocol_version >= 332 else \
|
0x1A if context.protocol_version >= 332 else \
|
||||||
0x1B if context.protocol_version >= 318 else \
|
0x1B if context.protocol_version >= 318 else \
|
||||||
@@ -198,7 +206,8 @@ class SpawnPlayerPacket(Packet):
|
|||||||
class EntityVelocityPacket(Packet):
|
class EntityVelocityPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x45 if context.protocol_version >= 471 else \
|
return 0x46 if context.protocol_version >= 573 else \
|
||||||
|
0x45 if context.protocol_version >= 471 else \
|
||||||
0x41 if context.protocol_version >= 461 else \
|
0x41 if context.protocol_version >= 461 else \
|
||||||
0x42 if context.protocol_version >= 451 else \
|
0x42 if context.protocol_version >= 451 else \
|
||||||
0x41 if context.protocol_version >= 389 else \
|
0x41 if context.protocol_version >= 389 else \
|
||||||
@@ -223,7 +232,8 @@ class EntityVelocityPacket(Packet):
|
|||||||
class UpdateHealthPacket(Packet):
|
class UpdateHealthPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x48 if context.protocol_version >= 471 else \
|
return 0x49 if context.protocol_version >= 573 else \
|
||||||
|
0x48 if context.protocol_version >= 471 else \
|
||||||
0x44 if context.protocol_version >= 461 else \
|
0x44 if context.protocol_version >= 461 else \
|
||||||
0x45 if context.protocol_version >= 451 else \
|
0x45 if context.protocol_version >= 451 else \
|
||||||
0x44 if context.protocol_version >= 389 else \
|
0x44 if context.protocol_version >= 389 else \
|
||||||
@@ -247,7 +257,8 @@ class UpdateHealthPacket(Packet):
|
|||||||
class RespawnPacket(Packet):
|
class RespawnPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x3A if context.protocol_version >= 471 else \
|
return 0x3B if context.protocol_version >= 573 else \
|
||||||
|
0x3A if context.protocol_version >= 471 else \
|
||||||
0x38 if context.protocol_version >= 461 else \
|
0x38 if context.protocol_version >= 461 else \
|
||||||
0x39 if context.protocol_version >= 451 else \
|
0x39 if context.protocol_version >= 451 else \
|
||||||
0x38 if context.protocol_version >= 389 else \
|
0x38 if context.protocol_version >= 389 else \
|
||||||
@@ -276,7 +287,8 @@ class RespawnPacket(Packet):
|
|||||||
class PluginMessagePacket(AbstractPluginMessagePacket):
|
class PluginMessagePacket(AbstractPluginMessagePacket):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x18 if context.protocol_version >= 471 else \
|
return 0x19 if context.protocol_version >= 573 else \
|
||||||
|
0x18 if context.protocol_version >= 471 else \
|
||||||
0x19 if context.protocol_version >= 345 else \
|
0x19 if context.protocol_version >= 345 else \
|
||||||
0x18 if context.protocol_version >= 332 else \
|
0x18 if context.protocol_version >= 332 else \
|
||||||
0x19 if context.protocol_version >= 318 else \
|
0x19 if context.protocol_version >= 318 else \
|
||||||
@@ -287,7 +299,8 @@ class PluginMessagePacket(AbstractPluginMessagePacket):
|
|||||||
class PlayerListHeaderAndFooterPacket(Packet):
|
class PlayerListHeaderAndFooterPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x53 if context.protocol_version >= 471 else \
|
return 0x54 if context.protocol_version >= 573 else \
|
||||||
|
0x53 if context.protocol_version >= 471 else \
|
||||||
0x5F if context.protocol_version >= 461 else \
|
0x5F if context.protocol_version >= 461 else \
|
||||||
0x50 if context.protocol_version >= 451 else \
|
0x50 if context.protocol_version >= 451 else \
|
||||||
0x4F if context.protocol_version >= 441 else \
|
0x4F if context.protocol_version >= 441 else \
|
||||||
@@ -307,7 +320,8 @@ class PlayerListHeaderAndFooterPacket(Packet):
|
|||||||
class EntityLookPacket(Packet):
|
class EntityLookPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x2A if context.protocol_version >= 389 else \
|
return 0x2B if context.protocol_version >= 573 else \
|
||||||
|
0x2A if context.protocol_version >= 389 else \
|
||||||
0x29 if context.protocol_version >= 345 else \
|
0x29 if context.protocol_version >= 345 else \
|
||||||
0x28 if context.protocol_version >= 318 else \
|
0x28 if context.protocol_version >= 318 else \
|
||||||
0x27 if context.protocol_version >= 94 else \
|
0x27 if context.protocol_version >= 94 else \
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ from minecraft.networking.types import (
|
|||||||
class BlockChangePacket(Packet):
|
class BlockChangePacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x0B if context.protocol_version >= 332 else \
|
return 0x0C if context.protocol_version >= 573 else \
|
||||||
|
0x0B if context.protocol_version >= 332 else \
|
||||||
0x0C if context.protocol_version >= 318 else \
|
0x0C if context.protocol_version >= 318 else \
|
||||||
0x0B if context.protocol_version >= 67 else \
|
0x0B if context.protocol_version >= 67 else \
|
||||||
0x24 if context.protocol_version >= 62 else \
|
0x24 if context.protocol_version >= 62 else \
|
||||||
@@ -45,7 +46,8 @@ class BlockChangePacket(Packet):
|
|||||||
class MultiBlockChangePacket(Packet):
|
class MultiBlockChangePacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x0F if context.protocol_version >= 343 else \
|
return 0x10 if context.protocol_version >= 573 else \
|
||||||
|
0x0F if context.protocol_version >= 343 else \
|
||||||
0x10 if context.protocol_version >= 332 else \
|
0x10 if context.protocol_version >= 332 else \
|
||||||
0x11 if context.protocol_version >= 318 else \
|
0x11 if context.protocol_version >= 318 else \
|
||||||
0x10 if context.protocol_version >= 67 else \
|
0x10 if context.protocol_version >= 67 else \
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ from minecraft.networking.types import (
|
|||||||
class CombatEventPacket(Packet):
|
class CombatEventPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x32 if context.protocol_version >= 471 else \
|
return 0x33 if context.protocol_version >= 573 else \
|
||||||
|
0x32 if context.protocol_version >= 471 else \
|
||||||
0x30 if context.protocol_version >= 451 else \
|
0x30 if context.protocol_version >= 451 else \
|
||||||
0x2F if context.protocol_version >= 389 else \
|
0x2F if context.protocol_version >= 389 else \
|
||||||
0x2E if context.protocol_version >= 345 else \
|
0x2E if context.protocol_version >= 345 else \
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ from minecraft.networking.packets import Packet
|
|||||||
class ExplosionPacket(Packet):
|
class ExplosionPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x1C if context.protocol_version >= 471 else \
|
return 0x1D if context.protocol_version >= 573 else \
|
||||||
|
0x1C if context.protocol_version >= 471 else \
|
||||||
0x1E if context.protocol_version >= 389 else \
|
0x1E if context.protocol_version >= 389 else \
|
||||||
0x1D if context.protocol_version >= 345 else \
|
0x1D if context.protocol_version >= 345 else \
|
||||||
0x1C if context.protocol_version >= 332 else \
|
0x1C if context.protocol_version >= 332 else \
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ from minecraft.networking.packets import Packet
|
|||||||
class FacePlayerPacket(Packet):
|
class FacePlayerPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x34 if context.protocol_version >= 471 else \
|
return 0x35 if context.protocol_version >= 573 else \
|
||||||
|
0x34 if context.protocol_version >= 471 else \
|
||||||
0x32 if context.protocol_version >= 451 else \
|
0x32 if context.protocol_version >= 451 else \
|
||||||
0x31 if context.protocol_version >= 389 else \
|
0x31 if context.protocol_version >= 389 else \
|
||||||
0x30
|
0x30
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ from minecraft.networking.types import (
|
|||||||
class MapPacket(Packet):
|
class MapPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x26 if context.protocol_version >= 389 else \
|
return 0x27 if context.protocol_version >= 573 else \
|
||||||
|
0x26 if context.protocol_version >= 389 else \
|
||||||
0x25 if context.protocol_version >= 345 else \
|
0x25 if context.protocol_version >= 345 else \
|
||||||
0x24 if context.protocol_version >= 334 else \
|
0x24 if context.protocol_version >= 334 else \
|
||||||
0x25 if context.protocol_version >= 318 else \
|
0x25 if context.protocol_version >= 318 else \
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ from minecraft.networking.types import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Player Info
|
||||||
class PlayerListItemPacket(Packet):
|
class PlayerListItemPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x33 if context.protocol_version >= 471 else \
|
return 0x34 if context.protocol_version >= 573 else \
|
||||||
|
0x33 if context.protocol_version >= 471 else \
|
||||||
0x31 if context.protocol_version >= 451 else \
|
0x31 if context.protocol_version >= 451 else \
|
||||||
0x30 if context.protocol_version >= 389 else \
|
0x30 if context.protocol_version >= 389 else \
|
||||||
0x2F if context.protocol_version >= 345 else \
|
0x2F if context.protocol_version >= 345 else \
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ from minecraft.networking.types import (
|
|||||||
class PlayerPositionAndLookPacket(Packet, BitFieldEnum):
|
class PlayerPositionAndLookPacket(Packet, BitFieldEnum):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x35 if context.protocol_version >= 471 else \
|
return 0x36 if context.protocol_version >= 573 else \
|
||||||
|
0x35 if context.protocol_version >= 471 else \
|
||||||
0x33 if context.protocol_version >= 451 else \
|
0x33 if context.protocol_version >= 451 else \
|
||||||
0x32 if context.protocol_version >= 389 else \
|
0x32 if context.protocol_version >= 389 else \
|
||||||
0x31 if context.protocol_version >= 352 else \
|
0x31 if context.protocol_version >= 352 else \
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ __all__ = 'SoundEffectPacket',
|
|||||||
class SoundEffectPacket(Packet):
|
class SoundEffectPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x51 if context.protocol_version >= 471 else \
|
return 0x52 if context.protocol_version >= 573 else \
|
||||||
|
0x51 if context.protocol_version >= 471 else \
|
||||||
0x4D if context.protocol_version >= 461 else \
|
0x4D if context.protocol_version >= 461 else \
|
||||||
0x4E if context.protocol_version >= 451 else \
|
0x4E if context.protocol_version >= 451 else \
|
||||||
0x4E if context.protocol_version >= 451 else \
|
0x4E if context.protocol_version >= 451 else \
|
||||||
|
|||||||
@@ -102,8 +102,9 @@ class FakeClientHandler(object):
|
|||||||
def handle_play_start(self):
|
def handle_play_start(self):
|
||||||
# Called upon entering the play state.
|
# Called upon entering the play state.
|
||||||
self.write_packet(clientbound.play.JoinGamePacket(
|
self.write_packet(clientbound.play.JoinGamePacket(
|
||||||
entity_id=0, game_mode=0, dimension=0, difficulty=2, max_players=1,
|
entity_id=0, game_mode=0, dimension=0, hashed_seed=12345,
|
||||||
level_type='default', reduced_debug_info=False, render_distance=9))
|
difficulty=2, max_players=1, level_type='default',
|
||||||
|
reduced_debug_info=False, render_distance=9, respawn_screen=False))
|
||||||
|
|
||||||
def handle_play_packet(self, packet):
|
def handle_play_packet(self, packet):
|
||||||
# Called upon each packet received after handle_play_start() returns.
|
# Called upon each packet received after handle_play_start() returns.
|
||||||
|
|||||||
Reference in new issue
Block a user