mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 00:09:39 +00:00
Level->sendBlocks() now syncs tiles
This commit is contained in:
parent
e1ef52c7c3
commit
eadb1d310e
@ -2254,13 +2254,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
|
|
||||||
$this->level->sendBlocks([$this], $blocks);
|
$this->level->sendBlocks([$this], $blocks);
|
||||||
|
|
||||||
foreach($blocks as $b){
|
|
||||||
$tile = $this->level->getTile($b);
|
|
||||||
if($tile instanceof Spawnable){
|
|
||||||
$tile->spawnTo($this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2490,7 +2483,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
throw new BadPacketException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
if(!$t->updateCompoundTag($compound, $this)){
|
if(!$t->updateCompoundTag($compound, $this)){
|
||||||
$t->spawnTo($this);
|
$this->level->sendBlocks([$this], [$pos]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2508,7 +2501,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
|
|
||||||
$ev->call();
|
$ev->call();
|
||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
$tile->spawnTo($this);
|
$this->level->sendBlocks([$this], [$tile]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,8 +975,12 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$fullBlock = $this->getFullBlock($b->x, $b->y, $b->z);
|
$fullBlock = $this->getFullBlock($b->x, $b->y, $b->z);
|
||||||
$pk->blockRuntimeId = BlockFactory::toStaticRuntimeId($fullBlock >> 4, $fullBlock & 0xf);
|
$pk->blockRuntimeId = BlockFactory::toStaticRuntimeId($fullBlock >> 4, $fullBlock & 0xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
$packets[] = $pk;
|
$packets[] = $pk;
|
||||||
|
|
||||||
|
$tile = $this->getTileAt($b->x, $b->y, $b->z);
|
||||||
|
if($tile instanceof Spawnable){
|
||||||
|
$packets[] = $tile->createSpawnPacket();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->server->broadcastPackets($target, $packets);
|
$this->server->broadcastPackets($target, $packets);
|
||||||
|
@ -50,16 +50,6 @@ abstract class Spawnable extends Tile{
|
|||||||
return $pk;
|
return $pk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function spawnTo(Player $player) : bool{
|
|
||||||
if($this->closed){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$player->sendDataPacket($this->createSpawnPacket());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags the tile as modified, so that updates will be broadcasted at the next available opportunity.
|
* Flags the tile as modified, so that updates will be broadcasted at the next available opportunity.
|
||||||
* This MUST be called any time a change is made that players must be able to see.
|
* This MUST be called any time a change is made that players must be able to see.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user