From df7991763d4738bf754e5f409ad33c9189c240ad Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Mon, 14 Oct 2024 21:42:52 +0200 Subject: [PATCH] added PaN --- src/lib/Item.hx | 7 ++----- src/lib/PaN.hx | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 src/lib/PaN.hx diff --git a/src/lib/Item.hx b/src/lib/Item.hx index 876fca0..61d8c4a 100644 --- a/src/lib/Item.hx +++ b/src/lib/Item.hx @@ -3,7 +3,8 @@ package lib; /** Represents an item in the game. **/ -enum abstract Item(String) to String { +@:forward +enum abstract Item(PaN) to String { public inline function new(name:String) { // Check if the name is valid. in the format `mod:item_name` e.g. `minecraft:apple` // TODO: implement @@ -16,10 +17,6 @@ enum abstract Item(String) to String { return new Item(s); } - function getBase():String { - return this.split(":")[0]; - } - var Coal = "minecraft:coal"; var Charcoal = "minecraft:charcoal"; } diff --git a/src/lib/PaN.hx b/src/lib/PaN.hx new file mode 100644 index 0000000..9ff99d9 --- /dev/null +++ b/src/lib/PaN.hx @@ -0,0 +1,18 @@ +package lib; + +/** + Provider and name. e.g. "minecraft:dirt", "mod:item", "minecraft:overworld" +**/ +abstract PaN(String) to String from String { + public inline function new(pan:String) { + this = pan; + } + + public function getProvider():String { + return this.split(":")[0]; + } + + public function getName():String { + return this.split(":")[1]; + } +}