Fixed Anvil levels duplicating saved entities

This commit is contained in:
Shoghi Cervantes 2014-09-29 13:08:49 +02:00
parent 61d84c73d0
commit 25f8e8318b
3 changed files with 5 additions and 45 deletions

View File

@ -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);
}

View File

@ -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()),

View File

@ -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){