mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
Living: Do not use spl_object_id() for identifying effects
it's possible for these to have different IDs if they were cloned, serialized or copied between threads.
This commit is contained in:
parent
fe98b6c765
commit
20f092a685
@ -64,7 +64,6 @@ use function max;
|
||||
use function min;
|
||||
use function mt_getrandmax;
|
||||
use function mt_rand;
|
||||
use function spl_object_id;
|
||||
use function sqrt;
|
||||
use const M_PI;
|
||||
|
||||
@ -219,7 +218,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
* @param Effect $effectType
|
||||
*/
|
||||
public function removeEffect(Effect $effectType) : void{
|
||||
$index = spl_object_id($effectType);
|
||||
$index = $effectType->getId();
|
||||
if(isset($this->effects[$index])){
|
||||
$effect = $this->effects[$index];
|
||||
$hasExpired = $effect->hasExpired();
|
||||
@ -249,7 +248,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
* @return EffectInstance|null
|
||||
*/
|
||||
public function getEffect(Effect $effect) : ?EffectInstance{
|
||||
return $this->effects[spl_object_id($effect)] ?? null;
|
||||
return $this->effects[$effect->getId()] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -260,7 +259,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEffect(Effect $effect) : bool{
|
||||
return isset($this->effects[spl_object_id($effect)]);
|
||||
return isset($this->effects[$effect->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,8 +283,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
$oldEffect = null;
|
||||
$cancelled = false;
|
||||
|
||||
$type = $effect->getType();
|
||||
$index = spl_object_id($type);
|
||||
$index = $effect->getType()->getId();
|
||||
if(isset($this->effects[$index])){
|
||||
$oldEffect = $this->effects[$index];
|
||||
if(
|
||||
|
Loading…
x
Reference in New Issue
Block a user