2022-04-13 19:40:19 +00:00
|
|
|
package lib;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Represents an item in the game.
|
|
|
|
**/
|
2024-05-02 13:03:51 +00:00
|
|
|
enum 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];
|
|
|
|
}
|
2024-05-02 13:03:51 +00:00
|
|
|
|
|
|
|
var Coal = "minecraft:coal";
|
|
|
|
var Charcoal = "minecraft:charcoal";
|
2022-04-13 19:40:19 +00:00
|
|
|
}
|