2024-10-26 14:24:38 +01:00
|
|
|
import MaxUses from "../enums/MaxUses";
|
2023-11-05 00:55:23 +00:00
|
|
|
|
2024-10-26 14:24:38 +01:00
|
|
|
export default class Item {
|
2023-11-02 08:31:43 +00:00
|
|
|
public static items:Array<Item> = new Array<Item>();
|
|
|
|
|
2023-04-11 01:53:33 +01:00
|
|
|
public maxStackSize:number;
|
2023-11-05 00:55:23 +00:00
|
|
|
public maxDamage:number;
|
2023-04-11 01:53:33 +01:00
|
|
|
public shiftedItemID:number;
|
2023-11-02 08:31:43 +00:00
|
|
|
public name:string;
|
2023-04-11 01:53:33 +01:00
|
|
|
|
|
|
|
public constructor(itemID:number) {
|
|
|
|
this.shiftedItemID = 256 + itemID;
|
2023-11-05 00:55:23 +00:00
|
|
|
this.maxDamage = 0;
|
2023-04-11 01:53:33 +01:00
|
|
|
this.maxStackSize = 64;
|
2023-11-02 08:31:43 +00:00
|
|
|
this.name = "UNNAMED";
|
|
|
|
|
|
|
|
Item.items[itemID] = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static getByShiftedItemId(shiftedItemID:number) {
|
|
|
|
return Item.items[shiftedItemID - 256];
|
2023-04-11 01:53:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public setMaxStackSize(stackSize:number) {
|
|
|
|
this.maxStackSize = stackSize;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2023-11-05 00:55:23 +00:00
|
|
|
public getMaxDamage() {
|
|
|
|
return this.maxDamage;
|
|
|
|
}
|
|
|
|
|
|
|
|
public setMaxDamage(value:number) {
|
|
|
|
this.maxDamage = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2023-11-02 08:31:43 +00:00
|
|
|
public setName(name:string) {
|
|
|
|
this.name = name;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getName() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
|
2023-04-11 01:53:33 +01:00
|
|
|
// Define statics here
|
2023-11-05 00:55:23 +00:00
|
|
|
static ironShovel = new Item(0).setMaxDamage(MaxUses.IRON).setName("Iron Shovel");
|
|
|
|
static ironPickaxe = new Item(1).setMaxDamage(MaxUses.IRON).setName("Iron Pickaxe");
|
|
|
|
static ironAxe = new Item(2).setMaxDamage(MaxUses.IRON).setName("Iron Axe");
|
2024-10-27 13:00:20 +00:00
|
|
|
static flintAndSteel = new Item(3).setName("Flint and Steel");
|
|
|
|
static apple = new Item(4).setName("Apple");
|
|
|
|
static bow = new Item(5).setName("Bow");
|
|
|
|
static arrow = new Item(6).setName("Arrow");
|
|
|
|
static coal = new Item(7).setName("Coal");
|
|
|
|
static diamond = new Item(8).setName("Diamond");
|
|
|
|
static iron = new Item(9).setName("Iron Ingot");
|
|
|
|
static gold = new Item(10).setName("Gold Ingot");
|
2023-11-05 00:55:23 +00:00
|
|
|
static ironSword = new Item(11).setMaxDamage(MaxUses.IRON).setName("Iron Sword");
|
2024-10-27 13:00:20 +00:00
|
|
|
static woodenSword = new Item(12).setMaxDamage(MaxUses.WOOD).setName("Wooden Sword");
|
|
|
|
static woodenShovel = new Item(13).setMaxDamage(MaxUses.WOOD).setName("Wooden Shovel");
|
|
|
|
static woodenPickaxe = new Item(14).setMaxDamage(MaxUses.WOOD).setName("Wooden Pickaxe");
|
|
|
|
static woodenAxe = new Item(15).setMaxDamage(MaxUses.WOOD).setName("Wooden Axe");
|
2023-12-24 17:47:20 +00:00
|
|
|
|
|
|
|
static clay = new Item(81).setName("Clay");
|
2023-04-11 01:53:33 +01:00
|
|
|
}
|