added item class
This commit is contained in:
parent
82939e53cc
commit
a5c023c78a
23
src/lib/Item.hx
Normal file
23
src/lib/Item.hx
Normal 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];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user