From d21a37c28b4cb3e5abe5df5d193f3290f4b47e7e Mon Sep 17 00:00:00 2001 From: alemidev Date: Fri, 10 Dec 2021 13:38:24 +0100 Subject: [PATCH] implemented bitfield and void types --- aiocraft/mc/types.py | 11 +++++++++++ compiler/proto.py | 3 +++ 2 files changed, 14 insertions(+) diff --git a/aiocraft/mc/types.py b/aiocraft/mc/types.py index 4b56bee..b1c0f0d 100644 --- a/aiocraft/mc/types.py +++ b/aiocraft/mc/types.py @@ -20,6 +20,17 @@ class Type(object): """Check if this type exists in this context""" return True +class VoidType(Type): + pytype : type = type(None) + + def write(self, v:None, buffer:io.BytesIO, ctx:object=None): + pass + + def read(self, buffer:io.BytesIO, ctx:object=None) -> None: + return None + +Void = VoidType() + class UnimplementedDataType(Type): pytype : type = bytes diff --git a/compiler/proto.py b/compiler/proto.py index fdae4b3..941e5fe 100644 --- a/compiler/proto.py +++ b/compiler/proto.py @@ -72,6 +72,7 @@ TYPE_MAP = { "position": Ref('Position'), "entityMetadataItem": Ref('EntityMetadataItem'), "entityMetadata": Ref('EntityMetadata'), + "void": Ref('Void'), } HINT_MAP = { @@ -138,6 +139,8 @@ def mctype(slot_type:Any) -> Ref: v["default"] if "default" in v and v['default'] != 'void' else None, ) # return SwitchType(mctype(v)) # TODO + elif t == "bitfield": + return Ref('Int') # elif t == "mapper": # ???? # return TrailingData else: