diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 295119c8..eb38ecc3 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1457,12 +1457,8 @@ class Entity extends Position }else{ $pk = new EntityEventPacket; $pk->eid = $this->eid; - $pk->event = 3; + $pk->event = EntityEventPacket::ENTITY_DEAD; $this->server->api->player->broadcastPacket($this->level->players, $pk); - $this->server->api->dhandle("entity.event", [ - "entity" => $this, - "event" => 3 - ]); // Entity dead } if($this->player instanceof Player){ $this->player->blocked = true; @@ -1474,7 +1470,7 @@ class Entity extends Position $this->server->api->ban->ban($this->player->username); } } else{ - $this->close(); + $this->server->api->schedule(40, [$this, "close"], []); } } diff --git a/src/entity/animal/Sheep.php b/src/entity/animal/Sheep.php index 049b0d6e..f337c778 100644 --- a/src/entity/animal/Sheep.php +++ b/src/entity/animal/Sheep.php @@ -34,7 +34,7 @@ class Sheep extends Animal{ } $pk = new EntityEventPacket; $pk->eid = $this->eid; - $pk->event = 10; + $pk->event = EntityEventPacket::ENTITY_ANIM_10; $this->server->api->player->broadcastPacket($this->level->players, $pk); $this->server->schedule(38, [$this, "setSheared"], false); $this->level->setblock(new Position($this->x, $this->y-1, $this->z, $this->level), new DirtBlock()); diff --git a/src/network/protocol/packet/EntityEventPacket.php b/src/network/protocol/packet/EntityEventPacket.php index fed2c035..c7faf41b 100644 --- a/src/network/protocol/packet/EntityEventPacket.php +++ b/src/network/protocol/packet/EntityEventPacket.php @@ -5,7 +5,8 @@ class EntityEventPacket extends RakNetDataPacket{ public $event; const ENTITY_DAMAGE = 2; - + const ENTITY_DEAD = 3; + const ENTITY_ANIM_10 = 10; public function pid(){ return ProtocolInfo::ENTITY_EVENT_PACKET; } diff --git a/src/world/LevelImport.php b/src/world/LevelImport.php index 08341a76..49f21773 100644 --- a/src/world/LevelImport.php +++ b/src/world/LevelImport.php @@ -86,13 +86,13 @@ class LevelImport{ } $chunks->map = null; $chunks = null; - if(file_exists$this->path . "level.dat") @unlink($this->path . "level.dat"); - if(file_exists$this->path . "level.dat_old") @unlink($this->path . "level.dat_old"); - if(file_exists$this->path . "player.dat") @unlink($this->path . "player.dat"); - if(file_exists$this->path . "entities.dat") @unlink($this->path . "entities.dat"); - if(file_exists$this->path . "chunks.dat") @unlink($this->path . "chunks.dat"); - if(file_exists$this->path . "chunks.dat.gz") @unlink($this->path . "chunks.dat.gz"); - if(file_exists$this->path . "tiles.dat") @unlink($this->path . "tiles.dat"); + if(file_exists($this->path . "level.dat")) @unlink($this->path . "level.dat"); + if(file_exists($this->path . "level.dat_old")) @unlink($this->path . "level.dat_old"); + if(file_exists($this->path . "player.dat")) @unlink($this->path . "player.dat"); + if(file_exists($this->path . "entities.dat")) @unlink($this->path . "entities.dat"); + if(file_exists($this->path . "chunks.dat")) @unlink($this->path . "chunks.dat"); + if(file_exists($this->path . "chunks.dat.gz")) @unlink($this->path . "chunks.dat.gz"); + if(file_exists($this->path . "tiles.dat")) @unlink($this->path . "tiles.dat"); unset($chunks, $level, $entities, $tiles, $nbt); return true; }