cc-haxe/src/lib/Item.hx

23 lines
442 B
Haxe
Raw Normal View History

2022-04-13 19:40:19 +00:00
package lib;
/**
Represents an item in the game.
**/
abstract Item(String) to String {
2023-07-30 13:55:22 +00:00
public inline function new(name:String) {
2022-04-13 19:40:19 +00:00
// 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)
2023-07-30 13:55:22 +00:00
public static function fromString(s:String) {
2022-04-13 19:40:19 +00:00
return new Item(s);
}
2023-07-30 13:55:22 +00:00
function getBase():String {
2022-04-13 19:40:19 +00:00
return this.split(":")[0];
}
}