public function onUnloadChunk(ChunkUnloadEvent $event) { if ($event->getLevel()->getName() !== "world_pvp") { return; } $chunk = $event->getChunk(); $hash = Level::chunkHash($chunk->getX(), $chunk->getZ()); if (isset($this->modelLocs[$hash])) { foreach ($this->modelLocs[$hash] as $id => $model) { if (isset($this->models[$id])) { $this->models[$id]->_kill(); unset($this->models[$id]); } } } if (isset($this->shopLocs[$hash])) { foreach ($this->shopLocs[$hash] as $col => $loc) { if (isset($this->shops[$col])) { $this->shops[$col]->_kill(); unset($this->shops[$col]); } } } if ($hash === $this->bowHash) { $this->bow->_kill(); $this->bow = null; } }
public function onUnload(ChunkUnloadEvent $event) { if ($event->getLevel() === $this->level) { foreach ($this->locs[Level::chunkHash($event->getChunk()->getX(), $event->getChunk()->getZ())] as $id => $spawn) { if (isset($this->spawns[$spawn->getId()])) { $this->level->removeEntity($this->spawns[$spawn->getId()]); } } } }