diff --git a/compiler/proto.py b/compiler/proto.py index 9f79ac9..6c46d5a 100644 --- a/compiler/proto.py +++ b/compiler/proto.py @@ -11,7 +11,7 @@ from aiocraft.mc.mctypes import * DIR_MAP = {"toClient": "clientbound", "toServer": "serverbound"} PREFACE = """\"\"\"[!] This file is autogenerated\"\"\"\n\n""" -IMPORTS = """from typing import Tuple, Dict +IMPORTS = """from typing import Tuple, List, Dict from ....packet import Packet from ....mctypes import *\n""" IMPORT_ALL = """__all__ = [\n\t{all}\n]\n""" @@ -20,7 +20,7 @@ class {name}(Packet): {fields} _ids : Dict[int, int] = {ids} - _slots : Dict[int, Tuple[Tuple[str, Type]]] = {slots} + _slots : Dict[int, List[Tuple[str, Type]]] = {slots} """ TYPE_MAP = { @@ -45,10 +45,10 @@ TYPE_MAP = { def mctype(name:str) -> Type: if not isinstance(name, str): - return String # should return TrailingByteArray but still haven't implemented it (: + return TrailingByteArray if name in TYPE_MAP: return TYPE_MAP[name] - return String # should return TrailingByteArray but still haven't implemented it (: + return TrailingByteArray def snake_to_camel(name:str) -> str: return "".join(x.capitalize() for x in name.split("_")) @@ -201,7 +201,7 @@ def compile(): for slot in defn["slots"]: v_slots.append(parse_slot(slot)) fields.add(parse_field(slot)) - slots.append(f"{v} : ( {','.join(v_slots)} ),") + slots.append(f"{v} : [ {','.join(v_slots)} ],") with open(mc_path / f"proto/{state}/{direction}/{packet}.py", "w") as f: f.write(