diff --git a/src/pocketmine/block/BaseRail.php b/src/pocketmine/block/BaseRail.php index b7a0d96b6..682404a0e 100644 --- a/src/pocketmine/block/BaseRail.php +++ b/src/pocketmine/block/BaseRail.php @@ -264,7 +264,7 @@ abstract class BaseRail extends Flowable{ } $this->connections = $connections; - $this->level->setBlock($this, $this, false, false); //avoid recursion + $this->level->setBlock($this, $this, false); //avoid recursion } public function onNearbyBlockChange() : void{ diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index 658433ab1..9586015a0 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -96,11 +96,11 @@ class Bed extends Transparent{ public function setOccupied(bool $occupied = true){ $this->occupied = $occupied; - $this->level->setBlock($this, $this, false, false); + $this->level->setBlock($this, $this, false); if(($other = $this->getOtherHalf()) !== null){ $other->occupied = $occupied; - $this->level->setBlock($other, $other, false, false); + $this->level->setBlock($other, $other, false); } } @@ -170,7 +170,7 @@ class Bed extends Transparent{ parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); $nextState = clone $this; $nextState->head = true; - $this->getLevel()->setBlock($next, $nextState, true, true); + $this->getLevel()->setBlock($next, $nextState); Tile::createTile(Tile::BED, $this->getLevel(), TileBed::createNBT($this, $face, $item, $player)); Tile::createTile(Tile::BED, $this->getLevel(), TileBed::createNBT($next, $face, $item, $player)); diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 364e6be11..60c292045 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -198,7 +198,7 @@ class Block extends Position implements BlockIds, Metadatable{ * @return bool */ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ - return $this->getLevel()->setBlock($blockReplace, $this, true, true); + return $this->getLevel()->setBlock($blockReplace, $this); } /** @@ -266,7 +266,7 @@ class Block extends Position implements BlockIds, Metadatable{ * @return bool */ public function onBreak(Item $item, Player $player = null) : bool{ - return $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true, true); + return $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR)); } diff --git a/src/pocketmine/block/Cactus.php b/src/pocketmine/block/Cactus.php index 97c10529d..6e452d0b0 100644 --- a/src/pocketmine/block/Cactus.php +++ b/src/pocketmine/block/Cactus.php @@ -106,7 +106,7 @@ class Cactus extends Transparent{ if($b->getId() === self::AIR){ Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, BlockFactory::get(Block::CACTUS))); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($b, $ev->getNewState(), true); + $this->getLevel()->setBlock($b, $ev->getNewState()); } } } diff --git a/src/pocketmine/block/Cake.php b/src/pocketmine/block/Cake.php index f082ba2bd..35862baca 100644 --- a/src/pocketmine/block/Cake.php +++ b/src/pocketmine/block/Cake.php @@ -89,7 +89,7 @@ class Cake extends Transparent implements FoodSource{ public function onNearbyBlockChange() : void{ if($this->getSide(Facing::DOWN)->getId() === self::AIR){ //Replace with common break method - $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR)); } } diff --git a/src/pocketmine/block/Crops.php b/src/pocketmine/block/Crops.php index 66866180f..5ce339e24 100644 --- a/src/pocketmine/block/Crops.php +++ b/src/pocketmine/block/Crops.php @@ -70,7 +70,7 @@ abstract class Crops extends Flowable{ Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block)); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($this, $ev->getNewState(), true, true); + $this->getLevel()->setBlock($this, $ev->getNewState()); } $item->count--; @@ -98,7 +98,7 @@ abstract class Crops extends Flowable{ Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block)); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($this, $ev->getNewState(), true, true); + $this->getLevel()->setBlock($this, $ev->getNewState()); } } } diff --git a/src/pocketmine/block/Dirt.php b/src/pocketmine/block/Dirt.php index fea10f3e2..2bc32e343 100644 --- a/src/pocketmine/block/Dirt.php +++ b/src/pocketmine/block/Dirt.php @@ -43,9 +43,9 @@ class Dirt extends Solid{ if($item instanceof Hoe){ $item->applyDamage(1); if($this->variant === self::COARSE){ - $this->getLevel()->setBlock($this, BlockFactory::get(Block::DIRT), true); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::DIRT)); }else{ - $this->getLevel()->setBlock($this, BlockFactory::get(Block::FARMLAND), true); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::FARMLAND)); } return true; diff --git a/src/pocketmine/block/Door.php b/src/pocketmine/block/Door.php index 31edd423d..1d081680f 100644 --- a/src/pocketmine/block/Door.php +++ b/src/pocketmine/block/Door.php @@ -143,9 +143,9 @@ abstract class Door extends Transparent{ public function onNearbyBlockChange() : void{ if($this->getSide(Facing::DOWN)->getId() === self::AIR){ //Replace with common break method - $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR)); if($this->getSide(Facing::UP) instanceof Door){ - $this->getLevel()->setBlock($this->getSide(Facing::UP), BlockFactory::get(Block::AIR), false); + $this->getLevel()->setBlock($this->getSide(Facing::UP), BlockFactory::get(Block::AIR)); } } } @@ -173,7 +173,7 @@ abstract class Door extends Transparent{ $topHalf->top = true; parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); - $this->level->setBlock($blockUp, $topHalf, true); //Top + $this->level->setBlock($blockUp, $topHalf); //Top return true; } @@ -187,10 +187,10 @@ abstract class Door extends Transparent{ $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); if($other instanceof Door and $this->getId() === $other->getId()){ $other->open = $this->open; - $this->level->setBlock($other, $other, true, true); + $this->level->setBlock($other, $other); } - $this->level->setBlock($this, $this, true, true); + $this->level->setBlock($this, $this); $this->level->addSound(new DoorSound($this)); return true; diff --git a/src/pocketmine/block/DoublePlant.php b/src/pocketmine/block/DoublePlant.php index 8f11b1e9c..caecc5c0a 100644 --- a/src/pocketmine/block/DoublePlant.php +++ b/src/pocketmine/block/DoublePlant.php @@ -54,10 +54,10 @@ class DoublePlant extends Flowable{ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ $id = $blockReplace->getSide(Facing::DOWN)->getId(); if(($id === Block::GRASS or $id === Block::DIRT) and $blockReplace->getSide(Facing::UP)->canBeReplaced()){ - $this->getLevel()->setBlock($blockReplace, $this, false, false); + $this->getLevel()->setBlock($blockReplace, $this, false); $top = clone $this; $top->top = true; - $this->getLevel()->setBlock($blockReplace->getSide(Facing::UP), $top, false, false); + $this->getLevel()->setBlock($blockReplace->getSide(Facing::UP), $top, false); return true; } diff --git a/src/pocketmine/block/Fallable.php b/src/pocketmine/block/Fallable.php index 990a13ebe..b9bc89571 100644 --- a/src/pocketmine/block/Fallable.php +++ b/src/pocketmine/block/Fallable.php @@ -31,7 +31,7 @@ abstract class Fallable extends Solid{ public function onNearbyBlockChange() : void{ $down = $this->getSide(Facing::DOWN); if($down->getId() === self::AIR or $down instanceof Liquid or $down instanceof Fire){ - $this->level->setBlock($this, BlockFactory::get(Block::AIR), true); + $this->level->setBlock($this, BlockFactory::get(Block::AIR)); $nbt = Entity::createBaseNBT($this->add(0.5, 0, 0.5)); $nbt->setInt("TileID", $this->getId()); diff --git a/src/pocketmine/block/Farmland.php b/src/pocketmine/block/Farmland.php index 0db8a649a..89c50a41c 100644 --- a/src/pocketmine/block/Farmland.php +++ b/src/pocketmine/block/Farmland.php @@ -69,7 +69,7 @@ class Farmland extends Transparent{ public function onNearbyBlockChange() : void{ if($this->getSide(Facing::UP)->isSolid()){ - $this->level->setBlock($this, BlockFactory::get(Block::DIRT), true); + $this->level->setBlock($this, BlockFactory::get(Block::DIRT)); } } @@ -81,13 +81,13 @@ class Farmland extends Transparent{ if(!$this->canHydrate()){ if($this->wetness > 0){ $this->wetness--; - $this->level->setBlock($this, $this, false, false); + $this->level->setBlock($this, $this, false); }else{ - $this->level->setBlock($this, BlockFactory::get(Block::DIRT), false, true); + $this->level->setBlock($this, BlockFactory::get(Block::DIRT)); } }elseif($this->wetness < 7){ $this->wetness = 7; - $this->level->setBlock($this, $this, false, false); + $this->level->setBlock($this, $this, false); } } diff --git a/src/pocketmine/block/FenceGate.php b/src/pocketmine/block/FenceGate.php index 5f14cdcd7..cd8878a45 100644 --- a/src/pocketmine/block/FenceGate.php +++ b/src/pocketmine/block/FenceGate.php @@ -102,7 +102,7 @@ class FenceGate extends Transparent{ } } - $this->getLevel()->setBlock($this, $this, true); + $this->getLevel()->setBlock($this, $this); $this->level->addSound(new DoorSound($this)); return true; } diff --git a/src/pocketmine/block/Fire.php b/src/pocketmine/block/Fire.php index 7aa4abd1f..f0757c87e 100644 --- a/src/pocketmine/block/Fire.php +++ b/src/pocketmine/block/Fire.php @@ -96,7 +96,7 @@ class Fire extends Flowable{ public function onNearbyBlockChange() : void{ if(!$this->getSide(Facing::DOWN)->isSolid() and !$this->hasAdjacentFlammableBlocks()){ - $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR)); }else{ $this->level->scheduleDelayedBlockUpdate($this, mt_rand(30, 40)); } diff --git a/src/pocketmine/block/FlowerPot.php b/src/pocketmine/block/FlowerPot.php index 2a07fd07d..e8b2eb8b3 100644 --- a/src/pocketmine/block/FlowerPot.php +++ b/src/pocketmine/block/FlowerPot.php @@ -93,7 +93,7 @@ class FlowerPot extends Flowable{ } $this->occupied = true; - $this->getLevel()->setBlock($this, $this, true, false); + $this->getLevel()->setBlock($this, $this, false); $pot->setItem($item->pop()); return true; diff --git a/src/pocketmine/block/Grass.php b/src/pocketmine/block/Grass.php index 954c5f9ba..b7c57158e 100644 --- a/src/pocketmine/block/Grass.php +++ b/src/pocketmine/block/Grass.php @@ -69,7 +69,7 @@ class Grass extends Solid{ //grass dies $this->level->getServer()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($this, $this, BlockFactory::get(Block::DIRT))); if(!$ev->isCancelled()){ - $this->level->setBlock($this, $ev->getNewState(), false, false); + $this->level->setBlock($this, $ev->getNewState(), false); } }elseif($lightAbove >= 9){ //try grass spread @@ -88,7 +88,7 @@ class Grass extends Solid{ $this->level->getServer()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($b = $this->level->getBlockAt($x, $y, $z), $this, BlockFactory::get(Block::GRASS))); if(!$ev->isCancelled()){ - $this->level->setBlock($b, $ev->getNewState(), false, false); + $this->level->setBlock($b, $ev->getNewState(), false); } } } diff --git a/src/pocketmine/block/GrassPath.php b/src/pocketmine/block/GrassPath.php index 9ec3737af..389d5ee58 100644 --- a/src/pocketmine/block/GrassPath.php +++ b/src/pocketmine/block/GrassPath.php @@ -54,7 +54,7 @@ class GrassPath extends Transparent{ public function onNearbyBlockChange() : void{ if($this->getSide(Facing::UP)->isSolid()){ - $this->level->setBlock($this, BlockFactory::get(Block::DIRT), true); + $this->level->setBlock($this, BlockFactory::get(Block::DIRT)); } } diff --git a/src/pocketmine/block/Ice.php b/src/pocketmine/block/Ice.php index fb100a4f7..f0b243a85 100644 --- a/src/pocketmine/block/Ice.php +++ b/src/pocketmine/block/Ice.php @@ -57,7 +57,7 @@ class Ice extends Transparent{ public function onBreak(Item $item, Player $player = null) : bool{ if(!$item->hasEnchantment(Enchantment::SILK_TOUCH)){ - return $this->getLevel()->setBlock($this, BlockFactory::get(Block::WATER), true); + return $this->getLevel()->setBlock($this, BlockFactory::get(Block::WATER)); } return parent::onBreak($item, $player); } diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index 11dd7fc4b..52e70d532 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -98,7 +98,7 @@ class Leaves extends Transparent{ public function onNearbyBlockChange() : void{ if(!$this->noDecay and !$this->checkDecay){ $this->checkDecay = true; - $this->getLevel()->setBlock($this, $this, true, false); + $this->getLevel()->setBlock($this, $this, false); } } @@ -111,7 +111,7 @@ class Leaves extends Transparent{ $this->getLevel()->getServer()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this)); if($ev->isCancelled() or $this->findLog($this)){ - $this->getLevel()->setBlock($this, $this, false, false); + $this->getLevel()->setBlock($this, $this, false); }else{ $this->getLevel()->useBreakOn($this); } diff --git a/src/pocketmine/block/Liquid.php b/src/pocketmine/block/Liquid.php index 978d3c520..ff8d20587 100644 --- a/src/pocketmine/block/Liquid.php +++ b/src/pocketmine/block/Liquid.php @@ -248,13 +248,13 @@ abstract class Liquid extends Transparent{ if($newDecay !== $this->decay or $falling !== $this->falling){ if(!$falling and $newDecay < 0){ - $this->level->setBlock($this, BlockFactory::get(Block::AIR), true, true); + $this->level->setBlock($this, BlockFactory::get(Block::AIR)); return; } $this->falling = $falling; $this->decay = $falling ? 0 : $newDecay; - $this->level->setBlock($this, $this, true, true); //local block update will cause an update to be scheduled + $this->level->setBlock($this, $this); //local block update will cause an update to be scheduled } } @@ -302,7 +302,7 @@ abstract class Liquid extends Transparent{ $new = clone $this; $new->falling = $falling; $new->decay = $falling ? 0 : $newFlowDecay; - $this->level->setBlock($block, $new, true, true); + $this->level->setBlock($block, $new); } } @@ -432,7 +432,7 @@ abstract class Liquid extends Transparent{ protected function liquidCollide(Block $cause, Block $result) : bool{ //TODO: add events - $this->level->setBlock($this, $result, true, true); + $this->level->setBlock($this, $result); $this->level->broadcastLevelSoundEvent($this->add(0.5, 0.5, 0.5), LevelSoundEventPacket::SOUND_FIZZ, (int) ((2.6 + (lcg_value() - lcg_value()) * 0.8) * 1000)); return true; } diff --git a/src/pocketmine/block/MelonStem.php b/src/pocketmine/block/MelonStem.php index aeb6eabc7..553230a3e 100644 --- a/src/pocketmine/block/MelonStem.php +++ b/src/pocketmine/block/MelonStem.php @@ -44,7 +44,7 @@ class MelonStem extends Crops{ ++$block->age; Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block)); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($this, $ev->getNewState(), true); + $this->getLevel()->setBlock($this, $ev->getNewState()); } }else{ foreach(Facing::HORIZONTAL as $side){ @@ -58,7 +58,7 @@ class MelonStem extends Crops{ if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){ Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, BlockFactory::get(Block::MELON_BLOCK))); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($side, $ev->getNewState(), true); + $this->getLevel()->setBlock($side, $ev->getNewState()); } } } diff --git a/src/pocketmine/block/NetherWartPlant.php b/src/pocketmine/block/NetherWartPlant.php index eb68dd3e7..e56dd19c5 100644 --- a/src/pocketmine/block/NetherWartPlant.php +++ b/src/pocketmine/block/NetherWartPlant.php @@ -85,7 +85,7 @@ class NetherWartPlant extends Flowable{ $this->getLevel()->getServer()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block)); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($this, $ev->getNewState(), false, true); + $this->getLevel()->setBlock($this, $ev->getNewState()); } } } diff --git a/src/pocketmine/block/PumpkinStem.php b/src/pocketmine/block/PumpkinStem.php index 1c916606b..13f8f93ec 100644 --- a/src/pocketmine/block/PumpkinStem.php +++ b/src/pocketmine/block/PumpkinStem.php @@ -44,7 +44,7 @@ class PumpkinStem extends Crops{ ++$block->age; Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block)); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($this, $ev->getNewState(), true); + $this->getLevel()->setBlock($this, $ev->getNewState()); } }else{ foreach(Facing::HORIZONTAL as $side){ @@ -58,7 +58,7 @@ class PumpkinStem extends Crops{ if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){ Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, BlockFactory::get(Block::PUMPKIN))); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($side, $ev->getNewState(), true); + $this->getLevel()->setBlock($side, $ev->getNewState()); } } } diff --git a/src/pocketmine/block/RedstoneOre.php b/src/pocketmine/block/RedstoneOre.php index 495634a3b..ffcef7ba1 100644 --- a/src/pocketmine/block/RedstoneOre.php +++ b/src/pocketmine/block/RedstoneOre.php @@ -65,7 +65,7 @@ class RedstoneOre extends Solid{ } public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ - return $this->getLevel()->setBlock($this, $this, true, false); + return $this->getLevel()->setBlock($this, $this, false); } public function onActivate(Item $item, Player $player = null) : bool{ diff --git a/src/pocketmine/block/Sapling.php b/src/pocketmine/block/Sapling.php index 3ec18bf9f..73e315ab6 100644 --- a/src/pocketmine/block/Sapling.php +++ b/src/pocketmine/block/Sapling.php @@ -85,7 +85,7 @@ class Sapling extends Flowable{ Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->getVariant()); }else{ $this->ready = true; - $this->getLevel()->setBlock($this, $this, true); + $this->getLevel()->setBlock($this, $this); } } } diff --git a/src/pocketmine/block/SignPost.php b/src/pocketmine/block/SignPost.php index b37ec9e84..c55f70662 100644 --- a/src/pocketmine/block/SignPost.php +++ b/src/pocketmine/block/SignPost.php @@ -79,7 +79,7 @@ class SignPost extends Transparent{ $this->rotation = $player !== null ? ((int) floor((($player->yaw + 180) * 16 / 360) + 0.5)) & 0x0f : 0; $ret = parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); }else{ - $ret = $this->getLevel()->setBlock($blockReplace, BlockFactory::get(Block::WALL_SIGN, $face), true); + $ret = $this->getLevel()->setBlock($blockReplace, BlockFactory::get(Block::WALL_SIGN, $face)); } if($ret){ diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index abe6561fc..5a09e6495 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -76,11 +76,11 @@ abstract class Slab extends Transparent{ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if($face === Facing::DOWN){ if($blockClicked instanceof Slab and $blockClicked->getId() === $this->getId() and $blockClicked->top and $blockClicked->getVariant() === $this->variant){ - $this->getLevel()->setBlock($blockClicked, BlockFactory::get($this->getDoubleSlabId(), $this->variant), true); + $this->getLevel()->setBlock($blockClicked, BlockFactory::get($this->getDoubleSlabId(), $this->variant)); return true; }elseif($blockReplace->getId() === $this->getId() and $blockReplace->getVariant() === $this->variant){ - $this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->getDoubleSlabId(), $this->variant), true); + $this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->getDoubleSlabId(), $this->variant)); return true; }else{ @@ -88,18 +88,18 @@ abstract class Slab extends Transparent{ } }elseif($face === Facing::UP){ if($blockClicked instanceof Slab and $blockClicked->getId() === $this->getId() and !$blockClicked->top and $blockClicked->getVariant() === $this->variant){ - $this->getLevel()->setBlock($blockClicked, BlockFactory::get($this->getDoubleSlabId(), $this->variant), true); + $this->getLevel()->setBlock($blockClicked, BlockFactory::get($this->getDoubleSlabId(), $this->variant)); return true; }elseif($blockReplace->getId() === $this->getId() and $blockReplace->getVariant() === $this->variant){ - $this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->getDoubleSlabId(), $this->variant), true); + $this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->getDoubleSlabId(), $this->variant)); return true; } }else{ //TODO: collision if($blockReplace->getId() === $this->getId()){ if($blockReplace->getVariant() === $this->variant){ - $this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->getDoubleSlabId(), $this->variant), true); + $this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->getDoubleSlabId(), $this->variant)); return true; } diff --git a/src/pocketmine/block/SnowLayer.php b/src/pocketmine/block/SnowLayer.php index faa73bab1..03759ef33 100644 --- a/src/pocketmine/block/SnowLayer.php +++ b/src/pocketmine/block/SnowLayer.php @@ -84,7 +84,7 @@ class SnowLayer extends Flowable{ public function onNearbyBlockChange() : void{ if(!$this->getSide(Facing::DOWN)->isSolid()){ - $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false, false); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false); } } @@ -94,7 +94,7 @@ class SnowLayer extends Flowable{ public function onRandomTick() : void{ if($this->level->getBlockLightAt($this->x, $this->y, $this->z) >= 12){ - $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false, false); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), false); } } diff --git a/src/pocketmine/block/StandingBanner.php b/src/pocketmine/block/StandingBanner.php index 5dc4b43da..e4b3ecc3d 100644 --- a/src/pocketmine/block/StandingBanner.php +++ b/src/pocketmine/block/StandingBanner.php @@ -79,7 +79,7 @@ class StandingBanner extends Transparent{ $this->rotation = ((int) floor((($player->yaw + 180) * 16 / 360) + 0.5)) & 0x0f; $ret = parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); }else{ - $ret = $this->getLevel()->setBlock($blockReplace, BlockFactory::get(Block::WALL_BANNER, $face), true); + $ret = $this->getLevel()->setBlock($blockReplace, BlockFactory::get(Block::WALL_BANNER, $face)); } if($ret){ diff --git a/src/pocketmine/block/Sugarcane.php b/src/pocketmine/block/Sugarcane.php index 70381022a..17b632350 100644 --- a/src/pocketmine/block/Sugarcane.php +++ b/src/pocketmine/block/Sugarcane.php @@ -67,13 +67,13 @@ class Sugarcane extends Flowable{ if($b->getId() === self::AIR){ Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, BlockFactory::get(Block::SUGARCANE_BLOCK))); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($b, $ev->getNewState(), true); + $this->getLevel()->setBlock($b, $ev->getNewState()); } break; } } $this->age = 0; - $this->getLevel()->setBlock($this, $this, true); + $this->getLevel()->setBlock($this, $this); } $item->count--; @@ -101,15 +101,15 @@ class Sugarcane extends Flowable{ for($y = 1; $y < 3; ++$y){ $b = $this->getLevel()->getBlockAt($this->x, $this->y + $y, $this->z); if($b->getId() === self::AIR){ - $this->getLevel()->setBlock($b, BlockFactory::get(Block::SUGARCANE_BLOCK), true); + $this->getLevel()->setBlock($b, BlockFactory::get(Block::SUGARCANE_BLOCK)); break; } } $this->age = 0; - $this->getLevel()->setBlock($this, $this, true); + $this->getLevel()->setBlock($this, $this); }else{ ++$this->age; - $this->getLevel()->setBlock($this, $this, true); + $this->getLevel()->setBlock($this, $this); } } } diff --git a/src/pocketmine/block/TNT.php b/src/pocketmine/block/TNT.php index 2a13c18af..57038bab3 100644 --- a/src/pocketmine/block/TNT.php +++ b/src/pocketmine/block/TNT.php @@ -68,7 +68,7 @@ class TNT extends Solid{ } public function ignite(int $fuse = 80){ - $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR)); $mot = (new Random())->nextSignedFloat() * M_PI * 2; $nbt = Entity::createBaseNBT($this->add(0.5, 0, 0.5), new Vector3(-sin($mot) * 0.02, 0.2, -cos($mot) * 0.02)); diff --git a/src/pocketmine/block/TallGrass.php b/src/pocketmine/block/TallGrass.php index f439a2204..0eab87c62 100644 --- a/src/pocketmine/block/TallGrass.php +++ b/src/pocketmine/block/TallGrass.php @@ -46,7 +46,7 @@ class TallGrass extends Flowable{ public function onNearbyBlockChange() : void{ if($this->getSide(Facing::DOWN)->isTransparent()){ //Replace with common break method - $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true, true); + $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR)); } } diff --git a/src/pocketmine/block/Trapdoor.php b/src/pocketmine/block/Trapdoor.php index 641f82e96..ba056ac7c 100644 --- a/src/pocketmine/block/Trapdoor.php +++ b/src/pocketmine/block/Trapdoor.php @@ -114,7 +114,7 @@ class Trapdoor extends Transparent{ public function onActivate(Item $item, Player $player = null) : bool{ $this->open = !$this->open; - $this->level->setBlock($this, $this, true); + $this->level->setBlock($this, $this); $this->level->addSound(new DoorSound($this)); return true; } diff --git a/src/pocketmine/entity/object/FallingBlock.php b/src/pocketmine/entity/object/FallingBlock.php index eb023b77c..9dc7b3e9e 100644 --- a/src/pocketmine/entity/object/FallingBlock.php +++ b/src/pocketmine/entity/object/FallingBlock.php @@ -115,7 +115,7 @@ class FallingBlock extends Entity{ }else{ $this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, $blockTarget ?? $this->block)); if(!$ev->isCancelled()){ - $this->getLevel()->setBlock($pos, $ev->getTo(), true); + $this->getLevel()->setBlock($pos, $ev->getTo()); } } $hasUpdate = true; diff --git a/src/pocketmine/item/Bucket.php b/src/pocketmine/item/Bucket.php index 133ccbb37..b7731ea1a 100644 --- a/src/pocketmine/item/Bucket.php +++ b/src/pocketmine/item/Bucket.php @@ -61,7 +61,7 @@ class Bucket extends Item implements Consumable{ $resultItem = ItemFactory::get(Item::BUCKET, $blockClicked->getFlowingForm()->getId()); $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $blockReplace, $face, $this, $resultItem)); if(!$ev->isCancelled()){ - $player->getLevel()->setBlock($blockClicked, BlockFactory::get(Block::AIR), true, true); + $player->getLevel()->setBlock($blockClicked, BlockFactory::get(Block::AIR)); $player->getLevel()->broadcastLevelSoundEvent($blockClicked->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound()); if($player->isSurvival()){ if($stack->getCount() === 0){ @@ -82,7 +82,7 @@ class Bucket extends Item implements Consumable{ }elseif($resultBlock instanceof Liquid and $blockReplace->canBeReplaced()){ $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketEmptyEvent($player, $blockReplace, $face, $this, ItemFactory::get(Item::BUCKET))); if(!$ev->isCancelled()){ - $player->getLevel()->setBlock($blockReplace, $resultBlock->getFlowingForm(), true, true); + $player->getLevel()->setBlock($blockReplace, $resultBlock->getFlowingForm()); $player->getLevel()->broadcastLevelSoundEvent($blockClicked->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound()); if($player->isSurvival()){ diff --git a/src/pocketmine/item/FlintSteel.php b/src/pocketmine/item/FlintSteel.php index 94b0098d7..ac9cb1456 100644 --- a/src/pocketmine/item/FlintSteel.php +++ b/src/pocketmine/item/FlintSteel.php @@ -38,7 +38,7 @@ class FlintSteel extends Tool{ if($blockReplace->getId() === self::AIR){ $level = $player->getLevel(); assert($level !== null); - $level->setBlock($blockReplace, BlockFactory::get(Block::FIRE), true); + $level->setBlock($blockReplace, BlockFactory::get(Block::FIRE)); $level->broadcastLevelSoundEvent($blockReplace->add(0.5, 0.5, 0.5), LevelSoundEventPacket::SOUND_IGNITE); $this->applyDamage(1); diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 13cbbb65a..9209100dc 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1475,21 +1475,16 @@ class Level implements ChunkManager, Metadatable{ * Sets on Vector3 the data from a Block object, * does block updates and puts the changes to the send queue. * - * If $direct is true, it'll send changes directly to players. if false, it'll be queued - * and the best way to send queued changes will be done in the next tick. - * This way big changes can be sent on a single chunk update packet instead of thousands of packets. - * * If $update is true, it'll get the neighbour blocks (6 sides) and update them. * If you are doing big changes, you might want to set this to false, then update manually. * * @param Vector3 $pos * @param Block $block - * @param bool $direct @deprecated * @param bool $update * * @return bool Whether the block has been updated or not */ - public function setBlock(Vector3 $pos, Block $block, bool $direct = false, bool $update = true) : bool{ + public function setBlock(Vector3 $pos, Block $block, bool $update = true) : bool{ $pos = $pos->floor(); if(!$this->isInWorld($pos->x, $pos->y, $pos->z)){ return false; @@ -1512,16 +1507,10 @@ class Level implements ChunkManager, Metadatable{ unset($this->blockCache[$chunkHash][$blockHash]); - if($direct){ - $this->sendBlocks($this->getChunkPlayers($pos->x >> 4, $pos->z >> 4), [$block]); - unset($this->chunkCache[$chunkHash], $this->changedBlocks[$chunkHash][$blockHash]); - }else{ - if(!isset($this->changedBlocks[$chunkHash])){ - $this->changedBlocks[$chunkHash] = []; - } - - $this->changedBlocks[$chunkHash][$blockHash] = $block; + if(!isset($this->changedBlocks[$chunkHash])){ + $this->changedBlocks[$chunkHash] = []; } + $this->changedBlocks[$chunkHash][$blockHash] = $block; foreach($this->getChunkLoaders($pos->x >> 4, $pos->z >> 4) as $loader){ $loader->onBlockChanged($block); diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index 2e4dbe79e..48369108e 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -146,7 +146,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{ $block = $this->getBlock(); if($block instanceof BlockFurnace and !$block->isLit()){ $block->setLit(true); - $this->getLevel()->setBlock($block, $block, true); + $this->getLevel()->setBlock($block, $block); } if($this->burnTime > 0 and $ev->isBurning()){ @@ -210,7 +210,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{ $block = $this->getBlock(); if($block instanceof BlockFurnace and $block->isLit()){ $block->setLit(false); - $this->getLevel()->setBlock($block, $block, true); + $this->getLevel()->setBlock($block, $block); } $this->burnTime = $this->cookTime = $this->maxTime = 0; }