Allow ItemStack(s) to be compared
This commit is contained in:
parent
83f37a0621
commit
bb733ff2af
1 changed files with 13 additions and 0 deletions
|
@ -4,6 +4,9 @@ import { Player } from "../entities/Player";
|
|||
import { Item } from "../items/Item";
|
||||
|
||||
export class ItemStack {
|
||||
private static ITEMSTACK_ID_ADDER = 0;
|
||||
private readonly itemStackId:number;
|
||||
|
||||
public readonly itemID:number;
|
||||
public readonly isBlock:boolean;
|
||||
public size:number;
|
||||
|
@ -58,6 +61,16 @@ export class ItemStack {
|
|||
this.maxSize = this.isBlock ? 64 : Item.getByShiftedItemId(this.itemID).maxStackSize;
|
||||
this.maxDamage = this.isBlock ? 0 : Item.getByShiftedItemId(this.itemID).maxDamage;
|
||||
this.canBeDamaged = this.maxDamage > 0;
|
||||
|
||||
this.itemStackId = ItemStack.ITEMSTACK_ID_ADDER++;
|
||||
}
|
||||
|
||||
public static Compare(itemStack1:ItemStack, itemStack2:ItemStack) {
|
||||
return itemStack1.itemStackId === itemStack2.itemStackId;
|
||||
}
|
||||
|
||||
public compare(itemStack:ItemStack) {
|
||||
return this.itemStackId === itemStack.itemStackId;
|
||||
}
|
||||
|
||||
public insert(itemStack:ItemStack) {
|
||||
|
|
Loading…
Reference in a new issue