Item.destroyOn

Function called when the item is used to the destroy a block.

class Item
bool
destroyOn

Return Value

Type: bool

true if the item is a tool and it has been consumed, false otherwise

Examples

auto dirt = new Blocks.Dirt();
auto sword = new Items.DiamondSword(Items.DiamondSword.DURABILITY - 2);
auto shovel = new Items.DiamondShovel(Items.DiamondShovel.DURABILITY - 2);

assert(sword.finished == false);
assert(shovel.finished == false);

sword.destroyOn(player, dirt);	// 2 uses
shovel.destroyOn(player, dirt);	// 1 use

assert(sword.finished == true);
assert(shovel.finished == false);

Meta