mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Fixed block updates not getting broadcasted
This commit is contained in:
parent
0e36107878
commit
0be2bd911f
@ -23,6 +23,7 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\generator\object\TallGrass;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
@ -39,6 +40,10 @@ class Grass extends Solid{
|
||||
);
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){
|
||||
$item->count--;
|
||||
|
@ -318,7 +318,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
$pk = new SetTimePacket;
|
||||
$pk->time = (int) $this->time;
|
||||
$pk->started = $this->stopTime == false;
|
||||
$this->server->broadcastPacket($this->players, $pk);
|
||||
foreach($this->players as $player){
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -357,7 +359,6 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
$this->changedCount = [];
|
||||
|
||||
if(count($this->changedBlocks) > 0){
|
||||
foreach($this->changedBlocks as $index => $mini){
|
||||
foreach($mini as $blocks){
|
||||
@ -369,7 +370,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
$pk->z = $b->z;
|
||||
$pk->block = $b->getID();
|
||||
$pk->meta = $b->getDamage();
|
||||
$this->server->broadcastPacket($this->players, $pk);
|
||||
foreach($this->players as $player){
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -574,8 +577,11 @@ class Level implements ChunkManager, Metadatable{
|
||||
$pk->z = $pos->z;
|
||||
$pk->block = $block->getID();
|
||||
$pk->meta = $block->getDamage();
|
||||
$this->server->broadcastPacket($this->players, $pk);
|
||||
}elseif($direct === false){
|
||||
|
||||
foreach($this->players as $player){
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
}else{
|
||||
if(!($pos instanceof Position)){
|
||||
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
||||
}
|
||||
|
@ -79,6 +79,8 @@ interface ChunkSection{
|
||||
* @param int $z 0-15
|
||||
* @param int $blockId , if null, do not change
|
||||
* @param int $meta 0-15, if null, do not change
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setBlock($x, $y, $z, $blockId = null, $meta = null);
|
||||
|
||||
|
@ -83,8 +83,15 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
|
||||
public function setBlock($x, $y, $z, $blockId = null, $meta = null){
|
||||
$i = ($y << 8) + ($z << 4) + $x;
|
||||
|
||||
$changed = false;
|
||||
|
||||
if($blockId !== null){
|
||||
$this->blocks{$i} = chr($blockId);
|
||||
$blockId = chr($blockId);
|
||||
if($this->blocks{$i} !== $blockId){
|
||||
$this->blocks{$i} = $blockId;
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($meta !== null){
|
||||
@ -92,10 +99,18 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
$old_m = ord($this->data{$i});
|
||||
if(($x & 1) === 0){
|
||||
$this->data{$i} = chr(($old_m & 0xf0) | ($meta & 0x0f));
|
||||
if(($old_m & 0x0f) !== $meta){
|
||||
$changed = true;
|
||||
}
|
||||
}else{
|
||||
$this->data{$i} = chr((($meta & 0x0f) << 4) | ($old_m & 0x0f));
|
||||
if((($old_m & 0xf0) >> 4) !== $meta){
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $changed;
|
||||
}
|
||||
|
||||
public function getBlockSkyLight($x, $y, $z){
|
||||
|
@ -157,7 +157,7 @@ abstract class BaseChunk implements Chunk{
|
||||
}
|
||||
|
||||
public function setBlock($x, $y, $z, $blockId = null, $meta = null){
|
||||
$this->sections[$y >> 4]->setBlock($x, $y & 0x0f, $z, $blockId, $meta);
|
||||
return $this->sections[$y >> 4]->setBlock($x, $y & 0x0f, $z, $blockId & 0xff, $meta & 0x0f);
|
||||
}
|
||||
|
||||
public function getBlockId($x, $y, $z){
|
||||
|
Loading…
x
Reference in New Issue
Block a user