added PaN

This commit is contained in:
Niklas Kapelle 2024-10-14 21:42:52 +02:00
parent e0f8d274e7
commit df7991763d
Signed by: niklas
GPG Key ID: 4EB651B36D841D16
2 changed files with 20 additions and 5 deletions

View File

@ -3,7 +3,8 @@ package lib;
/** /**
Represents an item in the game. Represents an item in the game.
**/ **/
enum abstract Item(String) to String { @:forward
enum abstract Item(PaN) to String {
public inline function new(name:String) { public inline function new(name:String) {
// Check if the name is valid. in the format `mod:item_name` e.g. `minecraft:apple` // Check if the name is valid. in the format `mod:item_name` e.g. `minecraft:apple`
// TODO: implement // TODO: implement
@ -16,10 +17,6 @@ enum abstract Item(String) to String {
return new Item(s); return new Item(s);
} }
function getBase():String {
return this.split(":")[0];
}
var Coal = "minecraft:coal"; var Coal = "minecraft:coal";
var Charcoal = "minecraft:charcoal"; var Charcoal = "minecraft:charcoal";
} }

18
src/lib/PaN.hx Normal file
View File

@ -0,0 +1,18 @@
package lib;
/**
Provider and name. e.g. "minecraft:dirt", "mod:item", "minecraft:overworld"
**/
abstract PaN(String) to String from String {
public inline function new(pan:String) {
this = pan;
}
public function getProvider():String {
return this.split(":")[0];
}
public function getName():String {
return this.split(":")[1];
}
}