Tool: cleanup durability handling, closes #379

long overdue... this isn't quite as extensible as the original api3/blocks system was, but this is primarily intended to replace Item->useOn(). If plugins want to use it it can be extended later on.
This commit is contained in:
Dylan K. Taylor
2018-05-10 19:48:51 +01:00
parent b8523cb304
commit b21572774a
13 changed files with 103 additions and 56 deletions

View File

@ -715,15 +715,6 @@ class Item implements ItemIds, \JsonSerializable{
return 0;
}
/**
* @param Entity|Block $object
*
* @return bool
*/
public function useOn($object){
return false;
}
/**
* Returns what type of block-breaking tool this is. Blocks requiring the same tool type as the item will break
* faster (except for blocks requiring no tool, which break at the same speed regardless of the tool used)
@ -814,6 +805,28 @@ class Item implements ItemIds, \JsonSerializable{
return false;
}
/**
* Called when this item is used to destroy a block. Usually used to update durability.
*
* @param Block $block
*
* @return bool
*/
public function onDestroyBlock(Block $block) : bool{
return false;
}
/**
* Called when this item is used to attack an entity. Usually used to update durability.
*
* @param Entity $victim
*
* @return bool
*/
public function onAttackEntity(Entity $victim) : bool{
return false;
}
/**
* Returns the number of ticks a player must wait before activating this item again.
*