mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Exterminate legacy item IDs
This commit is contained in:
@ -142,6 +142,7 @@ use function max;
|
||||
use function mb_strlen;
|
||||
use function microtime;
|
||||
use function min;
|
||||
use function morton2d_encode;
|
||||
use function preg_match;
|
||||
use function spl_object_id;
|
||||
use function sqrt;
|
||||
@ -641,7 +642,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
*/
|
||||
public function getItemCooldownExpiry(Item $item) : int{
|
||||
$this->checkItemCooldowns();
|
||||
return $this->usedItemsCooldown[$item->getId()] ?? 0;
|
||||
return $this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeTypeData())] ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -649,7 +650,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
*/
|
||||
public function hasItemCooldown(Item $item) : bool{
|
||||
$this->checkItemCooldowns();
|
||||
return isset($this->usedItemsCooldown[$item->getId()]);
|
||||
return isset($this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeTypeData())]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -658,7 +659,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
public function resetItemCooldown(Item $item, ?int $ticks = null) : void{
|
||||
$ticks = $ticks ?? $item->getCooldownTicks();
|
||||
if($ticks > 0){
|
||||
$this->usedItemsCooldown[$item->getId()] = $this->server->getTick() + $ticks;
|
||||
$this->usedItemsCooldown[morton2d_encode($item->getTypeId(), $item->computeTypeData())] = $this->server->getTick() + $ticks;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user