From 25f8e8318be1ad15fefeac17bbb5636448b7b652 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 29 Sep 2014 13:08:49 +0200 Subject: [PATCH] Fixed Anvil levels duplicating saved entities --- src/pocketmine/entity/Arrow.php | 4 +- src/pocketmine/entity/DroppedItem.php | 1 + .../level/format/generic/BaseChunk.php | 45 +------------------ 3 files changed, 5 insertions(+), 45 deletions(-) diff --git a/src/pocketmine/entity/Arrow.php b/src/pocketmine/entity/Arrow.php index 6a180289f..de1224719 100644 --- a/src/pocketmine/entity/Arrow.php +++ b/src/pocketmine/entity/Arrow.php @@ -161,8 +161,7 @@ class Arrow extends Projectile{ } public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ - $this->setLastDamageCause($source); - $this->setHealth($this->getHealth() - $damage); + } public function heal($amount){ @@ -170,6 +169,7 @@ class Arrow extends Projectile{ } public function saveNBT(){ + parent::saveNBT(); $this->namedtag->Age = new Short("Age", $this->age); } diff --git a/src/pocketmine/entity/DroppedItem.php b/src/pocketmine/entity/DroppedItem.php index d35f7dd21..811efb826 100644 --- a/src/pocketmine/entity/DroppedItem.php +++ b/src/pocketmine/entity/DroppedItem.php @@ -114,6 +114,7 @@ class DroppedItem extends Entity{ } public function saveNBT(){ + parent::saveNBT(); $this->namedtag->Item = new Compound("Item", [ "id" => new Short("id", $this->item->getID()), "Damage" => new Short("Damage", $this->item->getDamage()), diff --git a/src/pocketmine/level/format/generic/BaseChunk.php b/src/pocketmine/level/format/generic/BaseChunk.php index b5ab88648..f86f60750 100644 --- a/src/pocketmine/level/format/generic/BaseChunk.php +++ b/src/pocketmine/level/format/generic/BaseChunk.php @@ -98,49 +98,8 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ $this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a")); } - if($this->provider instanceof LevelProvider){ - $this->provider->getLevel()->timings->syncChunkLoadEntitiesTimer->startTiming(); - foreach($entities as $nbt){ - if($nbt instanceof Compound){ - if(!isset($nbt->id)){ - continue; - } - - //TODO: add all entities - if($nbt->id instanceof String){ //New format - switch($nbt["id"]){ - case "Item": - (new DroppedItem($this, $nbt))->spawnToAll(); - break; - } - }else{ //Old format - - } - } - } - $this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->stopTiming(); - - $this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->startTiming(); - foreach($tiles as $nbt){ - if($nbt instanceof Compound){ - if(!isset($nbt->id)){ - continue; - } - switch($nbt["id"]){ - case Tile::CHEST: - new Chest($this, $nbt); - break; - case Tile::FURNACE: - new Furnace($this, $nbt); - break; - case Tile::SIGN: - new Sign($this, $nbt); - break; - } - } - } - $this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->stopTiming(); - } + $this->NBTtiles = $tiles; + $this->NBTentities = $entities; } public function getBlock($x, $y, $z, &$blockId, &$meta = null){