mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
New way to spawn entities/tiles using a global register table, allow overriding default entity/tile classes via classes
This commit is contained in:
@ -21,10 +21,7 @@
|
||||
|
||||
namespace pocketmine\level\format\generic;
|
||||
|
||||
use pocketmine\entity\Arrow;
|
||||
use pocketmine\entity\DroppedItem;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\FallingBlock;
|
||||
use pocketmine\level\format\FullChunk;
|
||||
use pocketmine\level\format\LevelProvider;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
@ -116,27 +113,20 @@ abstract class BaseFullChunk implements FullChunk{
|
||||
foreach($this->NBTentities as $nbt){
|
||||
if($nbt instanceof Compound){
|
||||
if(!isset($nbt->id)){
|
||||
$this->setChanged();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(($nbt["Pos"][0] >> 4) !== $this->x or ($nbt["Pos"][2] >> 4) !== $this->z){
|
||||
$this->setChanged();
|
||||
continue; //Fixes entities allocated in wrong chunks.
|
||||
}
|
||||
|
||||
//TODO: add all entities
|
||||
switch($nbt["id"]){
|
||||
case DroppedItem::NETWORK_ID:
|
||||
case "Item":
|
||||
(new DroppedItem($this, $nbt))->spawnToAll();
|
||||
break;
|
||||
case Arrow::NETWORK_ID:
|
||||
case "Arrow":
|
||||
(new Arrow($this, $nbt))->spawnToAll();
|
||||
break;
|
||||
case FallingBlock::NETWORK_ID:
|
||||
case "FallingSand":
|
||||
(new FallingBlock($this, $nbt))->spawnToAll();
|
||||
break;
|
||||
if(($entity = Entity::createEntity($nbt["id"], $this, $nbt)) instanceof Entity){
|
||||
$entity->spawnToAll();
|
||||
}else{
|
||||
$this->setChanged();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -155,16 +145,9 @@ abstract class BaseFullChunk implements FullChunk{
|
||||
continue; //Fixes tiles allocated in wrong chunks.
|
||||
}
|
||||
|
||||
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;
|
||||
if(Tile::createTile($nbt["id"], $this, $nbt) === null){
|
||||
$this->setChanged();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user