From a5c023c78a887fa3de622bcd8fd7d3e0af9d9d76 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Wed, 13 Apr 2022 21:40:19 +0200 Subject: [PATCH] added item class --- src/lib/Item.hx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/lib/Item.hx diff --git a/src/lib/Item.hx b/src/lib/Item.hx new file mode 100644 index 0000000..854d337 --- /dev/null +++ b/src/lib/Item.hx @@ -0,0 +1,23 @@ +package lib; + +/** + Represents an item in the game. +**/ +abstract Item(String) 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 + // make sure to not use regex + this = name; + } + + @:from(String) + public static function fromString(s: String) { + return new Item(s); + } + + function getBase(): String { + return this.split(":")[0]; + } +}