mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Entity: Fire EntitySpawnEvent/ItemSpawnEvent on the first entity tick, instead of in the constructor (#5314)
This allows plugins to modify the entity via setters in EntitySpawnEvent without their changes getting overwritten by setter calls directly after the 'new YourEntity' statement. As well as benefiting plugins, this also clears a path for a BC-breaking change in PM5 (to have the programmer use addEntity() to spawn entities, instead of the constructor doing it, which will improve on a number of data handling aspects). fixes #4973 This targets next-minor because it has some side effects on plugins that depended on the old behaviour, such as VanillaHopper, so it's not suitable for a patch release.
This commit is contained in:
@ -1343,6 +1343,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
|
||||
$this->lastUpdate = $currentTick;
|
||||
|
||||
if($this->justCreated){
|
||||
$this->onFirstUpdate($currentTick);
|
||||
}
|
||||
|
||||
if(!$this->isAlive() && $this->spawned){
|
||||
$this->onDeathUpdate($tickDiff);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user