Add support for Minecraft 18w43a to 1.14 (protocols 441 to 477)
This commit introduces two backward-incompatible changes which may break existing code: (1) `networking.packets.clientbound.play.SpawnObjectPacket.EntityType' is no longer accessible as an attribute of the the `SpawnObjectPacket' class: the values now depend on a `ConnectionContext`, and must be accessed through an instance, or using `SpawnObjectPacket.field_enum'. See the text of the `AttributeError` raised from the descriptor for `SpawnObjectPacket.EntityType` for the full details. (2) For some subclasses of `networking.types.Type', it is necessary to call the methods `read_with_context' and `send_with_context' instead of `read' and `send', supplying a `ConnectionContext' for those data types - currently only `Position` - whose layout depends on it.
This commit is contained in:
1 parent
9b43d6f004
commit
612fa8e324
20 files changed
+463
-219
No files matched your search
@@ -61,7 +61,7 @@ class Packet(object):
|
||||
def read(self, file_object):
|
||||
for field in self.definition:
|
||||
for var_name, data_type in field.items():
|
||||
value = data_type.read(file_object)
|
||||
value = data_type.read_with_context(file_object, self.context)
|
||||
setattr(self, var_name, value)
|
||||
|
||||
# Writes a packet buffer to the socket with the appropriate headers
|
||||
@@ -104,7 +104,7 @@ class Packet(object):
|
||||
for field in self.definition:
|
||||
for var_name, data_type in field.items():
|
||||
data = getattr(self, var_name)
|
||||
data_type.send(data, packet_buffer)
|
||||
data_type.send_with_context(data, packet_buffer, self.context)
|
||||
|
||||
def __repr__(self):
|
||||
str = type(self).__name__
|
||||
@@ -129,7 +129,7 @@ class Packet(object):
|
||||
"""
|
||||
value = getattr(self, field, None)
|
||||
|
||||
enum_class = self.field_enum(field)
|
||||
enum_class = self.field_enum(field, self.context)
|
||||
if enum_class is not None:
|
||||
name = enum_class.name_from_value(value)
|
||||
if name is not None:
|
||||
@@ -138,7 +138,7 @@ class Packet(object):
|
||||
return repr(value)
|
||||
|
||||
@classmethod
|
||||
def field_enum(cls, field):
|
||||
def field_enum(cls, field, context=None):
|
||||
""" The subclass of 'minecraft.networking.types.Enum' associated with
|
||||
this field, or None if there is no such class.
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user