mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Player: fixed crash on action item return
this can happen if the old item had a lower max damage than the new one, and the new one has a damage higher than the old one's max damage. it can also happen if the damage was overridden to some illegal value by a custom item as seen in https://crash.pmmp.io/view/12754811
This commit is contained in:
parent
a554d2acf5
commit
b40b99fe72
@ -1641,7 +1641,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
$newReplica = clone $oldHeldItem;
|
$newReplica = clone $oldHeldItem;
|
||||||
$newReplica->setCount($newHeldItem->getCount());
|
$newReplica->setCount($newHeldItem->getCount());
|
||||||
if($newReplica instanceof Durable && $newHeldItem instanceof Durable){
|
if($newReplica instanceof Durable && $newHeldItem instanceof Durable){
|
||||||
$newReplica->setDamage($newHeldItem->getDamage());
|
$newDamage = $newHeldItem->getDamage();
|
||||||
|
if($newDamage >= 0 && $newDamage <= $newReplica->getMaxDurability()){
|
||||||
|
$newReplica->setDamage($newDamage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$damagedOrDeducted = $newReplica->equalsExact($newHeldItem);
|
$damagedOrDeducted = $newReplica->equalsExact($newHeldItem);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user