mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 06:55:29 +00:00
Resend blocks around targeted blocks when interactions & block-break are cancelled, fixes #906
this solution is dumber but more effective (also solves the beds & doors placement problem)
This commit is contained in:
parent
04ba41c58c
commit
fc9c264e77
@ -2362,10 +2362,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
if($blockVector->distanceSquared($this) > 10000){
|
if($blockVector->distanceSquared($this) > 10000){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$target = $this->level->getBlock($blockVector);
|
$target = $this->level->getBlock($blockVector);
|
||||||
$block = $target->getSide($face);
|
$block = $target->getSide($face);
|
||||||
|
|
||||||
$this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
/** @var Block[] $blocks */
|
||||||
|
$blocks = array_merge($target->getAllSides(), $block->getAllSides()); //getAllSides() on each of these will include $target and $block because they are next to each other
|
||||||
|
|
||||||
|
$this->level->sendBlocks([$this], $blocks, UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK:
|
case InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK:
|
||||||
@ -2391,15 +2395,20 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->inventory->sendContents($this);
|
$this->inventory->sendContents($this);
|
||||||
$target = $this->level->getBlock($blockVector);
|
|
||||||
$tile = $this->level->getTile($blockVector);
|
|
||||||
|
|
||||||
$this->level->sendBlocks([$this], [$target], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
|
||||||
|
|
||||||
$this->inventory->sendHeldItem($this);
|
$this->inventory->sendHeldItem($this);
|
||||||
|
|
||||||
if($tile instanceof Spawnable){
|
$target = $this->level->getBlock($blockVector);
|
||||||
$tile->spawnTo($this);
|
/** @var Block[] $blocks */
|
||||||
|
$blocks = $target->getAllSides();
|
||||||
|
$blocks[] = $target;
|
||||||
|
|
||||||
|
$this->level->sendBlocks([$this], $blocks, UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||||
|
|
||||||
|
foreach($blocks as $b){
|
||||||
|
$tile = $this->level->getTile($blockVector);
|
||||||
|
if($tile instanceof Spawnable){
|
||||||
|
$tile->spawnTo($this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -445,6 +445,35 @@ class Block extends Position implements BlockIds, Metadatable{
|
|||||||
return BlockFactory::get(Block::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
|
return BlockFactory::get(Block::AIR, 0, Position::fromObject(Vector3::getSide($side, $step)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the 4 blocks on the horizontal axes around the block (north, south, east, west)
|
||||||
|
*
|
||||||
|
* @return Block[]
|
||||||
|
*/
|
||||||
|
public function getHorizontalSides() : array{
|
||||||
|
return [
|
||||||
|
$this->getSide(Vector3::SIDE_NORTH),
|
||||||
|
$this->getSide(Vector3::SIDE_SOUTH),
|
||||||
|
$this->getSide(Vector3::SIDE_WEST),
|
||||||
|
$this->getSide(Vector3::SIDE_EAST)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the six blocks around this block.
|
||||||
|
*
|
||||||
|
* @return Block[]
|
||||||
|
*/
|
||||||
|
public function getAllSides() : array{
|
||||||
|
return array_merge(
|
||||||
|
[
|
||||||
|
$this->getSide(Vector3::SIDE_DOWN),
|
||||||
|
$this->getSide(Vector3::SIDE_UP)
|
||||||
|
],
|
||||||
|
$this->getHorizontalSides()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user