added item class

This commit is contained in:
Djeeberjr 2022-04-13 21:40:19 +02:00
parent 82939e53cc
commit a5c023c78a

23
src/lib/Item.hx Normal file
View File

@ -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];
}
}