mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +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\item\Item;
|
||||||
use pocketmine\level\generator\object\TallGrass;
|
use pocketmine\level\generator\object\TallGrass;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\utils\Random;
|
use pocketmine\utils\Random;
|
||||||
|
|
||||||
@ -39,6 +40,10 @@ class Grass extends Solid{
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onUpdate($type){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){
|
if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){
|
||||||
$item->count--;
|
$item->count--;
|
||||||
|
@ -318,7 +318,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$pk = new SetTimePacket;
|
$pk = new SetTimePacket;
|
||||||
$pk->time = (int) $this->time;
|
$pk->time = (int) $this->time;
|
||||||
$pk->started = $this->stopTime == false;
|
$pk->started = $this->stopTime == false;
|
||||||
$this->server->broadcastPacket($this->players, $pk);
|
foreach($this->players as $player){
|
||||||
|
$player->dataPacket($pk);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -357,7 +359,6 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->changedCount = [];
|
$this->changedCount = [];
|
||||||
|
|
||||||
if(count($this->changedBlocks) > 0){
|
if(count($this->changedBlocks) > 0){
|
||||||
foreach($this->changedBlocks as $index => $mini){
|
foreach($this->changedBlocks as $index => $mini){
|
||||||
foreach($mini as $blocks){
|
foreach($mini as $blocks){
|
||||||
@ -369,7 +370,9 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
$pk->z = $b->z;
|
$pk->z = $b->z;
|
||||||
$pk->block = $b->getID();
|
$pk->block = $b->getID();
|
||||||
$pk->meta = $b->getDamage();
|
$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->z = $pos->z;
|
||||||
$pk->block = $block->getID();
|
$pk->block = $block->getID();
|
||||||
$pk->meta = $block->getDamage();
|
$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)){
|
if(!($pos instanceof Position)){
|
||||||
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,8 @@ interface ChunkSection{
|
|||||||
* @param int $z 0-15
|
* @param int $z 0-15
|
||||||
* @param int $blockId , if null, do not change
|
* @param int $blockId , if null, do not change
|
||||||
* @param int $meta 0-15, 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);
|
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){
|
public function setBlock($x, $y, $z, $blockId = null, $meta = null){
|
||||||
$i = ($y << 8) + ($z << 4) + $x;
|
$i = ($y << 8) + ($z << 4) + $x;
|
||||||
|
|
||||||
|
$changed = false;
|
||||||
|
|
||||||
if($blockId !== null){
|
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){
|
if($meta !== null){
|
||||||
@ -92,12 +99,20 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
|||||||
$old_m = ord($this->data{$i});
|
$old_m = ord($this->data{$i});
|
||||||
if(($x & 1) === 0){
|
if(($x & 1) === 0){
|
||||||
$this->data{$i} = chr(($old_m & 0xf0) | ($meta & 0x0f));
|
$this->data{$i} = chr(($old_m & 0xf0) | ($meta & 0x0f));
|
||||||
|
if(($old_m & 0x0f) !== $meta){
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->data{$i} = chr((($meta & 0x0f) << 4) | ($old_m & 0x0f));
|
$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){
|
public function getBlockSkyLight($x, $y, $z){
|
||||||
$sl = ord($this->skyLight{($y << 7) + ($z << 3) + ($x >> 1)});
|
$sl = ord($this->skyLight{($y << 7) + ($z << 3) + ($x >> 1)});
|
||||||
if(($x & 1) === 0){
|
if(($x & 1) === 0){
|
||||||
|
@ -157,7 +157,7 @@ abstract class BaseChunk implements Chunk{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setBlock($x, $y, $z, $blockId = null, $meta = null){
|
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){
|
public function getBlockId($x, $y, $z){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user