aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'codegen/lib/utils.py')
-rw-r--r--codegen/lib/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/codegen/lib/utils.py b/codegen/lib/utils.py
index 8d1e8756..52c7206c 100644
--- a/codegen/lib/utils.py
+++ b/codegen/lib/utils.py
@@ -66,3 +66,15 @@ def group_packets(packets: list[PacketIdentifier]):
def get_dir_location(name: str):
return os.path.join(os.path.dirname(os.path.dirname(__file__)), name)
+
+def identifier_to_namespace(ident: str):
+ return ident.split(":")[0]
+def identifier_to_path(ident: str):
+ if ":" not in ident:
+ return ident
+
+ namespace, path = ident.lstrip("#").split(":")
+ if namespace in {"minecraft", "brigadier"}:
+ return path
+ # support for mods
+ return f"{namespace}_{path}"