fix for double ( ( being merged

This commit is contained in:
əlemi 2021-10-13 01:30:23 +02:00 committed by alemidev
parent b09646deb1
commit 1d0716842c

View file

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