mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
SimpleSessionHandler: Do not read blocks from world in onFailedBlockAction()
the world will do this anyway, so we can reduce our code burden here.
This commit is contained in:
parent
d44ec702b0
commit
fa9fcea189
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\network\mcpe\handler;
|
namespace pocketmine\network\mcpe\handler;
|
||||||
|
|
||||||
use pocketmine\block\Block;
|
|
||||||
use pocketmine\block\ItemFrame;
|
use pocketmine\block\ItemFrame;
|
||||||
use pocketmine\block\Sign;
|
use pocketmine\block\Sign;
|
||||||
use pocketmine\block\utils\SignText;
|
use pocketmine\block\utils\SignText;
|
||||||
@ -298,16 +297,14 @@ class SimpleSessionHandler extends SessionHandler{
|
|||||||
private function onFailedBlockAction(Vector3 $blockPos, ?int $face) : void{
|
private function onFailedBlockAction(Vector3 $blockPos, ?int $face) : void{
|
||||||
$this->player->getInventory()->sendHeldItem($this->player);
|
$this->player->getInventory()->sendHeldItem($this->player);
|
||||||
if($blockPos->distanceSquared($this->player) < 10000){
|
if($blockPos->distanceSquared($this->player) < 10000){
|
||||||
$target = $this->player->getWorld()->getBlock($blockPos);
|
$blocks = $blockPos->sidesArray();
|
||||||
|
|
||||||
$blocks = $target->getAllSides();
|
|
||||||
if($face !== null){
|
if($face !== null){
|
||||||
$sideBlock = $target->getSide($face);
|
$sidePos = $blockPos->getSide($face);
|
||||||
|
|
||||||
/** @var Block[] $blocks */
|
/** @var Vector3[] $blocks */
|
||||||
array_push($blocks, ...$sideBlock->getAllSides()); //getAllSides() on each of these will include $target and $sideBlock because they are next to each other
|
array_push($blocks, ...$sidePos->sidesArray()); //getAllSides() on each of these will include $blockPos and $sidePos because they are next to each other
|
||||||
}else{
|
}else{
|
||||||
$blocks[] = $target;
|
$blocks[] = $blockPos;
|
||||||
}
|
}
|
||||||
$this->player->getWorld()->sendBlocks([$this->player], $blocks);
|
$this->player->getWorld()->sendBlocks([$this->player], $blocks);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user