Add support for Minecraft snapshots 18w03a-18w20c (protocol 354-377).
This commit is contained in:
1 parent
bca783115c
commit
52c0671f4f
4 files changed
+50
-29
No files matched your search
@@ -81,6 +81,30 @@ SUPPORTED_MINECRAFT_VERSIONS = {
|
|||||||
'17w50a': 351,
|
'17w50a': 351,
|
||||||
'18w01a': 352,
|
'18w01a': 352,
|
||||||
'18w02a': 353,
|
'18w02a': 353,
|
||||||
|
'18w03a': 354,
|
||||||
|
'18w03b': 355,
|
||||||
|
'18w05a': 356,
|
||||||
|
'18w06a': 357,
|
||||||
|
'18w07a': 358,
|
||||||
|
'18w07b': 359,
|
||||||
|
'18w07c': 360,
|
||||||
|
'18w08a': 361,
|
||||||
|
'18w08b': 362,
|
||||||
|
'18w09a': 363,
|
||||||
|
'18w10a': 364,
|
||||||
|
'18w10b': 365,
|
||||||
|
'18w10c': 366,
|
||||||
|
'18w10d': 367,
|
||||||
|
'18w11a': 368,
|
||||||
|
'18w14a': 369,
|
||||||
|
'18w14b': 370,
|
||||||
|
'18w15a': 371,
|
||||||
|
'18w16a': 372,
|
||||||
|
'18w19a': 373,
|
||||||
|
'18w19b': 374,
|
||||||
|
'18w20a': 375,
|
||||||
|
'18w20b': 376,
|
||||||
|
'18w20c': 377,
|
||||||
}
|
}
|
||||||
|
|
||||||
SUPPORTED_PROTOCOL_VERSIONS = \
|
SUPPORTED_PROTOCOL_VERSIONS = \
|
||||||
|
|||||||
@@ -54,9 +54,6 @@ class MultiBlockChangePacket(Packet):
|
|||||||
self.y = y_coordinate
|
self.y = y_coordinate
|
||||||
self.z = (horizontal_position & 0x0F)
|
self.z = (horizontal_position & 0x0F)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__repr__()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_subclass(cls, context):
|
def get_subclass(cls, context):
|
||||||
return MultiBlockChangePacket.OpaqueRecord \
|
return MultiBlockChangePacket.OpaqueRecord \
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from minecraft.networking.packets import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from minecraft.networking.types import (
|
from minecraft.networking.types import (
|
||||||
VarInt, Byte, Boolean, UnsignedByte, VarIntPrefixedByteArray
|
VarInt, Byte, Boolean, UnsignedByte, VarIntPrefixedByteArray, String
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -19,19 +19,17 @@ class MapPacket(Packet):
|
|||||||
packet_name = 'map'
|
packet_name = 'map'
|
||||||
|
|
||||||
class MapIcon(object):
|
class MapIcon(object):
|
||||||
__slots__ = 'type', 'direction', 'location'
|
__slots__ = 'type', 'direction', 'location', 'display_name'
|
||||||
|
|
||||||
def __init__(self, type, direction, location):
|
def __init__(self, type, direction, location, display_name=None):
|
||||||
self.type = type
|
self.type = type
|
||||||
self.direction = direction
|
self.direction = direction
|
||||||
self.location = location
|
self.location = location
|
||||||
|
self.display_name = display_name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return ('MapIcon(type=%s, direction=%s, location=%s)'
|
fs = ('%s=%r' % (at, getattr(self, at)) for at in self.__slots__)
|
||||||
% (self.type, self.direction, self.location))
|
return 'MapIcon(%s)' % ', '.join(fs)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__repr__()
|
|
||||||
|
|
||||||
class Map(object):
|
class Map(object):
|
||||||
__slots__ = ('id', 'scale', 'icons', 'pixels', 'width', 'height',
|
__slots__ = ('id', 'scale', 'icons', 'pixels', 'width', 'height',
|
||||||
@@ -47,11 +45,8 @@ class MapPacket(Packet):
|
|||||||
self.is_tracking_position = True
|
self.is_tracking_position = True
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return ('Map(id=%s, scale=%s, icons=%s, width=%s, height=%s)' % (
|
fs = ('%s=%r' % (at, getattr(self, at)) for at in self.__slots__)
|
||||||
self.id, self.scale, self.icons, self.width, self.height))
|
return 'Map(%s)' % ', '.join(fs)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__repr__()
|
|
||||||
|
|
||||||
class MapSet(object):
|
class MapSet(object):
|
||||||
__slots__ = 'maps_by_id'
|
__slots__ = 'maps_by_id'
|
||||||
@@ -60,12 +55,9 @@ class MapPacket(Packet):
|
|||||||
self.maps_by_id = dict()
|
self.maps_by_id = dict()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
maps = [str(map) for map in self.maps_by_id.values()]
|
maps = (str(map) for map in self.maps_by_id.values())
|
||||||
return 'MapSet(%s)' % ', '.join(maps)
|
return 'MapSet(%s)' % ', '.join(maps)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__repr__()
|
|
||||||
|
|
||||||
def read(self, file_object):
|
def read(self, file_object):
|
||||||
self.map_id = VarInt.read(file_object)
|
self.map_id = VarInt.read(file_object)
|
||||||
self.scale = Byte.read(file_object)
|
self.scale = Byte.read(file_object)
|
||||||
@@ -78,11 +70,22 @@ class MapPacket(Packet):
|
|||||||
icon_count = VarInt.read(file_object)
|
icon_count = VarInt.read(file_object)
|
||||||
self.icons = []
|
self.icons = []
|
||||||
for i in range(icon_count):
|
for i in range(icon_count):
|
||||||
|
if self.context.protocol_version >= 373:
|
||||||
|
type = VarInt.read(file_object)
|
||||||
|
else:
|
||||||
type, direction = divmod(UnsignedByte.read(file_object), 16)
|
type, direction = divmod(UnsignedByte.read(file_object), 16)
|
||||||
x = Byte.read(file_object)
|
x = Byte.read(file_object)
|
||||||
z = Byte.read(file_object)
|
z = Byte.read(file_object)
|
||||||
icon = MapPacket.MapIcon(type, direction, (x, z))
|
if self.context.protocol_version >= 373:
|
||||||
|
direction = UnsignedByte.read(file_object)
|
||||||
|
if self.context.protocol_version >= 364:
|
||||||
|
has_name = Boolean.read(file_object)
|
||||||
|
display_name = String.read(file_object) if has_name else None
|
||||||
|
else:
|
||||||
|
display_name = None
|
||||||
|
icon = MapPacket.MapIcon(type, direction, (x, z), display_name)
|
||||||
self.icons.append(icon)
|
self.icons.append(icon)
|
||||||
|
|
||||||
self.width = UnsignedByte.read(file_object)
|
self.width = UnsignedByte.read(file_object)
|
||||||
if self.width:
|
if self.width:
|
||||||
self.height = UnsignedByte.read(file_object)
|
self.height = UnsignedByte.read(file_object)
|
||||||
@@ -140,10 +143,7 @@ class MapPacket(Packet):
|
|||||||
self._write_buffer(socket, packet_buffer, compression_threshold)
|
self._write_buffer(socket, packet_buffer, compression_threshold)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'MapPacket(%s)' % ', '.join(
|
return '%sMapPacket(%s)' % (
|
||||||
'%s=%r' % (k, v)
|
('0x%02X ' % self.id) if self.id is not None else '',
|
||||||
for (k, v) in self.__dict__.items()
|
', '.join('%s=%r' % (k, v) for (k, v) in self.__dict__.items()
|
||||||
if k != 'pixels')
|
if k not in ('pixels', '_context', 'id', 'definition')))
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.__repr__()
|
|
||||||
@@ -102,7 +102,7 @@ class Packet(object):
|
|||||||
|
|
||||||
self._write_buffer(socket, packet_buffer, compression_threshold)
|
self._write_buffer(socket, packet_buffer, compression_threshold)
|
||||||
|
|
||||||
def __str__(self):
|
def __repr__(self):
|
||||||
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)
|
||||||
|
|||||||
Reference in new issue
Block a user