From 6b2df0c27e0c5f24ab4c861e58c17455dd8467b0 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 24 Sep 2020 16:02:15 -0600 Subject: [PATCH] Fix hidden item metadata bug --- data.py | 1 - game.py | 5 +++-- protocol/managers.py | 6 +++++- protocol/types.py | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/data.py b/data.py index 4aff005..1d3bbb3 100644 --- a/data.py +++ b/data.py @@ -23,4 +23,3 @@ WINDOWS = { slot_diff=45, ), } - diff --git a/game.py b/game.py index 71a5d9b..162d60f 100644 --- a/game.py +++ b/game.py @@ -510,15 +510,16 @@ class Game: self.g.connection.write_packet(packet2) def handle_spawn_object(self, packet): - return + if packet.type_id != 37: return print(packet) def handle_entity_metadata(self, packet): return - if packet.metadata and packet.metadata[0].index == 1: return + if packet.metadata and packet.metadata[0].index != 7: return print(packet) def handle_spawn_living(self, packet): + return print(packet) def handle_entity_position(self, packet): diff --git a/protocol/managers.py b/protocol/managers.py index 69ea208..05da829 100644 --- a/protocol/managers.py +++ b/protocol/managers.py @@ -113,7 +113,10 @@ class ChatManager: elif 'text' in data: return data['text'] elif 'with' in data: - return '<{}> {}'.format(*[self.translate_chat(x) for x in data['with']]) + if len(data['with']) >= 2: + return '<{}> {}'.format(*[self.translate_chat(x) for x in data['with']]) + else: + return self.translate_chat(data['with'][0]) elif 'translate' in data: return data['translate'] else: @@ -127,6 +130,7 @@ class ChatManager: print('[%s] %s'%(source, text)) except Exception as ex: print('Exception %r on message (%s): %s' % (ex, chat_packet.field_string('position'), chat_packet.json_data)) + return if self.handler: self.handler((source, text)) diff --git a/protocol/types.py b/protocol/types.py index 1d4f681..b66b813 100644 --- a/protocol/types.py +++ b/protocol/types.py @@ -142,9 +142,11 @@ class Entry(Type): 1: VarInt, 2: Float, 3: String, + 5: Boolean, 6: Slot, 7: Boolean, 9: Position, + 18: VarInt, } def __init__(self, index, type, value):