Support for 1.16-rc1
This commit is contained in:
1 parent
7d9ffb8836
commit
b582029099
17 files changed
+133
-36
No files matched your search
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"python.formatting.provider": "none"
|
||||||
|
}
|
||||||
+34
-7
@@ -242,20 +242,47 @@ SUPPORTED_MINECRAFT_VERSIONS = {
|
|||||||
'20w19a': 715,
|
'20w19a': 715,
|
||||||
'20w20a': 716,
|
'20w20a': 716,
|
||||||
'20w20b': 717,
|
'20w20b': 717,
|
||||||
|
'1.16 Pre-release 2': 722,
|
||||||
|
'1.16 Pre-release 3': 725,
|
||||||
|
'1.16 Pre-release 4': 727,
|
||||||
|
'1.16 Pre-release 5': 729,
|
||||||
|
'1.16 Release Candidate 1':734,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Those Minecraft versions supported by pyCraft which are "release" versions,
|
# Those Minecraft versions supported by pyCraft which are "release" versions,
|
||||||
# i.e. not development snapshots or pre-release versions.
|
# i.e. not development snapshots or pre-release versions.
|
||||||
RELEASE_MINECRAFT_VERSIONS = {
|
RELEASE_MINECRAFT_VERSIONS = {}
|
||||||
vid: protocol for (vid, protocol) in SUPPORTED_MINECRAFT_VERSIONS.items()
|
|
||||||
if __import__('re').match(r'\d+(\.\d+)+$', vid)}
|
|
||||||
|
|
||||||
# The protocol versions of SUPPORTED_MINECRAFT_VERSIONS, without duplicates,
|
# The protocol versions of SUPPORTED_MINECRAFT_VERSIONS, without duplicates,
|
||||||
# in ascending numerical (and hence chronological) order.
|
# in ascending numerical (and hence chronological) order.
|
||||||
SUPPORTED_PROTOCOL_VERSIONS = \
|
SUPPORTED_PROTOCOL_VERSIONS = []
|
||||||
sorted(set(SUPPORTED_MINECRAFT_VERSIONS.values()))
|
|
||||||
|
|
||||||
# The protocol versions of RELEASE_MINECRAFT_VERSIONS, without duplicates,
|
# The protocol versions of RELEASE_MINECRAFT_VERSIONS, without duplicates,
|
||||||
# in ascending numerical (and hence chronological) order.
|
# in ascending numerical (and hence chronological) order.
|
||||||
RELEASE_PROTOCOL_VERSIONS = \
|
RELEASE_PROTOCOL_VERSIONS = []
|
||||||
sorted(set(RELEASE_MINECRAFT_VERSIONS.values()))
|
|
||||||
|
|
||||||
|
def initglobals():
|
||||||
|
'''Init the globals from the SUPPORTED_MINECRAFT_VERSIONS dict
|
||||||
|
|
||||||
|
This allows the SUPPORTED_MINECRAFT_VERSIONS dict to be updated, then the
|
||||||
|
other globals can be updated as well, to allow for dynamic version support.
|
||||||
|
All updates are done by reference to allow this to work else where in the code.
|
||||||
|
'''
|
||||||
|
global RELEASE_MINECRAFT_VERSIONS, SUPPORTED_PROTOCOL_VERSIONS, RELEASE_PROTOCOL_VERSIONS
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
for (vid, protocol) in SUPPORTED_MINECRAFT_VERSIONS.items():
|
||||||
|
if re.match(r"\d+(\.\d+)+$", vid):
|
||||||
|
RELEASE_MINECRAFT_VERSIONS[vid] = protocol
|
||||||
|
if protocol not in RELEASE_PROTOCOL_VERSIONS:
|
||||||
|
RELEASE_PROTOCOL_VERSIONS.append(protocol)
|
||||||
|
if protocol not in SUPPORTED_PROTOCOL_VERSIONS:
|
||||||
|
SUPPORTED_PROTOCOL_VERSIONS.append(protocol)
|
||||||
|
|
||||||
|
SUPPORTED_PROTOCOL_VERSIONS.sort()
|
||||||
|
RELEASE_PROTOCOL_VERSIONS.sort()
|
||||||
|
|
||||||
|
|
||||||
|
initglobals()
|
||||||
@@ -506,7 +506,10 @@ class Connection(object):
|
|||||||
ss = 'supported, but not allowed for this connection' \
|
ss = 'supported, but not allowed for this connection' \
|
||||||
if server_protocol in SUPPORTED_PROTOCOL_VERSIONS \
|
if server_protocol in SUPPORTED_PROTOCOL_VERSIONS \
|
||||||
else 'not supported'
|
else 'not supported'
|
||||||
raise VersionMismatch("Server's %s is %s." % (vs, ss))
|
err = VersionMismatch("Server's %s is %s." % (vs, ss))
|
||||||
|
err.server_protocol = server_protocol
|
||||||
|
err.server_version = server_version
|
||||||
|
raise err
|
||||||
|
|
||||||
def _handle_exit(self):
|
def _handle_exit(self):
|
||||||
if not self.connected and self.handle_exit is not None:
|
if not self.connected and self.handle_exit is not None:
|
||||||
@@ -647,7 +650,7 @@ class PacketReactor(object):
|
|||||||
packet.read(packet_data)
|
packet.read(packet_data)
|
||||||
return packet
|
return packet
|
||||||
else:
|
else:
|
||||||
return packets.Packet(context=self.connection.context)
|
return packets.Packet(context=self.connection.context, packet_id=packet_id)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ def get_packets(context):
|
|||||||
DisconnectPacket,
|
DisconnectPacket,
|
||||||
SpawnPlayerPacket,
|
SpawnPlayerPacket,
|
||||||
EntityVelocityPacket,
|
EntityVelocityPacket,
|
||||||
|
EntityPositionDeltaPacket,
|
||||||
|
TimeUpdatePacket,
|
||||||
UpdateHealthPacket,
|
UpdateHealthPacket,
|
||||||
CombatEventPacket,
|
CombatEventPacket,
|
||||||
ExplosionPacket,
|
ExplosionPacket,
|
||||||
@@ -62,7 +64,8 @@ def get_packets(context):
|
|||||||
class KeepAlivePacket(AbstractKeepAlivePacket):
|
class KeepAlivePacket(AbstractKeepAlivePacket):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x21 if context.protocol_version >= 550 else \
|
return 0x20 if context.protocol_version >= 722 else \
|
||||||
|
0x21 if context.protocol_version >= 550 else \
|
||||||
0x20 if context.protocol_version >= 471 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 \
|
||||||
@@ -75,7 +78,8 @@ class KeepAlivePacket(AbstractKeepAlivePacket):
|
|||||||
class JoinGamePacket(Packet):
|
class JoinGamePacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x26 if context.protocol_version >= 550 else \
|
return 0x25 if context.protocol_version >= 722 else \
|
||||||
|
0x26 if context.protocol_version >= 550 else \
|
||||||
0x25 if context.protocol_version >= 389 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 \
|
||||||
@@ -108,7 +112,8 @@ class JoinGamePacket(Packet):
|
|||||||
class ServerDifficultyPacket(Packet):
|
class ServerDifficultyPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x0E if context.protocol_version >= 550 else \
|
return 0x0D if context.protocol_version >= 722 else \
|
||||||
|
0x0E if context.protocol_version >= 550 else \
|
||||||
0x0D if context.protocol_version >= 332 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 \
|
||||||
@@ -127,7 +132,8 @@ class ServerDifficultyPacket(Packet):
|
|||||||
class ChatMessagePacket(Packet):
|
class ChatMessagePacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x0F if context.protocol_version >= 550 else \
|
return 0x0E if context.protocol_version >= 722 else \
|
||||||
|
0x0F if context.protocol_version >= 550 else \
|
||||||
0x0E if context.protocol_version >= 343 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 \
|
||||||
@@ -148,7 +154,8 @@ class ChatMessagePacket(Packet):
|
|||||||
class DisconnectPacket(Packet):
|
class DisconnectPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x1B if context.protocol_version >= 550 else \
|
return 0x1A if context.protocol_version >= 722 else \
|
||||||
|
0x1B if context.protocol_version >= 550 else \
|
||||||
0x1A if context.protocol_version >= 471 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 \
|
||||||
@@ -173,7 +180,8 @@ class SetCompressionPacket(Packet):
|
|||||||
class SpawnPlayerPacket(Packet):
|
class SpawnPlayerPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x05 if context.protocol_version >= 67 else \
|
return 0x04 if context.protocol_version >= 722 else \
|
||||||
|
0x05 if context.protocol_version >= 67 else \
|
||||||
0x0C
|
0x0C
|
||||||
|
|
||||||
packet_name = 'spawn player'
|
packet_name = 'spawn player'
|
||||||
@@ -208,7 +216,8 @@ class SpawnPlayerPacket(Packet):
|
|||||||
class EntityVelocityPacket(Packet):
|
class EntityVelocityPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x47 if context.protocol_version >= 707 else \
|
return 0x46 if context.protocol_version >= 722 else \
|
||||||
|
0x47 if context.protocol_version >= 707 else \
|
||||||
0x46 if context.protocol_version >= 550 else \
|
0x46 if context.protocol_version >= 550 else \
|
||||||
0x45 if context.protocol_version >= 471 else \
|
0x45 if context.protocol_version >= 471 else \
|
||||||
0x41 if context.protocol_version >= 461 else \
|
0x41 if context.protocol_version >= 461 else \
|
||||||
@@ -232,10 +241,42 @@ class EntityVelocityPacket(Packet):
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
class EntityPositionDeltaPacket(Packet):
|
||||||
|
@staticmethod
|
||||||
|
def get_id(context):
|
||||||
|
return 0x28 if context.protocol_version >= 722 else \
|
||||||
|
0x29 if context.protocol_version >= 578 else \
|
||||||
|
0xFF
|
||||||
|
|
||||||
|
packet_name = "entity position delta"
|
||||||
|
get_definition = staticmethod(lambda context: [
|
||||||
|
{'entity_id': VarInt},
|
||||||
|
{'delta_x': Short},
|
||||||
|
{'delta_y': Short},
|
||||||
|
{'delta_z': Short},
|
||||||
|
{'on_ground': Boolean}
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
class TimeUpdatePacket(Packet):
|
||||||
|
@staticmethod
|
||||||
|
def get_id(context):
|
||||||
|
return 0x4E if context.protocol_version >= 722 else \
|
||||||
|
0x4F if context.protocol_version >= 578 else \
|
||||||
|
0xFF
|
||||||
|
|
||||||
|
packet_name = "time update"
|
||||||
|
get_definition = staticmethod(lambda context: [
|
||||||
|
{'world_age': Long},
|
||||||
|
{'time_of_day': Long},
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
class UpdateHealthPacket(Packet):
|
class UpdateHealthPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x4A if context.protocol_version >= 707 else \
|
return 0x49 if context.protocol_version >= 722 else \
|
||||||
|
0x4A if context.protocol_version >= 707 else \
|
||||||
0x49 if context.protocol_version >= 550 else \
|
0x49 if context.protocol_version >= 550 else \
|
||||||
0x48 if context.protocol_version >= 471 else \
|
0x48 if context.protocol_version >= 471 else \
|
||||||
0x44 if context.protocol_version >= 461 else \
|
0x44 if context.protocol_version >= 461 else \
|
||||||
@@ -261,7 +302,8 @@ class UpdateHealthPacket(Packet):
|
|||||||
class RespawnPacket(Packet):
|
class RespawnPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x3B if context.protocol_version >= 550 else \
|
return 0x3A if context.protocol_version >= 722 else \
|
||||||
|
0x3B if context.protocol_version >= 550 else \
|
||||||
0x3A if context.protocol_version >= 471 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 \
|
||||||
@@ -295,7 +337,8 @@ class RespawnPacket(Packet):
|
|||||||
class PluginMessagePacket(AbstractPluginMessagePacket):
|
class PluginMessagePacket(AbstractPluginMessagePacket):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x19 if context.protocol_version >= 550 else \
|
return 0x18 if context.protocol_version >= 722 else \
|
||||||
|
0x19 if context.protocol_version >= 550 else \
|
||||||
0x18 if context.protocol_version >= 471 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 \
|
||||||
@@ -307,7 +350,8 @@ class PluginMessagePacket(AbstractPluginMessagePacket):
|
|||||||
class PlayerListHeaderAndFooterPacket(Packet):
|
class PlayerListHeaderAndFooterPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x54 if context.protocol_version >= 550 else \
|
return 0x53 if context.protocol_version >= 722 else \
|
||||||
|
0x54 if context.protocol_version >= 550 else \
|
||||||
0x53 if context.protocol_version >= 471 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 \
|
||||||
@@ -328,7 +372,8 @@ class PlayerListHeaderAndFooterPacket(Packet):
|
|||||||
class EntityLookPacket(Packet):
|
class EntityLookPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x2B if context.protocol_version >= 550 else \
|
return 0x2A if context.protocol_version >= 722 else \
|
||||||
|
0x2B if context.protocol_version >= 550 else \
|
||||||
0x2A if context.protocol_version >= 389 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 \
|
||||||
|
|||||||
@@ -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 0x0C if context.protocol_version >= 550 else \
|
return 0x0B if context.protocol_version >= 722 else \
|
||||||
|
0x0C if context.protocol_version >= 550 else \
|
||||||
0x0B if context.protocol_version >= 332 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 \
|
||||||
@@ -46,7 +47,8 @@ class BlockChangePacket(Packet):
|
|||||||
class MultiBlockChangePacket(Packet):
|
class MultiBlockChangePacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x10 if context.protocol_version >= 550 else \
|
return 0x0F if context.protocol_version >= 722 else \
|
||||||
|
0x10 if context.protocol_version >= 550 else \
|
||||||
0x0F if context.protocol_version >= 343 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 \
|
||||||
|
|||||||
@@ -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 0x33 if context.protocol_version >= 550 else \
|
return 0x32 if context.protocol_version >= 722 else \
|
||||||
|
0x33 if context.protocol_version >= 550 else \
|
||||||
0x32 if context.protocol_version >= 471 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 \
|
||||||
|
|||||||
@@ -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 0x1D if context.protocol_version >= 550 else \
|
return 0x1C if context.protocol_version >= 722 else \
|
||||||
|
0x1D if context.protocol_version >= 550 else \
|
||||||
0x1C if context.protocol_version >= 471 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 \
|
||||||
|
|||||||
@@ -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 0x35 if context.protocol_version >= 550 else \
|
return 0x34 if context.protocol_version >= 722 else \
|
||||||
|
0x35 if context.protocol_version >= 550 else \
|
||||||
0x34 if context.protocol_version >= 471 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 \
|
||||||
|
|||||||
@@ -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 0x27 if context.protocol_version >= 550 else \
|
return 0x26 if context.protocol_version >= 722 else \
|
||||||
|
0x27 if context.protocol_version >= 550 else \
|
||||||
0x26 if context.protocol_version >= 389 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 \
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ from minecraft.networking.types import (
|
|||||||
class PlayerListItemPacket(Packet):
|
class PlayerListItemPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x34 if context.protocol_version >= 550 else \
|
return 0x33 if context.protocol_version >= 722 else \
|
||||||
|
0x34 if context.protocol_version >= 550 else \
|
||||||
0x33 if context.protocol_version >= 471 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 \
|
||||||
|
|||||||
@@ -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 0x36 if context.protocol_version >= 550 else \
|
return 0x35 if context.protocol_version >= 722 else \
|
||||||
|
0x36 if context.protocol_version >= 550 else \
|
||||||
0x35 if context.protocol_version >= 471 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 \
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ __all__ = 'SoundEffectPacket',
|
|||||||
class SoundEffectPacket(Packet):
|
class SoundEffectPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x52 if context.protocol_version >= 550 else \
|
return 0x51 if context.protocol_version >= 722 else \
|
||||||
|
0x52 if context.protocol_version >= 550 else \
|
||||||
0x51 if context.protocol_version >= 471 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 \
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class SpawnObjectPacket(Packet):
|
|||||||
return getattr(cls, name)
|
return getattr(cls, name)
|
||||||
|
|
||||||
class EntityType(Enum):
|
class EntityType(Enum):
|
||||||
|
# XXX This has not been updated for >= v1.15
|
||||||
ACTIVATED_TNT = 50 if pv < 458 else 55 # PrimedTnt
|
ACTIVATED_TNT = 50 if pv < 458 else 55 # PrimedTnt
|
||||||
AREA_EFFECT_CLOUD = 3 if pv < 458 else 0
|
AREA_EFFECT_CLOUD = 3 if pv < 458 else 0
|
||||||
ARMORSTAND = 78 if pv < 458 else 1
|
ARMORSTAND = 78 if pv < 458 else 1
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ class Packet(object):
|
|||||||
str = type(self).__name__
|
str = type(self).__name__
|
||||||
if self.id is not None:
|
if self.id is not None:
|
||||||
str = '0x%02X %s' % (self.id, str)
|
str = '0x%02X %s' % (self.id, str)
|
||||||
|
elif hasattr(self, "packet_id"):
|
||||||
|
str = 'pkt: 0x%02X %s' % (self.packet_id, str)
|
||||||
fields = self.fields
|
fields = self.fields
|
||||||
if fields is not None:
|
if fields is not None:
|
||||||
inner_str = ', '.join('%s=%s' % (a, self.field_string(a))
|
inner_str = ', '.join('%s=%s' % (a, self.field_string(a))
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from minecraft.networking.packets import (
|
|||||||
from minecraft.networking.types import (
|
from minecraft.networking.types import (
|
||||||
Double, Float, Boolean, VarInt, String, Byte, Position, Enum,
|
Double, Float, Boolean, VarInt, String, Byte, Position, Enum,
|
||||||
RelativeHand, BlockFace, Vector, Direction, PositionAndLook,
|
RelativeHand, BlockFace, Vector, Direction, PositionAndLook,
|
||||||
multi_attribute_alias
|
multi_attribute_alias, Short
|
||||||
)
|
)
|
||||||
|
|
||||||
from .client_settings_packet import ClientSettingsPacket
|
from .client_settings_packet import ClientSettingsPacket
|
||||||
@@ -126,7 +126,8 @@ class TeleportConfirmPacket(Packet):
|
|||||||
class AnimationPacket(Packet):
|
class AnimationPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x2A if context.protocol_version >= 468 else \
|
return 0x2B if context.protocol_version >= 719 else \
|
||||||
|
0x2A if context.protocol_version >= 468 else \
|
||||||
0x29 if context.protocol_version >= 464 else \
|
0x29 if context.protocol_version >= 464 else \
|
||||||
0x27 if context.protocol_version >= 389 else \
|
0x27 if context.protocol_version >= 389 else \
|
||||||
0x25 if context.protocol_version >= 386 else \
|
0x25 if context.protocol_version >= 386 else \
|
||||||
@@ -237,7 +238,8 @@ class PlayerBlockPlacementPacket(Packet):
|
|||||||
class UseItemPacket(Packet):
|
class UseItemPacket(Packet):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_id(context):
|
def get_id(context):
|
||||||
return 0x2D if context.protocol_version >= 468 else \
|
return 0x2E if context.protocol_version >= 719 else \
|
||||||
|
0x2D if context.protocol_version >= 468 else \
|
||||||
0x2C if context.protocol_version >= 464 else \
|
0x2C if context.protocol_version >= 464 else \
|
||||||
0x2A if context.protocol_version >= 389 else \
|
0x2A if context.protocol_version >= 389 else \
|
||||||
0x28 if context.protocol_version >= 386 else \
|
0x28 if context.protocol_version >= 386 else \
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ def get_options():
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="print sent and received packets to standard error")
|
help="print sent and received packets to standard error")
|
||||||
|
|
||||||
|
parser.add_option("-v", "--dump-unknown-packets", dest="dump_unknown",
|
||||||
|
action="store_true",
|
||||||
|
help="include unknown packets in --dump-packets output")
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if not options.username:
|
if not options.username:
|
||||||
@@ -82,6 +86,8 @@ def main():
|
|||||||
if type(packet) is Packet:
|
if type(packet) is Packet:
|
||||||
# This is a direct instance of the base Packet type, meaning
|
# This is a direct instance of the base Packet type, meaning
|
||||||
# that it is a packet of unknown type, so we do not print it.
|
# that it is a packet of unknown type, so we do not print it.
|
||||||
|
if options.dump_unknown:
|
||||||
|
print('--> ??? %s' % packet, file=sys.stderr)
|
||||||
return
|
return
|
||||||
print('--> %s' % packet, file=sys.stderr)
|
print('--> %s' % packet, file=sys.stderr)
|
||||||
|
|
||||||
|
|||||||
@@ -103,9 +103,8 @@ class FakeClientHandler(object):
|
|||||||
# 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, hashed_seed=12345,
|
entity_id=0, game_mode=0, dimension=0, hashed_seed=12345,
|
||||||
difficulty=2, max_players=1, level_type='default', is_debug=False,
|
difficulty=2, max_players=1, level_type='default',
|
||||||
is_flat=False, reduced_debug_info=False, render_distance=9,
|
reduced_debug_info=False, render_distance=9, respawn_screen=False))
|
||||||
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