mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 08:39:53 +00:00
Durable: Allow subclasses to override behaviour when the item breaks
This commit is contained in:
parent
c7f15a556d
commit
9551e5b8e5
@ -59,7 +59,7 @@ abstract class Durable extends Item{
|
|||||||
|
|
||||||
$this->meta = min($this->meta + $amount, $this->getMaxDurability());
|
$this->meta = min($this->meta + $amount, $this->getMaxDurability());
|
||||||
if($this->isBroken()){
|
if($this->isBroken()){
|
||||||
$this->pop();
|
$this->onBroken();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -82,6 +82,12 @@ abstract class Durable extends Item{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the item's damage exceeds its maximum durability.
|
||||||
|
*/
|
||||||
|
protected function onBroken() : void{
|
||||||
|
$this->pop();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum amount of damage this item can take before it breaks.
|
* Returns the maximum amount of damage this item can take before it breaks.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user