diff --git a/src/block/Bamboo.php b/src/block/Bamboo.php index 9f605bca6..e0b62885d 100644 --- a/src/block/Bamboo.php +++ b/src/block/Bamboo.php @@ -116,7 +116,7 @@ class Bamboo extends Transparent{ } public function getModelPositionOffset() : ?Vector3{ - $seed = self::getOffsetSeed($this->position->getFloorX(), 0, $this->position->getFloorZ()); + $seed = self::getOffsetSeed($this->position->x, 0, $this->position->z); $retX = (($seed % 12) + 1) / 16; $retZ = ((($seed >> 8) % 12) + 1) / 16; return new Vector3($retX, 0, $retZ); @@ -135,7 +135,7 @@ class Bamboo extends Transparent{ private function seekToTop() : Bamboo{ $world = $this->position->getWorld(); $top = $this; - while(($next = $world->getBlock($top->position->up())) instanceof Bamboo && $next->hasSameTypeId($this)){ + while(($next = $world->getBlock($top->position->getSide(Facing::UP))) instanceof Bamboo && $next->hasSameTypeId($this)){ $top = $next; } return $top; @@ -144,7 +144,7 @@ class Bamboo extends Transparent{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($item instanceof Fertilizer){ $top = $this->seekToTop(); - if($top->grow(self::getMaxHeight($top->position->getFloorX(), $top->position->getFloorZ()), mt_rand(1, 2), $player)){ + if($top->grow(self::getMaxHeight($top->position->x, $top->position->z), mt_rand(1, 2), $player)){ $item->pop(); return true; } @@ -159,12 +159,12 @@ class Bamboo extends Transparent{ private function grow(int $maxHeight, int $growAmount, ?Player $player) : bool{ $world = $this->position->getWorld(); - if(!$world->getBlock($this->position->up())->canBeReplaced()){ + if(!$world->getBlock($this->position->getSide(Facing::UP))->canBeReplaced()){ return false; } $height = 1; - while($world->getBlock($this->position->subtract(0, $height, 0))->hasSameTypeId($this)){ + while($world->getBlock($this->position->getSide(Facing::DOWN, $height))->hasSameTypeId($this)){ if(++$height >= $maxHeight){ return false; } @@ -201,7 +201,7 @@ class Bamboo extends Transparent{ $tx = new BlockTransaction($world); foreach($newBlocks as $idx => $newBlock){ - $tx->addBlock($this->position->subtract(0, $idx - $growAmount, 0), $newBlock); + $tx->addBlock($this->position->getSide(Facing::DOWN, $idx - $growAmount), $newBlock); } $ev = new StructureGrowEvent($this, $tx, $player); @@ -221,10 +221,10 @@ class Bamboo extends Transparent{ $world = $this->position->getWorld(); if($this->ready){ $this->ready = false; - if($world->getFullLight($this->position) < 9 || !$this->grow(self::getMaxHeight($this->position->getFloorX(), $this->position->getFloorZ()), 1, null)){ + if($world->getFullLight($this->position) < 9 || !$this->grow(self::getMaxHeight($this->position->x, $this->position->z), 1, null)){ $world->setBlock($this->position, $this); } - }elseif($world->getBlock($this->position->up())->canBeReplaced()){ + }elseif($world->getBlock($this->position->getSide(Facing::UP))->canBeReplaced()){ $this->ready = true; $world->setBlock($this->position, $this); } diff --git a/src/block/BambooSapling.php b/src/block/BambooSapling.php index 67c8a24e0..a3ecf03c0 100644 --- a/src/block/BambooSapling.php +++ b/src/block/BambooSapling.php @@ -73,14 +73,14 @@ final class BambooSapling extends Flowable{ private function grow(?Player $player) : bool{ $world = $this->position->getWorld(); - if(!$world->getBlock($this->position->up())->canBeReplaced()){ + if(!$world->getBlock($this->position->getSide(Facing::UP))->canBeReplaced()){ return false; } $tx = new BlockTransaction($world); $bamboo = VanillaBlocks::BAMBOO(); $tx->addBlock($this->position, $bamboo) - ->addBlock($this->position->up(), (clone $bamboo)->setLeafSize(Bamboo::SMALL_LEAVES)); + ->addBlock($this->position->getSide(Facing::UP), (clone $bamboo)->setLeafSize(Bamboo::SMALL_LEAVES)); $ev = new StructureGrowEvent($this, $tx, $player); $ev->call(); @@ -102,7 +102,7 @@ final class BambooSapling extends Flowable{ if($world->getFullLight($this->position) < 9 || !$this->grow(null)){ $world->setBlock($this->position, $this); } - }elseif($world->getBlock($this->position->up())->canBeReplaced()){ + }elseif($world->getBlock($this->position->getSide(Facing::UP))->canBeReplaced()){ $this->ready = true; $world->setBlock($this->position, $this); } diff --git a/src/block/BaseBigDripleaf.php b/src/block/BaseBigDripleaf.php index f0ff59cf0..c90c54004 100644 --- a/src/block/BaseBigDripleaf.php +++ b/src/block/BaseBigDripleaf.php @@ -99,10 +99,10 @@ abstract class BaseBigDripleaf extends Transparent{ return false; } $pos = $head->position; - $up = $pos->up(); + $up = $pos->getSide(Facing::UP); $world = $pos->getWorld(); if( - !$world->isInWorld($up->getFloorX(), $up->getFloorY(), $up->getFloorZ()) || + !$world->isInWorld($up->x, $up->y, $up->z) || $world->getBlock($up)->getTypeId() !== BlockTypeIds::AIR ){ return false; diff --git a/src/block/BaseCoral.php b/src/block/BaseCoral.php index b9c595a97..969a07433 100644 --- a/src/block/BaseCoral.php +++ b/src/block/BaseCoral.php @@ -27,6 +27,7 @@ use pocketmine\block\utils\BlockEventHelper; use pocketmine\block\utils\CoralTypeTrait; use pocketmine\block\utils\SupportType; use pocketmine\item\Item; +use pocketmine\math\Facing; use function mt_rand; abstract class BaseCoral extends Transparent{ @@ -55,11 +56,9 @@ abstract class BaseCoral extends Transparent{ public function isSolid() : bool{ return false; } protected function isCoveredWithWater() : bool{ - $world = $this->position->getWorld(); - $hasWater = false; - foreach($this->position->sides() as $vector3){ - if($world->getBlock($vector3) instanceof Water){ + foreach(Facing::ALL as $side){ + if($this->getSide($side) instanceof Water){ $hasWater = true; break; } diff --git a/src/block/BaseSign.php b/src/block/BaseSign.php index 5a905f8b8..8613ddbc6 100644 --- a/src/block/BaseSign.php +++ b/src/block/BaseSign.php @@ -145,7 +145,7 @@ abstract class BaseSign extends Transparent{ private function changeSignGlowingState(bool $glowing, Player $player, Item $item) : bool{ if($this->text->isGlowing() !== $glowing && $this->doSignChange(new SignText($this->text->getLines(), $this->text->getBaseColor(), $glowing), $player, $item)){ - $this->position->getWorld()->addSound($this->position, new InkSacUseSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new InkSacUseSound()); return true; } return false; @@ -183,7 +183,7 @@ abstract class BaseSign extends Transparent{ $color->toARGB() !== $this->text->getBaseColor()->toARGB() && $this->doSignChange(new SignText($this->text->getLines(), $color, $this->text->isGlowing()), $player, $item) ){ - $this->position->getWorld()->addSound($this->position, new DyeUseSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new DyeUseSound()); return true; } }elseif(match($item->getTypeId()){ diff --git a/src/block/Bed.php b/src/block/Bed.php index 8efbdfe01..ebc31ded2 100644 --- a/src/block/Bed.php +++ b/src/block/Bed.php @@ -128,7 +128,7 @@ class Bed extends Transparent{ $player->sendMessage(TextFormat::GRAY . "This bed is incomplete"); return true; - }elseif($playerPos->distanceSquared($this->position) > 4 && $playerPos->distanceSquared($other->position) > 4){ + }elseif($playerPos->distanceSquared($this->position->asVector3()) > 4 && $playerPos->distanceSquared($other->position->asVector3()) > 4){ $player->sendMessage(KnownTranslationFactory::tile_bed_tooFar()->prefix(TextFormat::GRAY)); return true; } diff --git a/src/block/Bell.php b/src/block/Bell.php index 53a6fc7fb..0c677f347 100644 --- a/src/block/Bell.php +++ b/src/block/Bell.php @@ -143,10 +143,10 @@ final class Bell extends Transparent{ public function ring(int $faceHit) : void{ $world = $this->position->getWorld(); - $world->addSound($this->position, new BellRingSound()); + $world->addSound($this->position->asVector3(), new BellRingSound()); $tile = $world->getTile($this->position); if($tile instanceof TileBell){ - $world->broadcastPacketToViewers($this->position, $tile->createFakeUpdatePacket($faceHit)); + $world->broadcastPacketToViewers($this->position->asVector3(), $tile->createFakeUpdatePacket($faceHit)); } } diff --git a/src/block/BigDripleafHead.php b/src/block/BigDripleafHead.php index a9b87bf7f..948afc717 100644 --- a/src/block/BigDripleafHead.php +++ b/src/block/BigDripleafHead.php @@ -93,7 +93,7 @@ class BigDripleafHead extends BaseBigDripleaf{ public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{ if($this->leafState !== DripleafState::FULL_TILT){ $this->setTiltAndScheduleTick(DripleafState::FULL_TILT); - $this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new DripleafTiltDownSound()); } } @@ -101,13 +101,13 @@ class BigDripleafHead extends BaseBigDripleaf{ if($this->leafState !== DripleafState::STABLE){ if($this->leafState === DripleafState::FULL_TILT){ $this->position->getWorld()->setBlock($this->position, $this->setLeafState(DripleafState::STABLE)); - $this->position->getWorld()->addSound($this->position, new DripleafTiltUpSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new DripleafTiltUpSound()); }else{ $this->setTiltAndScheduleTick(match($this->leafState){ DripleafState::UNSTABLE => DripleafState::PARTIAL_TILT, DripleafState::PARTIAL_TILT => DripleafState::FULL_TILT, }); - $this->position->getWorld()->addSound($this->position, new DripleafTiltDownSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new DripleafTiltDownSound()); } } } diff --git a/src/block/Block.php b/src/block/Block.php index 89fe39265..d27ffccc0 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -73,7 +73,7 @@ class Block{ protected BlockIdentifier $idInfo; protected string $fallbackName; protected BlockTypeInfo $typeInfo; - protected Position $position; + protected BlockPosition $position; /** @var AxisAlignedBB[]|null */ protected ?array $collisionBoxes = null; @@ -107,7 +107,7 @@ class Block{ $this->idInfo = $idInfo; $this->fallbackName = $name; $this->typeInfo = $typeInfo; - $this->position = new Position(0, 0, 0, null); + $this->position = new BlockPosition(0, 0, 0, null); $calculator = new RuntimeDataSizeCalculator(); $this->describeBlockItemState($calculator); @@ -377,7 +377,7 @@ class Block{ */ public function writeStateToWorld() : void{ $world = $this->position->getWorld(); - $chunk = $world->getOrLoadChunkAtPosition($this->position); + $chunk = $world->loadChunk($this->position->x >> Chunk::COORD_BIT_SIZE, $this->position->z >> Chunk::COORD_BIT_SIZE); if($chunk === null){ throw new AssumptionFailedError("World::setBlock() should have loaded the chunk before calling this method"); } @@ -608,7 +608,7 @@ class Block{ return false; } - final public function getPosition() : Position{ + final public function getPosition() : BlockPosition{ return $this->position; } @@ -616,7 +616,7 @@ class Block{ * @internal */ final public function position(World $world, int $x, int $y, int $z) : void{ - $this->position = new Position($x, $y, $z, $world); + $this->position = new BlockPosition($x, $y, $z, $world); $this->collisionBoxes = null; } @@ -912,9 +912,9 @@ class Block{ if($this->collisionBoxes === null){ $this->collisionBoxes = $this->recalculateCollisionBoxes(); $extraOffset = $this->getModelPositionOffset(); - $offset = $extraOffset !== null ? $this->position->addVector($extraOffset) : $this->position; + [$dx, $dy, $dz] = $extraOffset !== null ? [$extraOffset->x, $extraOffset->y, $extraOffset->z] : [0, 0, 0]; foreach($this->collisionBoxes as $bb){ - $bb->offset($offset->x, $offset->y, $offset->z); + $bb->offset($this->position->x + $dx, $this->position->y + $dy, $this->position->z + $dz); } } diff --git a/src/block/Button.php b/src/block/Button.php index 73bd1d556..caa557610 100644 --- a/src/block/Button.php +++ b/src/block/Button.php @@ -67,7 +67,7 @@ abstract class Button extends Flowable{ $world = $this->position->getWorld(); $world->setBlock($this->position, $this); $world->scheduleDelayedBlockUpdate($this->position, $this->getActivationTime()); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new RedstonePowerOnSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new RedstonePowerOnSound()); } return true; @@ -78,7 +78,7 @@ abstract class Button extends Flowable{ $this->pressed = false; $world = $this->position->getWorld(); $world->setBlock($this->position, $this); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new RedstonePowerOffSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new RedstonePowerOffSound()); } } diff --git a/src/block/CakeWithCandle.php b/src/block/CakeWithCandle.php index 380d080c5..df558739b 100644 --- a/src/block/CakeWithCandle.php +++ b/src/block/CakeWithCandle.php @@ -76,6 +76,6 @@ class CakeWithCandle extends BaseCake{ public function onConsume(Living $consumer) : void{ parent::onConsume($consumer); - $this->position->getWorld()->dropItem($this->position->add(0.5, 0.5, 0.5), $this->getCandle()->asItem()); + $this->position->getWorld()->dropItem($this->position->asVector3()->add(0.5, 0.5, 0.5), $this->getCandle()->asItem()); } } diff --git a/src/block/Campfire.php b/src/block/Campfire.php index 9f4c42a9c..a9bbfdda7 100644 --- a/src/block/Campfire.php +++ b/src/block/Campfire.php @@ -185,7 +185,7 @@ class Campfire extends Transparent{ if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){ $item->pop(); $this->ignite(); - $this->position->getWorld()->addSound($this->position, new BlazeShootSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new BlazeShootSound()); return true; }elseif($item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){ if($item instanceof Durable){ @@ -205,7 +205,7 @@ class Campfire extends Transparent{ $ingredient->setCount(1); if(count($this->inventory->addItem($ingredient)) === 0){ $item->pop(); - $this->position->getWorld()->addSound($this->position, new ItemFrameAddItemSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new ItemFrameAddItemSound()); return true; } } @@ -259,26 +259,26 @@ class Campfire extends Transparent{ $this->inventory->setItem($slot, VanillaItems::AIR()); $this->setCookingTime($slot, 0); - $this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $ev->getResult()); + $this->position->getWorld()->dropItem($this->position->asVector3()->add(0.5, 1, 0.5), $ev->getResult()); } } if(count($items) > 0){ $this->position->getWorld()->setBlock($this->position, $this); } if(mt_rand(1, 6) === 1){ - $this->position->getWorld()->addSound($this->position, $furnaceType->getCookSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), $furnaceType->getCookSound()); } $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, self::UPDATE_INTERVAL_TICKS); } } private function extinguish() : void{ - $this->position->getWorld()->addSound($this->position, new FireExtinguishSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new FireExtinguishSound()); $this->position->getWorld()->setBlock($this->position, $this->setLit(false)); } private function ignite() : void{ - $this->position->getWorld()->addSound($this->position, new FlintSteelSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new FlintSteelSound()); $this->position->getWorld()->setBlock($this->position, $this->setLit(true)); $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, self::UPDATE_INTERVAL_TICKS); } diff --git a/src/block/Cauldron.php b/src/block/Cauldron.php index 772583a5a..1d696bdb7 100644 --- a/src/block/Cauldron.php +++ b/src/block/Cauldron.php @@ -69,7 +69,7 @@ final class Cauldron extends Transparent{ */ private function fill(int $amount, FillableCauldron $result, Item $usedItem, Item $returnedItem, array &$returnedItems) : void{ $this->position->getWorld()->setBlock($this->position, $result->setFillLevel($amount)); - $this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), $result->getFillSound()); + $this->position->getWorld()->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), $result->getFillSound()); $usedItem->pop(); $returnedItems[] = $returnedItem; @@ -95,10 +95,10 @@ final class Cauldron extends Transparent{ public function onNearbyBlockChange() : void{ $world = $this->position->getWorld(); - if($world->getBlock($this->position->up())->getTypeId() === BlockTypeIds::WATER){ + if($this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::WATER){ $cauldron = VanillaBlocks::WATER_CAULDRON()->setFillLevel(FillableCauldron::MAX_FILL_LEVEL); $world->setBlock($this->position, $cauldron); - $world->addSound($this->position->add(0.5, 0.5, 0.5), $cauldron->getFillSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), $cauldron->getFillSound()); } } } diff --git a/src/block/CaveVines.php b/src/block/CaveVines.php index daa973507..5f961defc 100644 --- a/src/block/CaveVines.php +++ b/src/block/CaveVines.php @@ -90,8 +90,8 @@ class CaveVines extends Flowable{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($this->berries){ - $this->position->getWorld()->dropItem($this->position, $this->asItem()); - $this->position->getWorld()->addSound($this->position, new GlowBerriesPickSound()); + $this->position->getWorld()->dropItem($this->position->asVector3(), $this->asItem()); + $this->position->getWorld()->addSound($this->position->asVector3(), new GlowBerriesPickSound()); $this->position->getWorld()->setBlock($this->position, $this->setBerries(false)); return true; @@ -117,7 +117,7 @@ class CaveVines extends Flowable{ if($this->age < self::MAX_AGE && mt_rand(1, 10) === 1){ $growthPos = $this->position->getSide(Facing::DOWN); $world = $growthPos->getWorld(); - if($world->isInWorld($growthPos->getFloorX(), $growthPos->getFloorY(), $growthPos->getFloorZ())){ + if($world->isInWorld($growthPos->x, $growthPos->y, $growthPos->z)){ $block = $world->getBlock($growthPos); if($block->getTypeId() === BlockTypeIds::AIR){ $newState = VanillaBlocks::CAVE_VINES() diff --git a/src/block/ChorusFlower.php b/src/block/ChorusFlower.php index cc3c606d9..478f1af4b 100644 --- a/src/block/ChorusFlower.php +++ b/src/block/ChorusFlower.php @@ -27,15 +27,12 @@ use pocketmine\block\utils\AgeableTrait; use pocketmine\block\utils\StaticSupportTrait; use pocketmine\entity\projectile\Projectile; use pocketmine\event\block\StructureGrowEvent; -use pocketmine\math\Axis; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\RayTraceResult; -use pocketmine\math\Vector3; use pocketmine\world\BlockTransaction; use pocketmine\world\sound\ChorusFlowerDieSound; use pocketmine\world\sound\ChorusFlowerGrowSound; -use pocketmine\world\World; use function array_rand; use function min; use function mt_rand; @@ -54,24 +51,22 @@ final class ChorusFlower extends Flowable{ } private function canBeSupportedAt(Block $block) : bool{ - $position = $block->position; - $world = $position->getWorld(); - $down = $world->getBlock($position->down()); + $down = $block->getSide(Facing::DOWN); if($down->getTypeId() === BlockTypeIds::END_STONE || $down->getTypeId() === BlockTypeIds::CHORUS_PLANT){ return true; } $plantAdjacent = false; - foreach($position->sidesAroundAxis(Axis::Y) as $sidePosition){ - $block = $world->getBlock($sidePosition); + foreach(Facing::HORIZONTAL as $side){ + $sideBlock = $block->getSide($side); - if($block->getTypeId() === BlockTypeIds::CHORUS_PLANT){ + if($sideBlock->getTypeId() === BlockTypeIds::CHORUS_PLANT){ if($plantAdjacent){ //at most one plant may be horizontally adjacent return false; } $plantAdjacent = true; - }elseif($block->getTypeId() !== BlockTypeIds::AIR){ + }elseif($sideBlock->getTypeId() !== BlockTypeIds::AIR){ return false; } } @@ -92,7 +87,7 @@ final class ChorusFlower extends Flowable{ $stemHeight = 0; $endStoneBelow = false; for($yOffset = 0; $yOffset < self::MAX_STEM_HEIGHT; $yOffset++, $stemHeight++){ - $down = $world->getBlock($this->position->down($yOffset + 1)); + $down = $this->getSide(Facing::DOWN, $yOffset + 1); if($down->getTypeId() !== BlockTypeIds::CHORUS_PLANT){ if($down->getTypeId() === BlockTypeIds::END_STONE){ @@ -105,12 +100,13 @@ final class ChorusFlower extends Flowable{ return [$stemHeight, $endStoneBelow]; } - private function allHorizontalBlocksEmpty(World $world, Vector3 $position, ?int $except) : bool{ - foreach($position->sidesAroundAxis(Axis::Y) as $facing => $sidePosition){ + private function allHorizontalBlocksEmpty(BlockPosition $position, ?int $except) : bool{ + $world = $position->getWorld(); + foreach(Facing::HORIZONTAL as $facing){ if($facing === $except){ continue; } - if($world->getBlock($sidePosition)->getTypeId() !== BlockTypeIds::AIR){ + if($world->getBlock($position->getSide($facing))->getTypeId() !== BlockTypeIds::AIR){ return false; } } @@ -121,7 +117,7 @@ final class ChorusFlower extends Flowable{ private function canGrowUpwards(int $stemHeight, bool $endStoneBelow) : bool{ $world = $this->position->getWorld(); - $up = $this->position->up(); + $up = $this->position->getSide(Facing::UP); if( //the space above must be empty and writable !$world->isInWorld($up->x, $up->y, $up->z) || @@ -129,7 +125,7 @@ final class ChorusFlower extends Flowable{ ( //the space above that must be empty, but doesn't need to be writable $world->isInWorld($up->x, $up->y + 1, $up->z) && - $world->getBlock($up->up())->getTypeId() !== BlockTypeIds::AIR + $world->getBlock($up->getSide(Facing::UP))->getTypeId() !== BlockTypeIds::AIR ) ){ return false; @@ -145,7 +141,7 @@ final class ChorusFlower extends Flowable{ } } - return $this->allHorizontalBlocksEmpty($world, $up, null); + return $this->allHorizontalBlocksEmpty($up, null); } private function grow(int $facing, int $ageChange, ?BlockTransaction $tx) : BlockTransaction{ @@ -183,8 +179,8 @@ final class ChorusFlower extends Flowable{ $sidePosition = $this->position->getSide($facing); if( $world->getBlock($sidePosition)->getTypeId() === BlockTypeIds::AIR && - $world->getBlock($sidePosition->down())->getTypeId() === BlockTypeIds::AIR && - $this->allHorizontalBlocksEmpty($world, $sidePosition, Facing::opposite($facing)) + $world->getBlock($sidePosition->getSide(Facing::DOWN))->getTypeId() === BlockTypeIds::AIR && + $this->allHorizontalBlocksEmpty($sidePosition, Facing::opposite($facing)) ){ $tx = $this->grow($facing, 1, $tx); } @@ -196,10 +192,10 @@ final class ChorusFlower extends Flowable{ $ev = new StructureGrowEvent($this, $tx, null); $ev->call(); if(!$ev->isCancelled() && $tx->apply()){ - $world->addSound($this->position->add(0.5, 0.5, 0.5), new ChorusFlowerGrowSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new ChorusFlowerGrowSound()); } }else{ - $world->addSound($this->position->add(0.5, 0.5, 0.5), new ChorusFlowerDieSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new ChorusFlowerDieSound()); $this->position->getWorld()->setBlock($this->position, $this->setAge(self::MAX_AGE)); } } diff --git a/src/block/ChorusPlant.php b/src/block/ChorusPlant.php index 9013f6825..e0a64f476 100644 --- a/src/block/ChorusPlant.php +++ b/src/block/ChorusPlant.php @@ -26,7 +26,6 @@ namespace pocketmine\block; use pocketmine\block\utils\StaticSupportTrait; use pocketmine\item\Item; use pocketmine\item\VanillaItems; -use pocketmine\math\Axis; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use function mt_rand; @@ -51,21 +50,18 @@ final class ChorusPlant extends Flowable{ } private function canBeSupportedAt(Block $block) : bool{ - $position = $block->position; - $world = $position->getWorld(); + $down = $block->getSide(Facing::DOWN); + $verticalAir = $down->getTypeId() === BlockTypeIds::AIR || $block->getSide(Facing::UP)->getTypeId() === BlockTypeIds::AIR; - $down = $world->getBlock($position->down()); - $verticalAir = $down->getTypeId() === BlockTypeIds::AIR || $world->getBlock($position->up())->getTypeId() === BlockTypeIds::AIR; + foreach(Facing::HORIZONTAL as $facing){ + $sideBlock = $block->getSide($facing); - foreach($position->sidesAroundAxis(Axis::Y) as $sidePosition){ - $block = $world->getBlock($sidePosition); - - if($block->getTypeId() === BlockTypeIds::CHORUS_PLANT){ + if($sideBlock->getTypeId() === BlockTypeIds::CHORUS_PLANT){ if(!$verticalAir){ return false; } - if($this->canBeSupportedBy($block->getSide(Facing::DOWN))){ + if($this->canBeSupportedBy($sideBlock->getSide(Facing::DOWN))){ return true; } } diff --git a/src/block/CoralBlock.php b/src/block/CoralBlock.php index 3e7ca8224..47b6cbf4f 100644 --- a/src/block/CoralBlock.php +++ b/src/block/CoralBlock.php @@ -26,6 +26,7 @@ namespace pocketmine\block; use pocketmine\block\utils\BlockEventHelper; use pocketmine\block\utils\CoralTypeTrait; use pocketmine\item\Item; +use pocketmine\math\Facing; use function mt_rand; final class CoralBlock extends Opaque{ @@ -39,11 +40,9 @@ final class CoralBlock extends Opaque{ public function onScheduledUpdate() : void{ if(!$this->dead){ - $world = $this->position->getWorld(); - $hasWater = false; - foreach($this->position->sides() as $vector3){ - if($world->getBlock($vector3) instanceof Water){ + foreach(Facing::ALL as $facing){ + if($this->getSide($facing) instanceof Water){ $hasWater = true; break; } diff --git a/src/block/Dirt.php b/src/block/Dirt.php index 104080d31..286b83f80 100644 --- a/src/block/Dirt.php +++ b/src/block/Dirt.php @@ -63,7 +63,7 @@ class Dirt extends Opaque{ $item->applyDamage(1); $newBlock = $this->dirtType === DirtType::NORMAL ? VanillaBlocks::FARMLAND() : VanillaBlocks::DIRT(); - $center = $this->position->add(0.5, 0.5, 0.5); + $center = $this->position->asVector3()->add(0.5, 0.5, 0.5); $world->addSound($center, new ItemUseOnBlockSound($newBlock)); $world->setBlock($this->position, $newBlock); if($this->dirtType === DirtType::ROOTED){ @@ -83,7 +83,7 @@ class Dirt extends Opaque{ }elseif(($item instanceof Potion || $item instanceof SplashPotion) && $item->getType() === PotionType::WATER){ $item->pop(); $world->setBlock($this->position, VanillaBlocks::MUD()); - $world->addSound($this->position, new WaterSplashSound(0.5)); + $world->addSound($this->position->asVector3(), new WaterSplashSound(0.5)); return true; } diff --git a/src/block/Door.php b/src/block/Door.php index 82ddaab51..7a214a9da 100644 --- a/src/block/Door.php +++ b/src/block/Door.php @@ -152,7 +152,7 @@ class Door extends Transparent{ } $world->setBlock($this->position, $this); - $world->addSound($this->position, new DoorSound()); + $world->addSound($this->position->asVector3(), new DoorSound()); return true; } diff --git a/src/block/DragonEgg.php b/src/block/DragonEgg.php index 10fec6394..2ff36934b 100644 --- a/src/block/DragonEgg.php +++ b/src/block/DragonEgg.php @@ -66,16 +66,17 @@ class DragonEgg extends Transparent implements Fallable{ $this->position->z + mt_rand(-16, 16) ); if($block instanceof Air){ - $ev = new BlockTeleportEvent($this, $block->position); + //TODO: this needs migrating to BlockPosition, but having World in there presents some issues + $ev = new BlockTeleportEvent($this, $block->position->asVector3()); $ev->call(); if($ev->isCancelled()){ break; } $blockPos = $ev->getTo(); - $world->addParticle($this->position, new DragonEggTeleportParticle($this->position->x - $blockPos->x, $this->position->y - $blockPos->y, $this->position->z - $blockPos->z)); + $world->addParticle($this->position->asVector3(), new DragonEggTeleportParticle($this->position->x - $blockPos->getFloorX(), $this->position->y - $blockPos->getFloorY(), $this->position->z - $blockPos->getFloorZ())); $world->setBlock($this->position, VanillaBlocks::AIR()); - $world->setBlock($blockPos, $this); + $world->setBlockAt($blockPos->getFloorX(), $blockPos->getFloorY(), $blockPos->getFloorZ(), $this); break; } } diff --git a/src/block/Farmland.php b/src/block/Farmland.php index b7a2500a8..56a1caed9 100644 --- a/src/block/Farmland.php +++ b/src/block/Farmland.php @@ -161,9 +161,9 @@ class Farmland extends Transparent{ protected function canHydrate() : bool{ $world = $this->position->getWorld(); - $startX = $this->position->getFloorX() - (int) (self::WATER_SEARCH_HORIZONTAL_LENGTH / 2); - $startY = $this->position->getFloorY(); - $startZ = $this->position->getFloorZ() - (int) (self::WATER_SEARCH_HORIZONTAL_LENGTH / 2); + $startX = $this->position->x - (int) (self::WATER_SEARCH_HORIZONTAL_LENGTH / 2); + $startY = $this->position->y; + $startZ = $this->position->z - (int) (self::WATER_SEARCH_HORIZONTAL_LENGTH / 2); if($this->waterPositionIndex !== self::WATER_POSITION_INDEX_UNKNOWN){ $raw = $this->waterPositionIndex; diff --git a/src/block/FenceGate.php b/src/block/FenceGate.php index 735456449..011e88c67 100644 --- a/src/block/FenceGate.php +++ b/src/block/FenceGate.php @@ -111,7 +111,7 @@ class FenceGate extends Transparent{ $world = $this->position->getWorld(); $world->setBlock($this->position, $this); - $world->addSound($this->position, new DoorSound()); + $world->addSound($this->position->asVector3(), new DoorSound()); return true; } diff --git a/src/block/FillableCauldron.php b/src/block/FillableCauldron.php index ceef35299..42f03fdad 100644 --- a/src/block/FillableCauldron.php +++ b/src/block/FillableCauldron.php @@ -79,7 +79,7 @@ abstract class FillableCauldron extends Transparent{ return; } $this->position->getWorld()->setBlock($this->position, $this->withFillLevel($this->fillLevel + $amount)); - $this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), $this->getFillSound()); + $this->position->getWorld()->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), $this->getFillSound()); $usedItem->pop(); $returnedItems[] = $returnedItem; @@ -94,7 +94,7 @@ abstract class FillableCauldron extends Transparent{ } $this->position->getWorld()->setBlock($this->position, $this->withFillLevel($this->fillLevel - $amount)); - $this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), $this->getEmptySound()); + $this->position->getWorld()->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), $this->getEmptySound()); $usedItem->pop(); $returnedItems[] = $returnedItem; diff --git a/src/block/Fire.php b/src/block/Fire.php index 35a7a696c..674a62ceb 100644 --- a/src/block/Fire.php +++ b/src/block/Fire.php @@ -161,7 +161,7 @@ class Fire extends BaseFire{ $ageDivisor = $this->age + 30; for($y = -1; $y <= 4; ++$y){ - $targetY = $y + (int) $this->position->y; + $targetY = $y + $this->position->y; if($targetY < World::Y_MIN || $targetY >= World::Y_MAX){ continue; } @@ -169,12 +169,12 @@ class Fire extends BaseFire{ $randomBound = 100 + ($y > 1 ? ($y - 1) * 100 : 0); for($z = -1; $z <= 1; ++$z){ - $targetZ = $z + (int) $this->position->z; + $targetZ = $z + $this->position->z; for($x = -1; $x <= 1; ++$x){ if($x === 0 && $y === 0 && $z === 0){ continue; } - $targetX = $x + (int) $this->position->x; + $targetX = $x + $this->position->x; if(!$world->isInWorld($targetX, $targetY, $targetZ)){ continue; } @@ -190,9 +190,10 @@ class Fire extends BaseFire{ //TODO: fire can't spread if it's raining in any horizontally adjacent block, or the current one $encouragement = 0; - foreach($block->position->sides() as $vector3){ - if($world->isInWorld($vector3->x, $vector3->y, $vector3->z)){ - $encouragement = max($encouragement, $world->getBlockAt($vector3->x, $vector3->y, $vector3->z)->getFlameEncouragement()); + foreach(Facing::ALL as $facing){ + $sidePos = $block->position->getSide($facing); + if($world->isInWorld($sidePos->x, $sidePos->y, $sidePos->z)){ + $encouragement = max($encouragement, $world->getBlockAt($sidePos->x, $sidePos->y, $sidePos->z)->getFlameEncouragement()); } } diff --git a/src/block/FloorCoralFan.php b/src/block/FloorCoralFan.php index 5b74d08af..d01df70a9 100644 --- a/src/block/FloorCoralFan.php +++ b/src/block/FloorCoralFan.php @@ -58,7 +58,7 @@ final class FloorCoralFan extends BaseCoral{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($player !== null){ $playerBlockPos = $player->getPosition()->floor(); - $directionVector = $blockReplace->position->subtractVector($playerBlockPos)->normalize(); + $directionVector = $blockReplace->position->asVector3()->subtractVector($playerBlockPos)->normalize(); $angle = rad2deg(atan2($directionVector->getZ(), $directionVector->getX())); if($angle <= 45 || 315 <= $angle || (135 <= $angle && $angle <= 225)){ diff --git a/src/block/FlowerPot.php b/src/block/FlowerPot.php index fb3e78d82..a5ea85c1f 100644 --- a/src/block/FlowerPot.php +++ b/src/block/FlowerPot.php @@ -111,7 +111,7 @@ class FlowerPot extends Flowable{ $removedItems = $player->getInventory()->addItem(...$removedItems); } foreach($removedItems as $drops){ - $world->dropItem($this->position->add(0.5, 0.5, 0.5), $drops); + $world->dropItem($this->position->asVector3()->add(0.5, 0.5, 0.5), $drops); } $this->setPlant(null); diff --git a/src/block/Furnace.php b/src/block/Furnace.php index 7a64e3cd3..00a5edbb3 100644 --- a/src/block/Furnace.php +++ b/src/block/Furnace.php @@ -73,7 +73,7 @@ class Furnace extends Opaque{ $furnace = $world->getTile($this->position); if($furnace instanceof TileFurnace && $furnace->onUpdate()){ if(mt_rand(1, 60) === 1){ //in vanilla this is between 1 and 5 seconds; try to average about 3 - $world->addSound($this->position, $furnace->getFurnaceType()->getCookSound()); + $world->addSound($this->position->asVector3(), $furnace->getFurnaceType()->getCookSound()); } $world->scheduleDelayedBlockUpdate($this->position, 1); //TODO: check this } diff --git a/src/block/GlowLichen.php b/src/block/GlowLichen.php index d30e25395..6a3893c3a 100644 --- a/src/block/GlowLichen.php +++ b/src/block/GlowLichen.php @@ -32,7 +32,6 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; -use pocketmine\world\World; use function count; use function shuffle; @@ -84,7 +83,8 @@ class GlowLichen extends Transparent{ return $result->setFace($spreadFace, true); } - private function spread(World $world, Vector3 $replacePos, int $spreadFace) : bool{ + private function spread(BlockPosition $replacePos, int $spreadFace) : bool{ + $world = $replacePos->getWorld(); $supportBlock = $world->getBlock($replacePos->getSide($spreadFace)); $supportFace = Facing::opposite($spreadFace); @@ -117,12 +117,10 @@ class GlowLichen extends Transparent{ } private function spreadAroundSupport(int $sourceFace) : bool{ - $world = $this->position->getWorld(); - $supportPos = $this->position->getSide($sourceFace); foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){ $replacePos = $supportPos->getSide($spreadFace); - if($this->spread($world, $replacePos, Facing::opposite($spreadFace))){ + if($this->spread($replacePos, Facing::opposite($spreadFace))){ return true; } } @@ -131,11 +129,9 @@ class GlowLichen extends Transparent{ } private function spreadAdjacentToSupport(int $sourceFace) : bool{ - $world = $this->position->getWorld(); - foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){ $replacePos = $this->position->getSide($spreadFace); - if($this->spread($world, $replacePos, $sourceFace)){ + if($this->spread($replacePos, $sourceFace)){ return true; } } @@ -144,7 +140,7 @@ class GlowLichen extends Transparent{ private function spreadWithinSelf(int $sourceFace) : bool{ foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){ - if(!$this->hasFace($spreadFace) && $this->spread($this->position->getWorld(), $this->position, $spreadFace)){ + if(!$this->hasFace($spreadFace) && $this->spread($this->position, $spreadFace)){ return true; } } diff --git a/src/block/Grass.php b/src/block/Grass.php index 8a9fea8ea..bc879e234 100644 --- a/src/block/Grass.php +++ b/src/block/Grass.php @@ -88,7 +88,7 @@ class Grass extends Opaque{ $world = $this->position->getWorld(); if($item instanceof Fertilizer){ $item->pop(); - TallGrassObject::growGrass($world, $this->position, new Random(mt_rand()), 8, 2); + TallGrassObject::growGrass($world, $this->position->asVector3(), new Random(mt_rand()), 8, 2); return true; } @@ -96,14 +96,14 @@ class Grass extends Opaque{ if($item instanceof Hoe){ $item->applyDamage(1); $newBlock = VanillaBlocks::FARMLAND(); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock)); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock)); $world->setBlock($this->position, $newBlock); return true; }elseif($item instanceof Shovel){ $item->applyDamage(1); $newBlock = VanillaBlocks::GRASS_PATH(); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock)); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new ItemUseOnBlockSound($newBlock)); $world->setBlock($this->position, $newBlock); return true; diff --git a/src/block/ItemFrame.php b/src/block/ItemFrame.php index c03806a3b..7550db272 100644 --- a/src/block/ItemFrame.php +++ b/src/block/ItemFrame.php @@ -135,11 +135,11 @@ class ItemFrame extends Flowable{ if($this->framedItem !== null){ $this->itemRotation = ($this->itemRotation + 1) % self::ROTATIONS; - $this->position->getWorld()->addSound($this->position, new ItemFrameRotateItemSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new ItemFrameRotateItemSound()); }elseif(!$item->isNull()){ $this->framedItem = $item->pop(); - $this->position->getWorld()->addSound($this->position, new ItemFrameAddItemSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new ItemFrameAddItemSound()); }else{ return true; } @@ -155,8 +155,8 @@ class ItemFrame extends Flowable{ } $world = $this->position->getWorld(); if(Utils::getRandomFloat() <= $this->itemDropChance){ - $world->dropItem($this->position->add(0.5, 0.5, 0.5), clone $this->framedItem); - $world->addSound($this->position, new ItemFrameRemoveItemSound()); + $world->dropItem($this->position->asVector3()->add(0.5, 0.5, 0.5), clone $this->framedItem); + $world->addSound($this->position->asVector3(), new ItemFrameRemoveItemSound()); } $this->setFramedItem(null); $world->setBlock($this->position, $this); diff --git a/src/block/Jukebox.php b/src/block/Jukebox.php index a61dd06db..15e44f87b 100644 --- a/src/block/Jukebox.php +++ b/src/block/Jukebox.php @@ -61,7 +61,7 @@ class Jukebox extends Opaque{ public function ejectRecord() : void{ if($this->record !== null){ - $this->position->getWorld()->dropItem($this->position->add(0.5, 1, 0.5), $this->record); + $this->position->getWorld()->dropItem($this->position->asVector3()->add(0.5, 1, 0.5), $this->record); $this->record = null; $this->stopSound(); } @@ -76,12 +76,12 @@ class Jukebox extends Opaque{ public function startSound() : void{ if($this->record !== null){ - $this->position->getWorld()->addSound($this->position, new RecordSound($this->record->getRecordType())); + $this->position->getWorld()->addSound($this->position->asVector3(), new RecordSound($this->record->getRecordType())); } } public function stopSound() : void{ - $this->position->getWorld()->addSound($this->position, new RecordStopSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new RecordStopSound()); } public function onBreak(Item $item, ?Player $player = null, array &$returnedItems = []) : bool{ diff --git a/src/block/Ladder.php b/src/block/Ladder.php index 58f133f6e..7c0ab9188 100644 --- a/src/block/Ladder.php +++ b/src/block/Ladder.php @@ -51,7 +51,7 @@ class Ladder extends Transparent{ } public function onEntityInside(Entity $entity) : bool{ - if($entity instanceof Living && $entity->getPosition()->floor()->distanceSquared($this->position) < 1){ //entity coordinates must be inside block + if($entity instanceof Living && $entity->getPosition()->floor()->distanceSquared($this->position->asVector3()) < 1){ //entity coordinates must be inside block $entity->resetFallDistance(); $entity->onGround = true; } diff --git a/src/block/Leaves.php b/src/block/Leaves.php index 7fe9eae74..4369c787a 100644 --- a/src/block/Leaves.php +++ b/src/block/Leaves.php @@ -81,7 +81,7 @@ class Leaves extends Transparent{ * @phpstan-param array $visited * @phpstan-param-out array $visited */ - protected function findLog(Vector3 $pos, array &$visited = [], int $distance = 0) : bool{ + protected function findLog(BlockPosition $pos, array &$visited = [], int $distance = 0) : bool{ $index = World::blockHash($pos->x, $pos->y, $pos->z); if(isset($visited[$index])){ return false; diff --git a/src/block/Lectern.php b/src/block/Lectern.php index 03880b3c5..c6461fda3 100644 --- a/src/block/Lectern.php +++ b/src/block/Lectern.php @@ -123,7 +123,7 @@ class Lectern extends Transparent{ if($this->book === null && $item instanceof WritableBookBase){ $world = $this->position->getWorld(); $world->setBlock($this->position, $this->setBook($item)); - $world->addSound($this->position, new LecternPlaceBookSound()); + $world->addSound($this->position->asVector3(), new LecternPlaceBookSound()); $item->pop(); } return true; @@ -132,7 +132,7 @@ class Lectern extends Transparent{ public function onAttack(Item $item, int $face, ?Player $player = null) : bool{ if($this->book !== null){ $world = $this->position->getWorld(); - $world->dropItem($this->position->up(), $this->book); + $world->dropItem($this->position->getSide(Facing::UP)->asVector3(), $this->book); $world->setBlock($this->position, $this->setBook(null)); } return false; diff --git a/src/block/Lever.php b/src/block/Lever.php index d2b98efc3..3389d18f0 100644 --- a/src/block/Lever.php +++ b/src/block/Lever.php @@ -95,7 +95,7 @@ class Lever extends Flowable{ $world = $this->position->getWorld(); $world->setBlock($this->position, $this); $world->addSound( - $this->position->add(0.5, 0.5, 0.5), + $this->position->asVector3()->add(0.5, 0.5, 0.5), $this->activated ? new RedstonePowerOnSound() : new RedstonePowerOffSound() ); return true; diff --git a/src/block/Liquid.php b/src/block/Liquid.php index a37019d65..5def61d1b 100644 --- a/src/block/Liquid.php +++ b/src/block/Liquid.php @@ -165,9 +165,9 @@ abstract class Liquid extends Transparent{ $vX = $vY = $vZ = 0; - $x = $this->position->getFloorX(); - $y = $this->position->getFloorY(); - $z = $this->position->getFloorZ(); + $x = $this->position->x; + $y = $this->position->y; + $z = $this->position->z; $decay = $this->getEffectiveFlowDecay($this); @@ -259,9 +259,9 @@ abstract class Liquid extends Transparent{ $world = $this->position->getWorld(); - $x = $this->position->getFloorX(); - $y = $this->position->getFloorY(); - $z = $this->position->getFloorZ(); + $x = $this->position->x; + $y = $this->position->y; + $z = $this->position->z; if(!$this->isSource()){ $smallestFlowDecay = -100; @@ -368,7 +368,7 @@ abstract class Liquid extends Transparent{ protected function liquidCollide(Block $cause, Block $result) : bool{ if(BlockEventHelper::form($this, $result, $cause)){ - $this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new FizzSound(2.6 + (Utils::getRandomFloat() - Utils::getRandomFloat()) * 0.8)); + $this->position->getWorld()->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new FizzSound(2.6 + (Utils::getRandomFloat() - Utils::getRandomFloat()) * 0.8)); } return true; } diff --git a/src/block/NetherVines.php b/src/block/NetherVines.php index e8729c00f..15d7b0e2f 100644 --- a/src/block/NetherVines.php +++ b/src/block/NetherVines.php @@ -117,7 +117,7 @@ class NetherVines extends Flowable{ for($i = 1; $i <= $growthAmount; $i++){ $growthPos = $pos->getSide($this->growthFace, $i); - if(!$world->isInWorld($growthPos->getFloorX(), $growthPos->getFloorY(), $growthPos->getFloorZ()) || !$world->getBlock($growthPos)->canBeReplaced()){ + if(!$world->isInWorld($growthPos->x, $growthPos->y, $growthPos->z) || !$world->getBlock($growthPos)->canBeReplaced()){ break; } $tx->addBlock($growthPos, (clone $top)->setAge(min(++$age, self::MAX_AGE))); diff --git a/src/block/PinkPetals.php b/src/block/PinkPetals.php index 17bc4c50a..97a4dee04 100644 --- a/src/block/PinkPetals.php +++ b/src/block/PinkPetals.php @@ -89,7 +89,7 @@ class PinkPetals extends Flowable{ if($this->count < self::MAX_COUNT){ $grew = BlockEventHelper::grow($this, (clone $this)->setCount($this->count + 1), $player); }else{ - $this->position->getWorld()->dropItem($this->position->add(0, 0.5, 0), $this->asItem()); + $this->position->getWorld()->dropItem($this->position->asVector3()->add(0, 0.5, 0), $this->asItem()); $grew = true; } if($grew){ diff --git a/src/block/PitcherCrop.php b/src/block/PitcherCrop.php index d41aed284..2dc73721f 100644 --- a/src/block/PitcherCrop.php +++ b/src/block/PitcherCrop.php @@ -73,7 +73,7 @@ final class PitcherCrop extends Flowable{ $tx = new BlockTransaction($this->position->getWorld()); $tx->addBlock($this->position, VanillaBlocks::DOUBLE_PITCHER_CROP()->setTop(false)); - $tx->addBlock($this->position->up(), VanillaBlocks::DOUBLE_PITCHER_CROP()->setTop(true)); + $tx->addBlock($this->position->getSide(Facing::UP), VanillaBlocks::DOUBLE_PITCHER_CROP()->setTop(true)); $ev = new StructureGrowEvent($this, $tx, $player); $ev->call(); diff --git a/src/block/PotionCauldron.php b/src/block/PotionCauldron.php index ca91664e4..27cf69c6d 100644 --- a/src/block/PotionCauldron.php +++ b/src/block/PotionCauldron.php @@ -27,6 +27,7 @@ use pocketmine\block\tile\Cauldron as TileCauldron; use pocketmine\item\Item; use pocketmine\item\ItemTypeIds; use pocketmine\item\VanillaItems; +use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; use pocketmine\world\sound\CauldronEmptyPotionSound; @@ -107,10 +108,10 @@ final class PotionCauldron extends FillableCauldron{ public function onNearbyBlockChange() : void{ $world = $this->position->getWorld(); - if($world->getBlock($this->position->up())->getTypeId() === BlockTypeIds::WATER){ + if($this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::WATER){ $cauldron = VanillaBlocks::WATER_CAULDRON()->setFillLevel(FillableCauldron::MAX_FILL_LEVEL); $world->setBlock($this->position, $cauldron); - $world->addSound($this->position->add(0.5, 0.5, 0.5), $cauldron->getFillSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), $cauldron->getFillSound()); } } } diff --git a/src/block/PressurePlate.php b/src/block/PressurePlate.php index 1dd4b50d9..e4292fd97 100644 --- a/src/block/PressurePlate.php +++ b/src/block/PressurePlate.php @@ -139,7 +139,7 @@ abstract class PressurePlate extends Transparent{ if($newState !== null){ $world->setBlock($this->position, $newState); if($pressedChange !== null){ - $world->addSound($this->position, $pressedChange ? + $world->addSound($this->position->asVector3(), $pressedChange ? new PressurePlateActivateSound($this) : new PressurePlateDeactivateSound($this) ); diff --git a/src/block/Pumpkin.php b/src/block/Pumpkin.php index 1b7f6a9cd..039cd3a10 100644 --- a/src/block/Pumpkin.php +++ b/src/block/Pumpkin.php @@ -38,7 +38,7 @@ class Pumpkin extends Opaque{ $item->applyDamage(1); $world = $this->position->getWorld(); $world->setBlock($this->position, VanillaBlocks::CARVED_PUMPKIN()->setFacing($face)); - $world->dropItem($this->position->add(0.5, 0.5, 0.5), VanillaItems::PUMPKIN_SEEDS()->setCount(1)); + $world->dropItem($this->position->asVector3()->add(0.5, 0.5, 0.5), VanillaItems::PUMPKIN_SEEDS()->setCount(1)); return true; } return false; diff --git a/src/block/Sapling.php b/src/block/Sapling.php index b3fdf59af..004353c08 100644 --- a/src/block/Sapling.php +++ b/src/block/Sapling.php @@ -81,7 +81,7 @@ class Sapling extends Flowable{ public function onRandomTick() : void{ $world = $this->position->getWorld(); - if($world->getFullLightAt($this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ()) >= 8 && mt_rand(1, 7) === 1){ + if($world->getFullLightAt($this->position->x, $this->position->y, $this->position->z) >= 8 && mt_rand(1, 7) === 1){ if($this->ready){ $this->grow(null); }else{ @@ -94,7 +94,7 @@ class Sapling extends Flowable{ private function grow(?Player $player) : bool{ $random = new Random(mt_rand()); $tree = TreeFactory::get($random, $this->saplingType->getTreeType()); - $transaction = $tree?->getBlockTransaction($this->position->getWorld(), $this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ(), $random); + $transaction = $tree?->getBlockTransaction($this->position->getWorld(), $this->position->x, $this->position->y, $this->position->z, $random); if($transaction === null){ return false; } diff --git a/src/block/SmallDripleaf.php b/src/block/SmallDripleaf.php index d192e43db..175867410 100644 --- a/src/block/SmallDripleaf.php +++ b/src/block/SmallDripleaf.php @@ -33,7 +33,6 @@ use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; use pocketmine\world\BlockTransaction; -use pocketmine\world\Position; use function mt_rand; class SmallDripleaf extends Transparent{ @@ -98,9 +97,9 @@ class SmallDripleaf extends Transparent{ return false; } - private function canGrowTo(Position $pos) : bool{ + private function canGrowTo(BlockPosition $pos) : bool{ $world = $pos->getWorld(); - if(!$world->isInWorld($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ())){ + if(!$world->isInWorld($pos->x, $pos->y, $pos->z)){ return false; } $block = $world->getBlock($pos); diff --git a/src/block/Sugarcane.php b/src/block/Sugarcane.php index 2da2dc9b9..49113818f 100644 --- a/src/block/Sugarcane.php +++ b/src/block/Sugarcane.php @@ -32,7 +32,6 @@ use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; use pocketmine\world\BlockTransaction; -use pocketmine\world\Position; class Sugarcane extends Flowable{ use AgeableTrait; @@ -42,16 +41,16 @@ class Sugarcane extends Flowable{ public const MAX_AGE = 15; - private function seekToBottom() : Position{ + private function seekToBottom() : BlockPosition{ $world = $this->position->getWorld(); $bottom = $this->position; - while(($next = $world->getBlock($bottom->down()))->hasSameTypeId($this)){ + while(($next = $world->getBlock($bottom->getSide(Facing::DOWN)))->hasSameTypeId($this)){ $bottom = $next->position; } return $bottom; } - private function grow(Position $pos, ?Player $player = null) : bool{ + private function grow(BlockPosition $pos, ?Player $player = null) : bool{ $grew = false; $world = $pos->getWorld(); for($y = 1; $y < 3; ++$y){ diff --git a/src/block/SweetBerryBush.php b/src/block/SweetBerryBush.php index eabdde118..9dfb71a9e 100644 --- a/src/block/SweetBerryBush.php +++ b/src/block/SweetBerryBush.php @@ -81,8 +81,9 @@ class SweetBerryBush extends Flowable{ } }elseif(($dropAmount = $this->getBerryDropAmount()) > 0){ $world->setBlock($this->position, $this->setAge(self::STAGE_BUSH_NO_BERRIES)); - $world->dropItem($this->position, $this->asItem()->setCount($dropAmount)); - $world->addSound($this->position, new SweetBerriesPickSound()); + $posV3 = $this->position->asVector3(); + $world->dropItem($posV3, $this->asItem()->setCount($dropAmount)); + $world->addSound($posV3, new SweetBerriesPickSound()); } return true; diff --git a/src/block/TNT.php b/src/block/TNT.php index a0256bb67..5e8a69262 100644 --- a/src/block/TNT.php +++ b/src/block/TNT.php @@ -100,7 +100,7 @@ class TNT extends Opaque{ $mot = (new Random())->nextSignedFloat() * M_PI * 2; - $tnt = new PrimedTNT(Location::fromObject($this->position->add(0.5, 0, 0.5), $world)); + $tnt = new PrimedTNT(Location::fromObject($this->position->asVector3()->add(0.5, 0, 0.5), $world)); $tnt->setFuse($fuse); $tnt->setWorksUnderwater($this->worksUnderwater); $tnt->setMotion(new Vector3(-sin($mot) * 0.02, 0.2, -cos($mot) * 0.02)); diff --git a/src/block/Trapdoor.php b/src/block/Trapdoor.php index 20b6af2ab..015fd4cf3 100644 --- a/src/block/Trapdoor.php +++ b/src/block/Trapdoor.php @@ -88,7 +88,7 @@ class Trapdoor extends Transparent{ $this->open = !$this->open; $world = $this->position->getWorld(); $world->setBlock($this->position, $this); - $world->addSound($this->position, new DoorSound()); + $world->addSound($this->position->asVector3(), new DoorSound()); return true; } } diff --git a/src/block/WaterCauldron.php b/src/block/WaterCauldron.php index e470aa6cb..087dd010e 100644 --- a/src/block/WaterCauldron.php +++ b/src/block/WaterCauldron.php @@ -36,6 +36,7 @@ use pocketmine\item\Potion; use pocketmine\item\PotionType; use pocketmine\item\SplashPotion; use pocketmine\item\VanillaItems; +use pocketmine\math\Facing; use pocketmine\math\Vector3; use pocketmine\player\Player; use pocketmine\world\sound\CauldronAddDyeSound; @@ -119,7 +120,7 @@ final class WaterCauldron extends FillableCauldron{ }) !== null && ($newColor = $dyeColor->getRgbValue())->toRGBA() !== $this->customWaterColor?->toRGBA() ){ $world->setBlock($this->position, $this->setCustomWaterColor($this->customWaterColor === null ? $newColor : Color::mix($this->customWaterColor, $newColor))); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronAddDyeSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new CauldronAddDyeSound()); $item->pop(); }elseif($item instanceof Potion || $item instanceof SplashPotion){ //TODO: lingering potion @@ -139,12 +140,12 @@ final class WaterCauldron extends FillableCauldron{ } && $item->getCustomColor()?->toRGBA() !== $this->customWaterColor->toRGBA()){ $item->setCustomColor($this->customWaterColor); $world->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::DYE_ARMOR_USE_AMOUNT)); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronDyeItemSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new CauldronDyeItemSound()); } }elseif($item->getCustomColor() !== null){ $item->clearCustomColor(); $world->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::CLEAN_ARMOR_USE_AMOUNT)); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronCleanItemSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new CauldronCleanItemSound()); } }elseif($item instanceof Banner){ $patterns = $item->getPatterns(); @@ -153,7 +154,7 @@ final class WaterCauldron extends FillableCauldron{ $item->setPatterns($patterns); $world->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::CLEAN_BANNER_USE_AMOUNT)); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronCleanItemSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new CauldronCleanItemSound()); } }elseif(ItemTypeIds::toBlockTypeId($item->getTypeId()) === BlockTypeIds::DYED_SHULKER_BOX){ if($this->customWaterColor === null){ @@ -164,7 +165,7 @@ final class WaterCauldron extends FillableCauldron{ $returnedItems[] = $newItem; $world->setBlock($this->position, $this->withFillLevel($this->getFillLevel() - self::CLEAN_SHULKER_BOX_USE_AMOUNT)); - $world->addSound($this->position->add(0.5, 0.5, 0.5), new CauldronCleanItemSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new CauldronCleanItemSound()); } }else{ match($item->getTypeId()){ @@ -195,13 +196,13 @@ final class WaterCauldron extends FillableCauldron{ public function onNearbyBlockChange() : void{ $hasCustomWaterColor = $this->customWaterColor !== null; if($this->getFillLevel() < self::MAX_FILL_LEVEL || $hasCustomWaterColor){ - $world = $this->position->getWorld(); - if($world->getBlock($this->position->up())->getTypeId() === BlockTypeIds::WATER){ + if($this->getSide(Facing::UP)->getTypeId() === BlockTypeIds::WATER){ if($hasCustomWaterColor){ //TODO: particles } + $world = $this->position->getWorld(); $world->setBlock($this->position, $this->setCustomWaterColor(null)->setFillLevel(FillableCauldron::MAX_FILL_LEVEL)); - $world->addSound($this->position->add(0.5, 0.5, 0.5), $this->getFillSound()); + $world->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), $this->getFillSound()); } } } diff --git a/src/block/Wood.php b/src/block/Wood.php index 127533b98..1531a16a1 100644 --- a/src/block/Wood.php +++ b/src/block/Wood.php @@ -67,7 +67,7 @@ class Wood extends Opaque{ $item->applyDamage(1); $this->stripped = true; $this->position->getWorld()->setBlock($this->position, $this); - $this->position->getWorld()->addSound($this->position, new ItemUseOnBlockSound($this)); + $this->position->getWorld()->addSound($this->position->asVector3(), new ItemUseOnBlockSound($this)); return true; } return false; diff --git a/src/block/inventory/AnimatedBlockInventoryTrait.php b/src/block/inventory/AnimatedBlockInventoryTrait.php index 8720c985b..b1fdc10a0 100644 --- a/src/block/inventory/AnimatedBlockInventoryTrait.php +++ b/src/block/inventory/AnimatedBlockInventoryTrait.php @@ -50,7 +50,7 @@ trait AnimatedBlockInventoryTrait{ if($this->holder->isValid() && $this->getViewerCount() === 1){ //TODO: this crap really shouldn't be managed by the inventory $this->animateBlock(true); - $this->holder->getWorld()->addSound($this->holder->add(0.5, 0.5, 0.5), $this->getOpenSound()); + $this->holder->getWorld()->addSound($this->holder->asVector3()->add(0.5, 0.5, 0.5), $this->getOpenSound()); } } @@ -60,7 +60,7 @@ trait AnimatedBlockInventoryTrait{ if($this->holder->isValid() && $this->getViewerCount() === 1){ //TODO: this crap really shouldn't be managed by the inventory $this->animateBlock(false); - $this->holder->getWorld()->addSound($this->holder->add(0.5, 0.5, 0.5), $this->getCloseSound()); + $this->holder->getWorld()->addSound($this->holder->asVector3()->add(0.5, 0.5, 0.5), $this->getCloseSound()); } parent::onClose($who); } diff --git a/src/block/inventory/AnvilInventory.php b/src/block/inventory/AnvilInventory.php index 7d906a632..977d451f3 100644 --- a/src/block/inventory/AnvilInventory.php +++ b/src/block/inventory/AnvilInventory.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; use pocketmine\inventory\TemporaryInventory; -use pocketmine\world\Position; class AnvilInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{ use BlockInventoryTrait; @@ -33,7 +33,7 @@ class AnvilInventory extends SimpleInventory implements BlockInventory, Temporar public const SLOT_INPUT = 0; public const SLOT_MATERIAL = 1; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(2); } diff --git a/src/block/inventory/BarrelInventory.php b/src/block/inventory/BarrelInventory.php index 0d17d2a3e..ae136b1a9 100644 --- a/src/block/inventory/BarrelInventory.php +++ b/src/block/inventory/BarrelInventory.php @@ -24,8 +24,8 @@ declare(strict_types=1); namespace pocketmine\block\inventory; use pocketmine\block\Barrel; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; -use pocketmine\world\Position; use pocketmine\world\sound\BarrelCloseSound; use pocketmine\world\sound\BarrelOpenSound; use pocketmine\world\sound\Sound; @@ -33,7 +33,7 @@ use pocketmine\world\sound\Sound; class BarrelInventory extends SimpleInventory implements BlockInventory{ use AnimatedBlockInventoryTrait; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(27); } diff --git a/src/block/inventory/BlockInventory.php b/src/block/inventory/BlockInventory.php index 063a451a9..9e7f7f4e9 100644 --- a/src/block/inventory/BlockInventory.php +++ b/src/block/inventory/BlockInventory.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\block\inventory; -use pocketmine\world\Position; +use pocketmine\block\BlockPosition; interface BlockInventory{ - public function getHolder() : Position; + public function getHolder() : BlockPosition; } diff --git a/src/block/inventory/BlockInventoryTrait.php b/src/block/inventory/BlockInventoryTrait.php index 980e947f0..da6e04b7d 100644 --- a/src/block/inventory/BlockInventoryTrait.php +++ b/src/block/inventory/BlockInventoryTrait.php @@ -23,12 +23,12 @@ declare(strict_types=1); namespace pocketmine\block\inventory; -use pocketmine\world\Position; +use pocketmine\block\BlockPosition; trait BlockInventoryTrait{ - protected Position $holder; + protected BlockPosition $holder; - public function getHolder() : Position{ + public function getHolder() : BlockPosition{ return $this->holder; } } diff --git a/src/block/inventory/BrewingStandInventory.php b/src/block/inventory/BrewingStandInventory.php index 8bab4ba97..17e0a291a 100644 --- a/src/block/inventory/BrewingStandInventory.php +++ b/src/block/inventory/BrewingStandInventory.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; -use pocketmine\world\Position; class BrewingStandInventory extends SimpleInventory implements BlockInventory{ use BlockInventoryTrait; @@ -35,7 +35,7 @@ class BrewingStandInventory extends SimpleInventory implements BlockInventory{ public const SLOT_BOTTLE_RIGHT = 3; public const SLOT_FUEL = 4; - public function __construct(Position $holder, int $size = 5){ + public function __construct(BlockPosition $holder, int $size = 5){ $this->holder = $holder; parent::__construct($size); } diff --git a/src/block/inventory/CampfireInventory.php b/src/block/inventory/CampfireInventory.php index ae762473e..9e91a2e24 100644 --- a/src/block/inventory/CampfireInventory.php +++ b/src/block/inventory/CampfireInventory.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; -use pocketmine\world\Position; class CampfireInventory extends SimpleInventory implements BlockInventory{ use BlockInventoryTrait; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(4); } diff --git a/src/block/inventory/CartographyTableInventory.php b/src/block/inventory/CartographyTableInventory.php index 7bd9146ac..ee8a41b2b 100644 --- a/src/block/inventory/CartographyTableInventory.php +++ b/src/block/inventory/CartographyTableInventory.php @@ -23,14 +23,14 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; use pocketmine\inventory\TemporaryInventory; -use pocketmine\world\Position; final class CartographyTableInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{ use BlockInventoryTrait; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(2); } diff --git a/src/block/inventory/ChestInventory.php b/src/block/inventory/ChestInventory.php index b61fab57c..219f243b5 100644 --- a/src/block/inventory/ChestInventory.php +++ b/src/block/inventory/ChestInventory.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; use pocketmine\network\mcpe\protocol\BlockEventPacket; -use pocketmine\network\mcpe\protocol\types\BlockPosition; -use pocketmine\world\Position; +use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition; use pocketmine\world\sound\ChestCloseSound; use pocketmine\world\sound\ChestOpenSound; use pocketmine\world\sound\Sound; @@ -34,7 +34,7 @@ use pocketmine\world\sound\Sound; class ChestInventory extends SimpleInventory implements BlockInventory{ use AnimatedBlockInventoryTrait; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(27); } @@ -51,6 +51,6 @@ class ChestInventory extends SimpleInventory implements BlockInventory{ $holder = $this->getHolder(); //event ID is always 1 for a chest - $holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0)); + $holder->getWorld()->broadcastPacketToViewers($holder->asVector3(), BlockEventPacket::create(new ProtocolBlockPosition($holder->x, $holder->y, $holder->z), 1, $isOpen ? 1 : 0)); } } diff --git a/src/block/inventory/CraftingTableInventory.php b/src/block/inventory/CraftingTableInventory.php index 767e8a5f4..09a1e18aa 100644 --- a/src/block/inventory/CraftingTableInventory.php +++ b/src/block/inventory/CraftingTableInventory.php @@ -23,14 +23,14 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\crafting\CraftingGrid; use pocketmine\inventory\TemporaryInventory; -use pocketmine\world\Position; final class CraftingTableInventory extends CraftingGrid implements BlockInventory, TemporaryInventory{ use BlockInventoryTrait; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(CraftingGrid::SIZE_BIG); } diff --git a/src/block/inventory/EnchantInventory.php b/src/block/inventory/EnchantInventory.php index 6dffbad32..735c0f0f9 100644 --- a/src/block/inventory/EnchantInventory.php +++ b/src/block/inventory/EnchantInventory.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\event\player\PlayerEnchantingOptionsRequestEvent; use pocketmine\inventory\SimpleInventory; use pocketmine\inventory\TemporaryInventory; use pocketmine\item\enchantment\EnchantingHelper as Helper; use pocketmine\item\enchantment\EnchantingOption; use pocketmine\item\Item; -use pocketmine\world\Position; use function array_values; use function count; @@ -45,7 +45,7 @@ class EnchantInventory extends SimpleInventory implements BlockInventory, Tempor */ private array $options = []; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(2); } diff --git a/src/block/inventory/EnderChestInventory.php b/src/block/inventory/EnderChestInventory.php index c1d7c5401..e6eeca3e9 100644 --- a/src/block/inventory/EnderChestInventory.php +++ b/src/block/inventory/EnderChestInventory.php @@ -23,14 +23,14 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\block\tile\EnderChest; use pocketmine\inventory\DelegateInventory; use pocketmine\inventory\Inventory; use pocketmine\inventory\PlayerEnderInventory; use pocketmine\network\mcpe\protocol\BlockEventPacket; -use pocketmine\network\mcpe\protocol\types\BlockPosition; +use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition; use pocketmine\player\Player; -use pocketmine\world\Position; use pocketmine\world\sound\EnderChestCloseSound; use pocketmine\world\sound\EnderChestOpenSound; use pocketmine\world\sound\Sound; @@ -44,7 +44,7 @@ class EnderChestInventory extends DelegateInventory implements BlockInventory{ } public function __construct( - Position $holder, + BlockPosition $holder, private PlayerEnderInventory $inventory ){ parent::__construct($inventory); @@ -75,7 +75,8 @@ class EnderChestInventory extends DelegateInventory implements BlockInventory{ $holder = $this->getHolder(); //event ID is always 1 for a chest - $holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0)); + //TODO: maybe broadcast should use BlockPosition + $holder->getWorld()->broadcastPacketToViewers($holder->asVector3(), BlockEventPacket::create(new ProtocolBlockPosition($holder->x, $holder->y, $holder->z), 1, $isOpen ? 1 : 0)); } public function onClose(Player $who) : void{ diff --git a/src/block/inventory/FurnaceInventory.php b/src/block/inventory/FurnaceInventory.php index ff44d6b70..0304c2512 100644 --- a/src/block/inventory/FurnaceInventory.php +++ b/src/block/inventory/FurnaceInventory.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\crafting\FurnaceType; use pocketmine\inventory\SimpleInventory; use pocketmine\item\Item; -use pocketmine\world\Position; class FurnaceInventory extends SimpleInventory implements BlockInventory{ use BlockInventoryTrait; @@ -36,7 +36,7 @@ class FurnaceInventory extends SimpleInventory implements BlockInventory{ public const SLOT_RESULT = 2; public function __construct( - Position $holder, + BlockPosition $holder, private FurnaceType $furnaceType ){ $this->holder = $holder; diff --git a/src/block/inventory/HopperInventory.php b/src/block/inventory/HopperInventory.php index a20e9ae1a..aec7d99a5 100644 --- a/src/block/inventory/HopperInventory.php +++ b/src/block/inventory/HopperInventory.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; -use pocketmine\world\Position; class HopperInventory extends SimpleInventory implements BlockInventory{ use BlockInventoryTrait; - public function __construct(Position $holder, int $size = 5){ + public function __construct(BlockPosition $holder, int $size = 5){ $this->holder = $holder; parent::__construct($size); } diff --git a/src/block/inventory/LoomInventory.php b/src/block/inventory/LoomInventory.php index fd34620a0..5aaa8379a 100644 --- a/src/block/inventory/LoomInventory.php +++ b/src/block/inventory/LoomInventory.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; use pocketmine\inventory\TemporaryInventory; -use pocketmine\world\Position; final class LoomInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{ use BlockInventoryTrait; @@ -34,7 +34,7 @@ final class LoomInventory extends SimpleInventory implements BlockInventory, Tem public const SLOT_DYE = 1; public const SLOT_PATTERN = 2; - public function __construct(Position $holder, int $size = 3){ + public function __construct(BlockPosition $holder, int $size = 3){ $this->holder = $holder; parent::__construct($size); } diff --git a/src/block/inventory/ShulkerBoxInventory.php b/src/block/inventory/ShulkerBoxInventory.php index d915a9951..90c9fa604 100644 --- a/src/block/inventory/ShulkerBoxInventory.php +++ b/src/block/inventory/ShulkerBoxInventory.php @@ -23,12 +23,13 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\block\BlockTypeIds; use pocketmine\inventory\SimpleInventory; use pocketmine\item\Item; use pocketmine\item\ItemTypeIds; use pocketmine\network\mcpe\protocol\BlockEventPacket; -use pocketmine\network\mcpe\protocol\types\BlockPosition; +use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition; use pocketmine\world\Position; use pocketmine\world\sound\ShulkerBoxCloseSound; use pocketmine\world\sound\ShulkerBoxOpenSound; @@ -37,7 +38,7 @@ use pocketmine\world\sound\Sound; class ShulkerBoxInventory extends SimpleInventory implements BlockInventory{ use AnimatedBlockInventoryTrait; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(27); } @@ -62,6 +63,7 @@ class ShulkerBoxInventory extends SimpleInventory implements BlockInventory{ $holder = $this->getHolder(); //event ID is always 1 for a chest - $holder->getWorld()->broadcastPacketToViewers($holder, BlockEventPacket::create(BlockPosition::fromVector3($holder), 1, $isOpen ? 1 : 0)); + //TODO: maybe broadcast should use block position + $holder->getWorld()->broadcastPacketToViewers($holder->asVector3(), BlockEventPacket::create(new ProtocolBlockPosition($holder->x, $holder->y, $holder->z), 1, $isOpen ? 1 : 0)); } } diff --git a/src/block/inventory/SmithingTableInventory.php b/src/block/inventory/SmithingTableInventory.php index 2f67ac9d2..ea14a7086 100644 --- a/src/block/inventory/SmithingTableInventory.php +++ b/src/block/inventory/SmithingTableInventory.php @@ -23,14 +23,14 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; use pocketmine\inventory\TemporaryInventory; -use pocketmine\world\Position; final class SmithingTableInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{ use BlockInventoryTrait; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(3); } diff --git a/src/block/inventory/StonecutterInventory.php b/src/block/inventory/StonecutterInventory.php index 4ed644ff2..15d8330be 100644 --- a/src/block/inventory/StonecutterInventory.php +++ b/src/block/inventory/StonecutterInventory.php @@ -23,16 +23,16 @@ declare(strict_types=1); namespace pocketmine\block\inventory; +use pocketmine\block\BlockPosition; use pocketmine\inventory\SimpleInventory; use pocketmine\inventory\TemporaryInventory; -use pocketmine\world\Position; class StonecutterInventory extends SimpleInventory implements BlockInventory, TemporaryInventory{ use BlockInventoryTrait; public const SLOT_INPUT = 0; - public function __construct(Position $holder){ + public function __construct(BlockPosition $holder){ $this->holder = $holder; parent::__construct(1); } diff --git a/src/block/tile/Barrel.php b/src/block/tile/Barrel.php index a7f353214..3ffa5e3dc 100644 --- a/src/block/tile/Barrel.php +++ b/src/block/tile/Barrel.php @@ -23,10 +23,9 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\inventory\BarrelInventory; -use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; -use pocketmine\world\World; class Barrel extends Spawnable implements Container, Nameable{ use NameableTrait; @@ -34,8 +33,8 @@ class Barrel extends Spawnable implements Container, Nameable{ protected BarrelInventory $inventory; - public function __construct(World $world, Vector3 $pos){ - parent::__construct($world, $pos); + public function __construct(BlockPosition $position){ + parent::__construct($position); $this->inventory = new BarrelInventory($this->position); } diff --git a/src/block/tile/Bell.php b/src/block/tile/Bell.php index 7a1e784e3..c5a9ec2e3 100644 --- a/src/block/tile/Bell.php +++ b/src/block/tile/Bell.php @@ -88,6 +88,6 @@ final class Bell extends Spawnable{ default => throw new AssumptionFailedError("Unreachable") }); $nbt->setInt(self::TAG_TICKS, 0); - return BlockActorDataPacket::create(BlockPosition::fromVector3($this->position), new CacheableNbt($nbt)); + return BlockActorDataPacket::create(new BlockPosition($this->position->x, $this->position->y, $this->position->z), new CacheableNbt($nbt)); } } diff --git a/src/block/tile/BrewingStand.php b/src/block/tile/BrewingStand.php index c3a331e6c..be6e380fd 100644 --- a/src/block/tile/BrewingStand.php +++ b/src/block/tile/BrewingStand.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\inventory\BrewingStandInventory; use pocketmine\crafting\BrewingRecipe; use pocketmine\event\block\BrewingFuelUseEvent; @@ -31,12 +32,10 @@ use pocketmine\inventory\CallbackInventoryListener; use pocketmine\inventory\Inventory; use pocketmine\item\Item; use pocketmine\item\VanillaItems; -use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\ContainerSetDataPacket; use pocketmine\player\Player; use pocketmine\world\sound\PotionFinishBrewingSound; -use pocketmine\world\World; use function array_map; use function count; @@ -60,11 +59,11 @@ class BrewingStand extends Spawnable implements Container, Nameable{ private int $maxFuelTime = 0; private int $remainingFuelTime = 0; - public function __construct(World $world, Vector3 $pos){ - parent::__construct($world, $pos); + public function __construct(BlockPosition $position){ + parent::__construct($position); $this->inventory = new BrewingStandInventory($this->position); - $this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(static function(Inventory $unused) use ($world, $pos) : void{ - $world->scheduleDelayedBlockUpdate($pos, 1); + $this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange(static function(Inventory $unused) use ($position) : void{ + $position->getWorld()->scheduleDelayedBlockUpdate($position, 1); })); } @@ -215,7 +214,7 @@ class BrewingStand extends Spawnable implements Container, Nameable{ } if($anythingBrewed){ - $this->position->getWorld()->addSound($this->position->add(0.5, 0.5, 0.5), new PotionFinishBrewingSound()); + $this->position->getWorld()->addSound($this->position->asVector3()->add(0.5, 0.5, 0.5), new PotionFinishBrewingSound()); } $ingredient->pop(); diff --git a/src/block/tile/Campfire.php b/src/block/tile/Campfire.php index ad4a193d7..ab48670c5 100644 --- a/src/block/tile/Campfire.php +++ b/src/block/tile/Campfire.php @@ -23,16 +23,15 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\Campfire as BlockCampfire; use pocketmine\block\inventory\CampfireInventory; use pocketmine\inventory\CallbackInventoryListener; use pocketmine\inventory\Inventory; use pocketmine\item\Item; -use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\network\mcpe\convert\TypeConverter; -use pocketmine\world\World; class Campfire extends Spawnable implements Container{ use ContainerTrait; @@ -51,14 +50,15 @@ class Campfire extends Spawnable implements Container{ /** @var array */ private array $cookingTimes = []; - public function __construct(World $world, Vector3 $pos){ - parent::__construct($world, $pos); + public function __construct(BlockPosition $position){ + parent::__construct($position); $this->inventory = new CampfireInventory($this->position); $this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange( - static function(Inventory $unused) use ($world, $pos) : void{ - $block = $world->getBlock($pos); + static function(Inventory $unused) use ($position) : void{ + $world = $position->getWorld(); + $block = $world->getBlock($position); if($block instanceof BlockCampfire){ - $world->setBlock($pos, $block); + $world->setBlock($position, $block); } }) ); diff --git a/src/block/tile/Chest.php b/src/block/tile/Chest.php index 4f97eed23..14d6df638 100644 --- a/src/block/tile/Chest.php +++ b/src/block/tile/Chest.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\inventory\ChestInventory; use pocketmine\block\inventory\DoubleChestInventory; use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\world\format\Chunk; -use pocketmine\world\World; use function abs; class Chest extends Spawnable implements Container, Nameable{ @@ -50,8 +50,8 @@ class Chest extends Spawnable implements Container, Nameable{ private ?int $pairX = null; private ?int $pairZ = null; - public function __construct(World $world, Vector3 $pos){ - parent::__construct($world, $pos); + public function __construct(BlockPosition $position){ + parent::__construct($position); $this->inventory = new ChestInventory($this->position); } diff --git a/src/block/tile/ChiseledBookshelf.php b/src/block/tile/ChiseledBookshelf.php index 06175e27f..0d06b35c7 100644 --- a/src/block/tile/ChiseledBookshelf.php +++ b/src/block/tile/ChiseledBookshelf.php @@ -23,18 +23,17 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\utils\ChiseledBookshelfSlot; use pocketmine\data\bedrock\item\SavedItemData; use pocketmine\data\bedrock\item\SavedItemStackData; use pocketmine\data\SavedDataLoadingException; use pocketmine\inventory\SimpleInventory; use pocketmine\item\Item; -use pocketmine\math\Vector3; use pocketmine\nbt\NBT; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\StringTag; -use pocketmine\world\World; use function count; class ChiseledBookshelf extends Tile implements Container{ @@ -46,8 +45,8 @@ class ChiseledBookshelf extends Tile implements Container{ private ?ChiseledBookshelfSlot $lastInteractedSlot = null; - public function __construct(World $world, Vector3 $pos){ - parent::__construct($world, $pos); + public function __construct(BlockPosition $position){ + parent::__construct($position); $this->inventory = new SimpleInventory(count(ChiseledBookshelfSlot::cases())); } diff --git a/src/block/tile/ContainerTrait.php b/src/block/tile/ContainerTrait.php index fdd050a41..566804d24 100644 --- a/src/block/tile/ContainerTrait.php +++ b/src/block/tile/ContainerTrait.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\data\bedrock\item\SavedItemStackData; use pocketmine\data\SavedDataLoadingException; use pocketmine\inventory\Inventory; @@ -31,7 +32,6 @@ use pocketmine\nbt\NBT; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\StringTag; -use pocketmine\world\Position; /** * This trait implements most methods in the {@link Container} interface. It should only be used by Tiles. @@ -90,9 +90,9 @@ trait ContainerTrait{ } /** - * @see Position::asPosition() + * @see Tile::getPosition() */ - abstract protected function getPosition() : Position; + abstract protected function getPosition() : BlockPosition; /** * @see Tile::onBlockDestroyedHook() @@ -102,7 +102,7 @@ trait ContainerTrait{ $pos = $this->getPosition(); $world = $pos->getWorld(); - $dropPos = $pos->add(0.5, 0.5, 0.5); + $dropPos = $pos->asVector3()->add(0.5, 0.5, 0.5); foreach($inv->getContents() as $k => $item){ $world->dropItem($dropPos, $item); } diff --git a/src/block/tile/Furnace.php b/src/block/tile/Furnace.php index a706a827e..38afa4102 100644 --- a/src/block/tile/Furnace.php +++ b/src/block/tile/Furnace.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\Furnace as BlockFurnace; use pocketmine\block\inventory\FurnaceInventory; use pocketmine\crafting\FurnaceRecipe; @@ -32,11 +33,9 @@ use pocketmine\event\inventory\FurnaceSmeltEvent; use pocketmine\inventory\CallbackInventoryListener; use pocketmine\inventory\Inventory; use pocketmine\item\Item; -use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\ContainerSetDataPacket; use pocketmine\player\Player; -use pocketmine\world\World; use function array_map; use function max; @@ -53,12 +52,12 @@ abstract class Furnace extends Spawnable implements Container, Nameable{ private int $cookTime = 0; private int $maxFuelTime = 0; - public function __construct(World $world, Vector3 $pos){ - parent::__construct($world, $pos); + public function __construct(BlockPosition $position){ + parent::__construct($position); $this->inventory = new FurnaceInventory($this->position, $this->getFurnaceType()); $this->inventory->getListeners()->add(CallbackInventoryListener::onAnyChange( - static function(Inventory $unused) use ($world, $pos) : void{ - $world->scheduleDelayedBlockUpdate($pos, 1); + static function(Inventory $unused) use ($position) : void{ + $position->getWorld()->scheduleDelayedBlockUpdate($position, 1); }) ); } diff --git a/src/block/tile/Hopper.php b/src/block/tile/Hopper.php index 5c39bc2bd..0ba0d8923 100644 --- a/src/block/tile/Hopper.php +++ b/src/block/tile/Hopper.php @@ -23,10 +23,9 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\inventory\HopperInventory; -use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; -use pocketmine\world\World; class Hopper extends Spawnable implements Container, Nameable{ @@ -38,8 +37,8 @@ class Hopper extends Spawnable implements Container, Nameable{ private HopperInventory $inventory; private int $transferCooldown = 0; - public function __construct(World $world, Vector3 $pos){ - parent::__construct($world, $pos); + public function __construct(BlockPosition $position){ + parent::__construct($position); $this->inventory = new HopperInventory($this->position); } diff --git a/src/block/tile/ItemFrame.php b/src/block/tile/ItemFrame.php index 7d003770e..d0fe7c927 100644 --- a/src/block/tile/ItemFrame.php +++ b/src/block/tile/ItemFrame.php @@ -23,13 +23,12 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\item\Item; use pocketmine\item\VanillaItems; -use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\FloatTag; use pocketmine\network\mcpe\convert\TypeConverter; -use pocketmine\world\World; /** * @deprecated @@ -44,9 +43,9 @@ class ItemFrame extends Spawnable{ private int $itemRotation = 0; private float $itemDropChance = 1.0; - public function __construct(World $world, Vector3 $pos){ + public function __construct(BlockPosition $position){ $this->item = VanillaItems::AIR(); - parent::__construct($world, $pos); + parent::__construct($position); } public function readSaveData(CompoundTag $nbt) : void{ diff --git a/src/block/tile/Jukebox.php b/src/block/tile/Jukebox.php index 54acd60ee..729db99ee 100644 --- a/src/block/tile/Jukebox.php +++ b/src/block/tile/Jukebox.php @@ -65,6 +65,6 @@ class Jukebox extends Spawnable{ } protected function onBlockDestroyedHook() : void{ - $this->position->getWorld()->addSound($this->position, new RecordStopSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new RecordStopSound()); } } diff --git a/src/block/tile/ShulkerBox.php b/src/block/tile/ShulkerBox.php index a30b75c4e..c5f87c879 100644 --- a/src/block/tile/ShulkerBox.php +++ b/src/block/tile/ShulkerBox.php @@ -23,12 +23,11 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\inventory\ShulkerBoxInventory; use pocketmine\item\Item; use pocketmine\math\Facing; -use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; -use pocketmine\world\World; class ShulkerBox extends Spawnable implements Container, Nameable{ use NameableTrait { @@ -42,8 +41,8 @@ class ShulkerBox extends Spawnable implements Container, Nameable{ protected ShulkerBoxInventory $inventory; - public function __construct(World $world, Vector3 $pos){ - parent::__construct($world, $pos); + public function __construct(BlockPosition $position){ + parent::__construct($position); $this->inventory = new ShulkerBoxInventory($this->position); } diff --git a/src/block/tile/Sign.php b/src/block/tile/Sign.php index 2ced414ff..f1b0f59f6 100644 --- a/src/block/tile/Sign.php +++ b/src/block/tile/Sign.php @@ -23,15 +23,14 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\block\utils\SignText; use pocketmine\color\Color; -use pocketmine\math\Vector3; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\StringTag; use pocketmine\utils\Binary; -use pocketmine\world\World; use function array_pad; use function array_slice; use function explode; @@ -72,9 +71,9 @@ class Sign extends Spawnable{ protected ?int $editorEntityRuntimeId = null; - public function __construct(World $world, Vector3 $pos){ + public function __construct(BlockPosition $position){ $this->text = new SignText(); - parent::__construct($world, $pos); + parent::__construct($position); } private function readTextTag(CompoundTag $nbt, bool $lightingBugResolved) : void{ diff --git a/src/block/tile/Tile.php b/src/block/tile/Tile.php index 7b709f679..37b03c0cd 100644 --- a/src/block/tile/Tile.php +++ b/src/block/tile/Tile.php @@ -28,15 +28,13 @@ declare(strict_types=1); namespace pocketmine\block\tile; use pocketmine\block\Block; +use pocketmine\block\BlockPosition; use pocketmine\item\Item; -use pocketmine\math\Vector3; use pocketmine\nbt\NbtDataException; use pocketmine\nbt\tag\CompoundTag; use pocketmine\timings\Timings; use pocketmine\timings\TimingsHandler; use pocketmine\VersionInfo; -use pocketmine\world\Position; -use pocketmine\world\World; use function get_class; abstract class Tile{ @@ -46,12 +44,12 @@ abstract class Tile{ public const TAG_Y = "y"; public const TAG_Z = "z"; - protected Position $position; public bool $closed = false; protected TimingsHandler $timings; - public function __construct(World $world, Vector3 $pos){ - $this->position = Position::fromObject($pos, $world); + public function __construct( + protected BlockPosition $position, + ){ $this->timings = Timings::getTileEntityTimings($this); } @@ -70,9 +68,9 @@ abstract class Tile{ public function saveNBT() : CompoundTag{ $nbt = CompoundTag::create() ->setString(self::TAG_ID, TileFactory::getInstance()->getSaveId(get_class($this))) - ->setInt(self::TAG_X, $this->position->getFloorX()) - ->setInt(self::TAG_Y, $this->position->getFloorY()) - ->setInt(self::TAG_Z, $this->position->getFloorZ()) + ->setInt(self::TAG_X, $this->position->x) + ->setInt(self::TAG_Y, $this->position->y) + ->setInt(self::TAG_Z, $this->position->z) ->setLong(VersionInfo::TAG_WORLD_DATA_VERSION, VersionInfo::WORLD_DATA_VERSION); $this->writeSaveData($nbt); @@ -99,7 +97,7 @@ abstract class Tile{ return $this->position->getWorld()->getBlock($this->position); } - public function getPosition() : Position{ + public function getPosition() : BlockPosition{ return $this->position; } diff --git a/src/block/tile/TileFactory.php b/src/block/tile/TileFactory.php index 515dd8c63..b9e95e02c 100644 --- a/src/block/tile/TileFactory.php +++ b/src/block/tile/TileFactory.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\block\tile; +use pocketmine\block\BlockPosition; use pocketmine\data\SavedDataLoadingException; -use pocketmine\math\Vector3; use pocketmine\nbt\NbtException; use pocketmine\nbt\tag\CompoundTag; use pocketmine\utils\SingletonTrait; @@ -130,7 +130,7 @@ final class TileFactory{ * @var Tile $tile * @see Tile::__construct() */ - $tile = new $class($world, new Vector3($nbt->getInt(Tile::TAG_X), $nbt->getInt(Tile::TAG_Y), $nbt->getInt(Tile::TAG_Z))); + $tile = new $class(new BlockPosition($nbt->getInt(Tile::TAG_X), $nbt->getInt(Tile::TAG_Y), $nbt->getInt(Tile::TAG_Z), $world)); $tile->readSaveData($nbt); }catch(NbtException $e){ throw new SavedDataLoadingException($e->getMessage(), 0, $e); diff --git a/src/block/utils/AmethystTrait.php b/src/block/utils/AmethystTrait.php index e581d3517..94abadb71 100644 --- a/src/block/utils/AmethystTrait.php +++ b/src/block/utils/AmethystTrait.php @@ -34,7 +34,7 @@ trait AmethystTrait{ * @see Block::onProjectileHit() */ public function onProjectileHit(Projectile $projectile, RayTraceResult $hitResult) : void{ - $this->position->getWorld()->addSound($this->position, new AmethystBlockChimeSound()); - $this->position->getWorld()->addSound($this->position, new BlockPunchSound($this)); + $this->position->getWorld()->addSound($this->position->asVector3(), new AmethystBlockChimeSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new BlockPunchSound($this)); } } diff --git a/src/block/utils/CandleTrait.php b/src/block/utils/CandleTrait.php index c9da97ee0..1fff5a7ec 100644 --- a/src/block/utils/CandleTrait.php +++ b/src/block/utils/CandleTrait.php @@ -54,9 +54,9 @@ trait CandleTrait{ }elseif($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){ $item->pop(); //TODO: not sure if this is intentional, but it's what Bedrock currently does as of 1.20.10 - $this->position->getWorld()->addSound($this->position, new BlazeShootSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new BlazeShootSound()); } - $this->position->getWorld()->addSound($this->position, new FlintSteelSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new FlintSteelSound()); $this->position->getWorld()->setBlock($this->position, $this->setLit(true)); return true; @@ -65,7 +65,7 @@ trait CandleTrait{ if(!$this->lit){ return true; } - $this->position->getWorld()->addSound($this->position, new FireExtinguishSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new FireExtinguishSound()); $this->position->getWorld()->setBlock($this->position, $this->setLit(false)); return true; diff --git a/src/block/utils/CopperTrait.php b/src/block/utils/CopperTrait.php index 5ad8aa82d..f9a003fe6 100644 --- a/src/block/utils/CopperTrait.php +++ b/src/block/utils/CopperTrait.php @@ -63,7 +63,7 @@ trait CopperTrait{ $this->waxed = true; $this->position->getWorld()->setBlock($this->position, $this); //TODO: orange particles are supposed to appear when applying wax - $this->position->getWorld()->addSound($this->position, new CopperWaxApplySound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new CopperWaxApplySound()); $item->pop(); return true; } @@ -73,7 +73,7 @@ trait CopperTrait{ $this->waxed = false; $this->position->getWorld()->setBlock($this->position, $this); //TODO: white particles are supposed to appear when removing wax - $this->position->getWorld()->addSound($this->position, new CopperWaxRemoveSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new CopperWaxRemoveSound()); $item->applyDamage(1); return true; } @@ -83,7 +83,7 @@ trait CopperTrait{ $this->oxidation = $previousOxidation; $this->position->getWorld()->setBlock($this->position, $this); //TODO: turquoise particles are supposed to appear when removing oxidation - $this->position->getWorld()->addSound($this->position, new ScrapeSound()); + $this->position->getWorld()->addSound($this->position->asVector3(), new ScrapeSound()); $item->applyDamage(1); return true; } diff --git a/src/block/utils/CropGrowthHelper.php b/src/block/utils/CropGrowthHelper.php index e85b0b82d..cee807259 100644 --- a/src/block/utils/CropGrowthHelper.php +++ b/src/block/utils/CropGrowthHelper.php @@ -56,9 +56,9 @@ final class CropGrowthHelper{ $position = $block->getPosition(); $world = $position->getWorld(); - $baseX = $position->getFloorX(); - $baseY = $position->getFloorY(); - $baseZ = $position->getFloorZ(); + $baseX = $position->x; + $baseY = $position->y; + $baseZ = $position->z; $farmland = $world->getBlockAt($baseX, $baseY - 1, $baseZ); diff --git a/src/block/utils/FallableTrait.php b/src/block/utils/FallableTrait.php index f062792ef..178026684 100644 --- a/src/block/utils/FallableTrait.php +++ b/src/block/utils/FallableTrait.php @@ -24,12 +24,12 @@ declare(strict_types=1); namespace pocketmine\block\utils; use pocketmine\block\Block; +use pocketmine\block\BlockPosition; use pocketmine\block\VanillaBlocks; use pocketmine\entity\Location; use pocketmine\entity\object\FallingBlock; use pocketmine\math\Facing; use pocketmine\utils\AssumptionFailedError; -use pocketmine\world\Position; use pocketmine\world\sound\Sound; /** @@ -39,7 +39,7 @@ use pocketmine\world\sound\Sound; */ trait FallableTrait{ - abstract protected function getPosition() : Position; + abstract protected function getPosition() : BlockPosition; public function onNearbyBlockChange() : void{ $pos = $this->getPosition(); @@ -51,7 +51,7 @@ trait FallableTrait{ $block = $this; if(!($block instanceof Block)) throw new AssumptionFailedError(__TRAIT__ . " should only be used by Blocks"); - $fall = new FallingBlock(Location::fromObject($pos->add(0.5, 0, 0.5), $world), $block); + $fall = new FallingBlock(Location::fromObject($pos->asVector3()->add(0.5, 0, 0.5), $world), $block); $fall->spawnToAll(); } } diff --git a/src/entity/EntityFactory.php b/src/entity/EntityFactory.php index 03d9c03e6..3a4582a18 100644 --- a/src/entity/EntityFactory.php +++ b/src/entity/EntityFactory.php @@ -26,6 +26,7 @@ namespace pocketmine\entity; use DaveRandom\CallbackValidator\CallbackType; use DaveRandom\CallbackValidator\ParameterType; use DaveRandom\CallbackValidator\ReturnType; +use pocketmine\block\BlockPosition; use pocketmine\block\RuntimeBlockStateRegistry; use pocketmine\data\bedrock\LegacyEntityIdToStringIdMap; use pocketmine\data\bedrock\PotionTypeIdMap; @@ -48,7 +49,6 @@ use pocketmine\entity\projectile\Snowball; use pocketmine\entity\projectile\SplashPotion; use pocketmine\item\Item; use pocketmine\math\Facing; -use pocketmine\math\Vector3; use pocketmine\nbt\NbtException; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; @@ -143,7 +143,7 @@ final class EntityFactory{ if($motive === null){ throw new SavedDataLoadingException("Unknown painting motive"); } - $blockIn = new Vector3($nbt->getInt(Painting::TAG_TILE_X), $nbt->getInt(Painting::TAG_TILE_Y), $nbt->getInt(Painting::TAG_TILE_Z)); + $blockIn = new BlockPosition($nbt->getInt(Painting::TAG_TILE_X), $nbt->getInt(Painting::TAG_TILE_Y), $nbt->getInt(Painting::TAG_TILE_Z), $world); if(($directionTag = $nbt->getTag(Painting::TAG_DIRECTION_BE)) instanceof ByteTag){ $facing = Painting::DATA_TO_FACING[$directionTag->getValue()] ?? Facing::NORTH; }elseif(($facingTag = $nbt->getTag(Painting::TAG_FACING_JE)) instanceof ByteTag){ diff --git a/src/entity/Living.php b/src/entity/Living.php index 852344784..28e7d8a34 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -377,11 +377,12 @@ abstract class Living extends Entity{ } protected function onHitGround() : ?float{ - $fallBlockPos = $this->location->floor(); - $fallBlock = $this->getWorld()->getBlock($fallBlockPos); + $fallBlockX = $this->location->getFloorX(); + $fallBlockY = $this->location->getFloorY(); + $fallBlockZ = $this->location->getFloorZ(); + $fallBlock = $this->getWorld()->getBlockAt($fallBlockX, $fallBlockY, $fallBlockZ); if(count($fallBlock->getCollisionBoxes()) === 0){ - $fallBlockPos = $fallBlockPos->down(); - $fallBlock = $this->getWorld()->getBlock($fallBlockPos); + $fallBlock = $this->getWorld()->getBlockAt($fallBlockX, $fallBlockY - 1, $fallBlockZ); } $newVerticalVelocity = $fallBlock->onEntityLand($this); diff --git a/src/entity/object/FallingBlock.php b/src/entity/object/FallingBlock.php index 5285ebbbc..342a79316 100644 --- a/src/entity/object/FallingBlock.php +++ b/src/entity/object/FallingBlock.php @@ -132,7 +132,7 @@ class FallingBlock extends Entity{ $world = $this->getWorld(); $pos = $this->location->add(-$this->size->getWidth() / 2, $this->size->getHeight(), -$this->size->getWidth() / 2)->floor(); - $this->block->position($world, $pos->x, $pos->y, $pos->z); + $this->block->position($world, $pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ()); $blockTarget = null; if($this->block instanceof Fallable){ @@ -143,7 +143,7 @@ class FallingBlock extends Entity{ $this->flagForDespawn(); $blockResult = $blockTarget ?? $this->block; - $block = $world->getBlock($pos); + $block = $world->getBlock($this->block->getPosition()); if(!$block->canBeReplaced() || !$world->isInWorld($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ()) || ($this->onGround && abs($this->location->y - $this->location->getFloorY()) > 0.001)){ $world->dropItem($this->location, $this->block->asItem()); $world->addSound($pos->add(0.5, 0.5, 0.5), new BlockBreakSound($blockResult)); @@ -152,7 +152,7 @@ class FallingBlock extends Entity{ $ev->call(); if(!$ev->isCancelled()){ $b = $ev->getTo(); - $world->setBlock($pos, $b); + $world->setBlock($this->block->getPosition(), $b); if($this->onGround && $b instanceof Fallable && ($sound = $b->getLandSound()) !== null){ $world->addSound($pos->add(0.5, 0.5, 0.5), $sound); } diff --git a/src/entity/object/Painting.php b/src/entity/object/Painting.php index 78a006d77..2613bf9f5 100644 --- a/src/entity/object/Painting.php +++ b/src/entity/object/Painting.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\entity\object; +use pocketmine\block\BlockPosition; use pocketmine\block\VanillaBlocks; use pocketmine\entity\Entity; use pocketmine\entity\EntitySizeInfo; @@ -64,13 +65,13 @@ class Painting extends Entity{ Facing::EAST => 3 ]; - protected Vector3 $blockIn; + protected BlockPosition $blockIn; protected int $facing; protected PaintingMotive $motive; - public function __construct(Location $location, Vector3 $blockIn, int $facing, PaintingMotive $motive, ?CompoundTag $nbt = null){ + public function __construct(Location $location, BlockPosition $blockIn, int $facing, PaintingMotive $motive, ?CompoundTag $nbt = null){ $this->motive = $motive; - $this->blockIn = $blockIn->asVector3(); + $this->blockIn = $blockIn; $this->facing = $facing; parent::__construct($location, $nbt); } @@ -92,9 +93,9 @@ class Painting extends Entity{ public function saveNBT() : CompoundTag{ $nbt = parent::saveNBT(); - $nbt->setInt(self::TAG_TILE_X, (int) $this->blockIn->x); - $nbt->setInt(self::TAG_TILE_Y, (int) $this->blockIn->y); - $nbt->setInt(self::TAG_TILE_Z, (int) $this->blockIn->z); + $nbt->setInt(self::TAG_TILE_X, $this->blockIn->x); + $nbt->setInt(self::TAG_TILE_Y, $this->blockIn->y); + $nbt->setInt(self::TAG_TILE_Z, $this->blockIn->z); $nbt->setByte(self::TAG_FACING_JE, self::FACING_TO_DATA[$this->facing]); $nbt->setByte(self::TAG_DIRECTION_BE, self::FACING_TO_DATA[$this->facing]); //Save both for full compatibility @@ -202,7 +203,7 @@ class Painting extends Entity{ /** * Returns whether a painting with the specified motive can be placed at the given position. */ - public static function canFit(World $world, Vector3 $blockIn, int $facing, bool $checkOverlap, PaintingMotive $motive) : bool{ + public static function canFit(World $world, BlockPosition $blockIn, int $facing, bool $checkOverlap, PaintingMotive $motive) : bool{ $width = $motive->getWidth(); $height = $motive->getHeight(); @@ -213,7 +214,7 @@ class Painting extends Entity{ $oppositeSide = Facing::opposite($facing); - $startPos = $blockIn->asVector3()->getSide(Facing::opposite($rotatedFace), $horizontalStart)->getSide(Facing::DOWN, $verticalStart); + $startPos = $blockIn->getSide(Facing::opposite($rotatedFace), $horizontalStart)->getSide(Facing::DOWN, $verticalStart); for($w = 0; $w < $width; ++$w){ for($h = 0; $h < $height; ++$h){ diff --git a/src/entity/projectile/IceBomb.php b/src/entity/projectile/IceBomb.php index 5a3525c74..a37c9d60d 100644 --- a/src/entity/projectile/IceBomb.php +++ b/src/entity/projectile/IceBomb.php @@ -68,9 +68,9 @@ class IceBomb extends Throwable{ $pos = $blockHit->getPosition(); $world = $pos->getWorld(); - $posX = $pos->getFloorX(); - $posY = $pos->getFloorY(); - $posZ = $pos->getFloorZ(); + $posX = $pos->x; + $posY = $pos->y; + $posZ = $pos->z; $ice = VanillaBlocks::ICE(); for($x = $posX - 1; $x <= $posX + 1; $x++){ diff --git a/src/entity/projectile/Projectile.php b/src/entity/projectile/Projectile.php index 0abc274b5..21ae2a2fd 100644 --- a/src/entity/projectile/Projectile.php +++ b/src/entity/projectile/Projectile.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\entity\projectile; use pocketmine\block\Block; +use pocketmine\block\BlockPosition; use pocketmine\data\SavedDataLoadingException; use pocketmine\entity\Entity; use pocketmine\entity\Living; @@ -60,7 +61,7 @@ abstract class Projectile extends Entity{ private const TAG_TILE_Z = "tileZ"; //TAG_Int protected float $damage = 0.0; - protected ?Vector3 $blockHit = null; + protected ?BlockPosition $blockHit = null; public function __construct(Location $location, ?Entity $shootingEntity, ?CompoundTag $nbt = null){ parent::__construct($location, $nbt); @@ -90,9 +91,9 @@ abstract class Projectile extends Entity{ /** @var IntTag[] $values */ $values = $stuckOnBlockPosTag->getValue(); - $this->blockHit = new Vector3($values[0]->getValue(), $values[1]->getValue(), $values[2]->getValue()); + $this->blockHit = new BlockPosition($values[0]->getValue(), $values[1]->getValue(), $values[2]->getValue(), $this->getWorld()); }elseif(($tileXTag = $nbt->getTag(self::TAG_TILE_X)) instanceof IntTag && ($tileYTag = $nbt->getTag(self::TAG_TILE_Y)) instanceof IntTag && ($tileZTag = $nbt->getTag(self::TAG_TILE_Z)) instanceof IntTag){ - $this->blockHit = new Vector3($tileXTag->getValue(), $tileYTag->getValue(), $tileZTag->getValue()); + $this->blockHit = new BlockPosition($tileXTag->getValue(), $tileYTag->getValue(), $tileZTag->getValue(), $this->getWorld()); } } @@ -133,9 +134,9 @@ abstract class Projectile extends Entity{ if($this->blockHit !== null){ $nbt->setTag(self::TAG_STUCK_ON_BLOCK_POS, new ListTag([ - new IntTag($this->blockHit->getFloorX()), - new IntTag($this->blockHit->getFloorY()), - new IntTag($this->blockHit->getFloorZ()) + new IntTag($this->blockHit->x), + new IntTag($this->blockHit->y), + new IntTag($this->blockHit->z) ])); } @@ -147,7 +148,7 @@ abstract class Projectile extends Entity{ } public function onNearbyBlockChange() : void{ - if($this->blockHit !== null && $this->getWorld()->isInLoadedTerrain($this->blockHit)){ + if($this->blockHit !== null && $this->getWorld()->isInLoadedTerrain($this->blockHit->asVector3())){ $blockHit = $this->getWorld()->getBlock($this->blockHit); if(!$blockHit->collidesWithBB($this->getBoundingBox()->expandedCopy(0.001, 0.001, 0.001))){ $this->blockHit = null; @@ -176,7 +177,7 @@ abstract class Projectile extends Entity{ $world = $this->getWorld(); foreach(VoxelRayTrace::betweenPoints($start, $end) as $vector3){ - $block = $world->getBlockAt($vector3->x, $vector3->y, $vector3->z); + $block = $world->getBlockAt($vector3->getFloorX(), $vector3->getFloorY(), $vector3->getFloorZ()); $blockHitResult = $this->calculateInterceptWithBlock($block, $start, $end); if($blockHitResult !== null){ @@ -314,7 +315,7 @@ abstract class Projectile extends Entity{ * Called when the projectile collides with a Block. */ protected function onHitBlock(Block $blockHit, RayTraceResult $hitResult) : void{ - $this->blockHit = $blockHit->getPosition()->asVector3(); + $this->blockHit = $blockHit->getPosition(); $blockHit->onProjectileHit($this, $hitResult); } } diff --git a/src/item/Bucket.php b/src/item/Bucket.php index ee69a0a8a..e27937843 100644 --- a/src/item/Bucket.php +++ b/src/item/Bucket.php @@ -56,7 +56,7 @@ class Bucket extends Item{ $ev->call(); if(!$ev->isCancelled()){ $player->getWorld()->setBlock($blockClicked->getPosition(), VanillaBlocks::AIR()); - $player->getWorld()->addSound($blockClicked->getPosition()->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound()); + $player->getWorld()->addSound($blockClicked->getPosition()->asVector3()->add(0.5, 0.5, 0.5), $blockClicked->getBucketFillSound()); $this->pop(); $returnedItems[] = $ev->getItem(); diff --git a/src/item/EndCrystal.php b/src/item/EndCrystal.php index 320d657e6..62ceeb69e 100644 --- a/src/item/EndCrystal.php +++ b/src/item/EndCrystal.php @@ -40,14 +40,14 @@ class EndCrystal extends Item{ $pos = $blockClicked->getPosition(); $world = $pos->getWorld(); $bb = AxisAlignedBB::one() - ->offset($pos->getX(), $pos->getY(), $pos->getZ()) + ->offset($pos->x, $pos->y, $pos->z) ->extend(Facing::UP, 1); if( count($world->getNearbyEntities($bb)) === 0 && $blockClicked->getSide(Facing::UP)->getTypeId() === BlockTypeIds::AIR && $blockClicked->getSide(Facing::UP, 2)->getTypeId() === BlockTypeIds::AIR ){ - $crystal = new EntityEndCrystal(Location::fromObject($pos->add(0.5, 1, 0.5), $world)); + $crystal = new EntityEndCrystal(Location::fromObject($pos->asVector3()->add(0.5, 1, 0.5), $world)); $crystal->spawnToAll(); $this->pop(); diff --git a/src/item/FireCharge.php b/src/item/FireCharge.php index a612e0897..a80a5ad46 100644 --- a/src/item/FireCharge.php +++ b/src/item/FireCharge.php @@ -36,7 +36,7 @@ class FireCharge extends Item{ if($blockReplace->getTypeId() === BlockTypeIds::AIR){ $world = $player->getWorld(); $world->setBlock($blockReplace->getPosition(), VanillaBlocks::FIRE()); - $world->addSound($blockReplace->getPosition()->add(0.5, 0.5, 0.5), new BlazeShootSound()); + $world->addSound($blockReplace->getPosition()->asVector3()->add(0.5, 0.5, 0.5), new BlazeShootSound()); $this->pop(); diff --git a/src/item/FlintSteel.php b/src/item/FlintSteel.php index 3e694eb0d..b5da77838 100644 --- a/src/item/FlintSteel.php +++ b/src/item/FlintSteel.php @@ -36,7 +36,7 @@ class FlintSteel extends Tool{ if($blockReplace->getTypeId() === BlockTypeIds::AIR){ $world = $player->getWorld(); $world->setBlock($blockReplace->getPosition(), VanillaBlocks::FIRE()); - $world->addSound($blockReplace->getPosition()->add(0.5, 0.5, 0.5), new FlintSteelSound()); + $world->addSound($blockReplace->getPosition()->asVector3()->add(0.5, 0.5, 0.5), new FlintSteelSound()); $this->applyDamage(1); diff --git a/src/item/LiquidBucket.php b/src/item/LiquidBucket.php index eb2cb18ed..c6e1ecc53 100644 --- a/src/item/LiquidBucket.php +++ b/src/item/LiquidBucket.php @@ -66,7 +66,7 @@ class LiquidBucket extends Item{ $ev->call(); if(!$ev->isCancelled()){ $player->getWorld()->setBlock($blockReplace->getPosition(), $resultBlock->getFlowingForm()); - $player->getWorld()->addSound($blockReplace->getPosition()->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound()); + $player->getWorld()->addSound($blockReplace->getPosition()->asVector3()->add(0.5, 0.5, 0.5), $resultBlock->getBucketEmptySound()); $this->pop(); $returnedItems[] = $ev->getItem(); diff --git a/src/item/PaintingItem.php b/src/item/PaintingItem.php index a83c8dba8..f70e7894f 100644 --- a/src/item/PaintingItem.php +++ b/src/item/PaintingItem.php @@ -74,13 +74,14 @@ class PaintingItem extends Item{ $motive = $motives[array_rand($motives)]; $replacePos = $blockReplace->getPosition(); + $replaceVec3 = $replacePos->asVector3(); $clickedPos = $blockClicked->getPosition(); - $entity = new Painting(Location::fromObject($replacePos, $replacePos->getWorld()), $clickedPos, $face, $motive); + $entity = new Painting(Location::fromObject($replaceVec3, $replacePos->getWorld()), $clickedPos, $face, $motive); $this->pop(); $entity->spawnToAll(); - $player->getWorld()->addSound($replacePos->add(0.5, 0.5, 0.5), new PaintingPlaceSound()); + $player->getWorld()->addSound($replaceVec3->add(0.5, 0.5, 0.5), new PaintingPlaceSound()); return ItemUseResult::SUCCESS; } } diff --git a/src/item/SpawnEgg.php b/src/item/SpawnEgg.php index ab4f0e149..ea51d28c2 100644 --- a/src/item/SpawnEgg.php +++ b/src/item/SpawnEgg.php @@ -35,7 +35,7 @@ abstract class SpawnEgg extends Item{ abstract protected function createEntity(World $world, Vector3 $pos, float $yaw, float $pitch) : Entity; public function onInteractBlock(Player $player, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, array &$returnedItems) : ItemUseResult{ - $entity = $this->createEntity($player->getWorld(), $blockReplace->getPosition()->add(0.5, 0, 0.5), Utils::getRandomFloat() * 360, 0); + $entity = $this->createEntity($player->getWorld(), $blockReplace->getPosition()->asVector3()->add(0.5, 0, 0.5), Utils::getRandomFloat() * 360, 0); if($this->hasCustomName()){ $entity->setNameTag($this->getCustomName()); diff --git a/src/item/enchantment/EnchantingHelper.php b/src/item/enchantment/EnchantingHelper.php index fb4e8f27c..cd1100c90 100644 --- a/src/item/enchantment/EnchantingHelper.php +++ b/src/item/enchantment/EnchantingHelper.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\item\enchantment; +use pocketmine\block\BlockPosition; use pocketmine\block\BlockTypeIds; use pocketmine\item\enchantment\AvailableEnchantmentRegistry as EnchantmentRegistry; use pocketmine\item\Item; @@ -75,7 +76,7 @@ final class EnchantingHelper{ /** * @return EnchantingOption[] */ - public static function generateOptions(Position $tablePos, Item $input, int $seed) : array{ + public static function generateOptions(BlockPosition $tablePos, Item $input, int $seed) : array{ if($input->isNull() || $input->hasEnchantments()){ return []; } @@ -95,7 +96,7 @@ final class EnchantingHelper{ ]; } - private static function countBookshelves(Position $tablePos) : int{ + private static function countBookshelves(BlockPosition $tablePos) : int{ $bookshelfCount = 0; $world = $tablePos->getWorld(); diff --git a/src/network/mcpe/InventoryManager.php b/src/network/mcpe/InventoryManager.php index 7df8c734b..9b803ebba 100644 --- a/src/network/mcpe/InventoryManager.php +++ b/src/network/mcpe/InventoryManager.php @@ -357,7 +357,8 @@ class InventoryManager{ //TODO: we should be using some kind of tagging system to identify the types. Instanceof is flaky especially //if the class isn't final, not to mention being inflexible. if($inv instanceof BlockInventory){ - $blockPosition = BlockPosition::fromVector3($inv->getHolder()); + $blockPosition = $inv->getHolder(); + $protocolBlockPosition = new BlockPosition($blockPosition->x, $blockPosition->y, $blockPosition->z); $windowType = match(true){ $inv instanceof LoomInventory => WindowTypes::LOOM, $inv instanceof FurnaceInventory => match($inv->getFurnaceType()){ @@ -376,7 +377,7 @@ class InventoryManager{ $inv instanceof SmithingTableInventory => WindowTypes::SMITHING_TABLE, default => WindowTypes::CONTAINER }; - return [ContainerOpenPacket::blockInv($id, $windowType, $blockPosition)]; + return [ContainerOpenPacket::blockInv($id, $windowType, $protocolBlockPosition)]; } return null; } diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 78b11e27e..f3b3b0a9b 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\network\mcpe; +use pocketmine\block\BlockPosition; use pocketmine\entity\effect\EffectInstance; use pocketmine\event\player\PlayerDuplicateLoginEvent; use pocketmine\event\player\PlayerResourcePackOfferEvent; @@ -83,7 +84,7 @@ use pocketmine\network\mcpe\protocol\ToastRequestPacket; use pocketmine\network\mcpe\protocol\TransferPacket; use pocketmine\network\mcpe\protocol\types\AbilitiesData; use pocketmine\network\mcpe\protocol\types\AbilitiesLayer; -use pocketmine\network\mcpe\protocol\types\BlockPosition; +use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition; use pocketmine\network\mcpe\protocol\types\command\CommandData; use pocketmine\network\mcpe\protocol\types\command\CommandEnum; use pocketmine\network\mcpe\protocol\types\command\CommandOverload; @@ -1005,17 +1006,17 @@ class NetworkSession{ } public function syncViewAreaCenterPoint(Vector3 $newPos, int $viewDistance) : void{ - $this->sendDataPacket(NetworkChunkPublisherUpdatePacket::create(BlockPosition::fromVector3($newPos), $viewDistance * 16, [])); //blocks, not chunks >.> + $this->sendDataPacket(NetworkChunkPublisherUpdatePacket::create(ProtocolBlockPosition::fromVector3($newPos), $viewDistance * 16, [])); //blocks, not chunks >.> } public function syncPlayerSpawnPoint(Position $newSpawn) : void{ - $newSpawnBlockPosition = BlockPosition::fromVector3($newSpawn); + $newSpawnBlockPosition = ProtocolBlockPosition::fromVector3($newSpawn); //TODO: respawn causing block position (bed, respawn anchor) $this->sendDataPacket(SetSpawnPositionPacket::playerSpawn($newSpawnBlockPosition, DimensionIds::OVERWORLD, $newSpawnBlockPosition)); } public function syncWorldSpawnPoint(Position $newSpawn) : void{ - $this->sendDataPacket(SetSpawnPositionPacket::worldSpawn(BlockPosition::fromVector3($newSpawn), DimensionIds::OVERWORLD)); + $this->sendDataPacket(SetSpawnPositionPacket::worldSpawn(ProtocolBlockPosition::fromVector3($newSpawn), DimensionIds::OVERWORLD)); } public function syncGameMode(GameMode $mode, bool $isRollback = false) : void{ @@ -1288,8 +1289,8 @@ class NetworkSession{ $this->sendDataPacket(ToastRequestPacket::create($title, $body)); } - public function onOpenSignEditor(Vector3 $signPosition, bool $frontSide) : void{ - $this->sendDataPacket(OpenSignPacket::create(BlockPosition::fromVector3($signPosition), $frontSide)); + public function onOpenSignEditor(BlockPosition $signPosition, bool $frontSide) : void{ + $this->sendDataPacket(OpenSignPacket::create(new ProtocolBlockPosition($signPosition->x, $signPosition->y, $signPosition->z), $frontSide)); } public function onItemCooldownChanged(Item $item, int $ticks) : void{ diff --git a/src/network/mcpe/convert/TypeConverter.php b/src/network/mcpe/convert/TypeConverter.php index e886b2b8b..1ff5d3adb 100644 --- a/src/network/mcpe/convert/TypeConverter.php +++ b/src/network/mcpe/convert/TypeConverter.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\convert; +use pocketmine\block\BlockPosition; use pocketmine\block\VanillaBlocks; use pocketmine\crafting\ExactRecipeIngredient; use pocketmine\crafting\MetaWildcardRecipeIngredient; @@ -37,6 +38,7 @@ use pocketmine\nbt\NbtException; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\serializer\ItemTypeDictionary; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; +use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition; use pocketmine\network\mcpe\protocol\types\GameMode as ProtocolGameMode; use pocketmine\network\mcpe\protocol\types\inventory\ItemStack; use pocketmine\network\mcpe\protocol\types\inventory\ItemStackExtraData; @@ -51,6 +53,7 @@ use pocketmine\utils\Filesystem; use pocketmine\utils\SingletonTrait; use pocketmine\world\format\io\GlobalBlockStateHandlers; use pocketmine\world\format\io\GlobalItemDataHandlers; +use pocketmine\world\World; use function get_class; class TypeConverter{ @@ -276,4 +279,24 @@ class TypeConverter{ ItemStackExtraDataShield::read($extraDataDeserializer) : ItemStackExtraData::read($extraDataDeserializer); } + + public function coreBlockPositionToNet(?BlockPosition $position) : ProtocolBlockPosition{ + if($position === null){ + return new ProtocolBlockPosition(0, 0, 0); + } + return new ProtocolBlockPosition( + $position->x, + $position->y, + $position->z + ); + } + + public function netBlockPositionToCore(ProtocolBlockPosition $position, World $world) : BlockPosition{ + return new BlockPosition( + $position->getX(), + $position->getY(), + $position->getZ(), + $world + ); + } } diff --git a/src/network/mcpe/handler/InGamePacketHandler.php b/src/network/mcpe/handler/InGamePacketHandler.php index 0db50cd78..558b24855 100644 --- a/src/network/mcpe/handler/InGamePacketHandler.php +++ b/src/network/mcpe/handler/InGamePacketHandler.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\handler; use pocketmine\block\BaseSign; +use pocketmine\block\BlockPosition; use pocketmine\block\Lectern; use pocketmine\block\tile\Sign; use pocketmine\block\utils\SignText; @@ -85,7 +86,7 @@ use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket; use pocketmine\network\mcpe\protocol\SubClientLoginPacket; use pocketmine\network\mcpe\protocol\TextPacket; use pocketmine\network\mcpe\protocol\types\ActorEvent; -use pocketmine\network\mcpe\protocol\types\BlockPosition; +use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition; use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds; use pocketmine\network\mcpe\protocol\types\inventory\MismatchTransactionData; use pocketmine\network\mcpe\protocol\types\inventory\NetworkInventoryAction; @@ -257,7 +258,7 @@ class InGamePacketHandler extends PacketHandler{ foreach(Utils::promoteKeys($blockActions) as $k => $blockAction){ $actionHandled = false; if($blockAction instanceof PlayerBlockActionStopBreak){ - $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(), new BlockPosition(0, 0, 0), Facing::DOWN); + $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(), new ProtocolBlockPosition(0, 0, 0), Facing::DOWN); }elseif($blockAction instanceof PlayerBlockActionWithBlockInfo){ $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(), $blockAction->getBlockPosition(), $blockAction->getFace()); } @@ -494,20 +495,20 @@ class InGamePacketHandler extends PacketHandler{ self::validateFacing($data->getFace()); - $blockPos = $data->getBlockPosition(); - $vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ()); - $this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos); + $networkBlockPos = $data->getBlockPosition(); + $blockPos = new BlockPosition($networkBlockPos->getX(), $networkBlockPos->getY(), $networkBlockPos->getZ(), $this->player->getWorld()); + $this->player->interactBlock($blockPos, $data->getFace(), $clickPos); //always sync this in case plugins caused a different result than the client expected //we *could* try to enhance detection of plugin-altered behaviour, but this would require propagating //more information up the stack. For now I think this is good enough. //if only the client would tell us what blocks it thinks changed... - $this->syncBlocksNearby($vBlockPos, $data->getFace()); + $this->syncBlocksNearby($blockPos, $data->getFace()); return true; case UseItemTransactionData::ACTION_BREAK_BLOCK: - $blockPos = $data->getBlockPosition(); - $vBlockPos = new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ()); - if(!$this->player->breakBlock($vBlockPos)){ - $this->syncBlocksNearby($vBlockPos, null); + $networkBlockPos = $data->getBlockPosition(); + $blockPos = new BlockPosition($networkBlockPos->getX(), $networkBlockPos->getY(), $networkBlockPos->getZ(), $this->player->getWorld()); + if(!$this->player->breakBlock($blockPos)){ + $this->syncBlocksNearby($blockPos, null); } return true; case UseItemTransactionData::ACTION_CLICK_AIR: @@ -537,14 +538,14 @@ class InGamePacketHandler extends PacketHandler{ /** * Syncs blocks nearby to ensure that the client and server agree on the world's blocks after a block interaction. */ - private function syncBlocksNearby(Vector3 $blockPos, ?int $face) : void{ - if($blockPos->distanceSquared($this->player->getLocation()) < 10000){ - $blocks = $blockPos->sidesArray(); + private function syncBlocksNearby(BlockPosition $blockPos, ?int $face) : void{ + //TODO: migrate this to BlockPosition + if($blockPos->asVector3()->distanceSquared($this->player->getLocation()) < 10000){ + $blocks = $blockPos->getAllSidesArray(); if($face !== null){ $sidePos = $blockPos->getSide($face); - /** @var Vector3[] $blocks */ - array_push($blocks, ...$sidePos->sidesArray()); //getAllSides() on each of these will include $blockPos and $sidePos because they are next to each other + array_push($blocks, ...$sidePos->getAllSidesArray()); //getAllSides() on each of these will include $blockPos and $sidePos because they are next to each other }else{ $blocks[] = $blockPos; } @@ -670,7 +671,7 @@ class InGamePacketHandler extends PacketHandler{ } public function handleBlockPickRequest(BlockPickRequestPacket $packet) : bool{ - return $this->player->pickBlock(new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ()), $packet->addUserData); + return $this->player->pickBlock(new BlockPosition($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ(), $this->player->getWorld()), $packet->addUserData); } public function handleActorPickRequest(ActorPickRequestPacket $packet) : bool{ @@ -681,8 +682,8 @@ class InGamePacketHandler extends PacketHandler{ return $this->handlePlayerActionFromData($packet->action, $packet->blockPosition, $packet->face); } - private function handlePlayerActionFromData(int $action, BlockPosition $blockPosition, int $face) : bool{ - $pos = new Vector3($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ()); + private function handlePlayerActionFromData(int $action, ProtocolBlockPosition $blockPosition, int $face) : bool{ + $pos = new BlockPosition($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ(), $this->player->getWorld()); switch($action){ case PlayerAction::START_BREAK: @@ -744,8 +745,8 @@ class InGamePacketHandler extends PacketHandler{ } public function handleBlockActorData(BlockActorDataPacket $packet) : bool{ - $pos = new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ()); - if($pos->distanceSquared($this->player->getLocation()) > 10000){ + $pos = new BlockPosition($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ(), $this->player->getWorld()); + if($pos->asVector3()->distanceSquared($this->player->getLocation()) > 10000){ return false; } @@ -1002,9 +1003,10 @@ class InGamePacketHandler extends PacketHandler{ } $lectern = $world->getBlockAt($pos->getX(), $pos->getY(), $pos->getZ()); - if($lectern instanceof Lectern && $this->player->canInteract($lectern->getPosition(), 15)){ + $lecternPos = $lectern->getPosition(); + if($lectern instanceof Lectern && $this->player->canInteract($lecternPos->asVector3(), 15)){ if(!$lectern->onPageTurn($packet->page)){ - $this->syncBlocksNearby($lectern->getPosition(), null); + $this->syncBlocksNearby($lecternPos, null); } return true; } diff --git a/src/player/Player.php b/src/player/Player.php index 5e57ab1cc..ad4347b95 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -26,6 +26,7 @@ namespace pocketmine\player; use DateTimeImmutable; use pocketmine\block\BaseSign; use pocketmine\block\Bed; +use pocketmine\block\BlockPosition; use pocketmine\block\BlockTypeTags; use pocketmine\block\UnknownBlock; use pocketmine\block\VanillaBlocks; @@ -106,11 +107,12 @@ use pocketmine\lang\Translatable; use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; +use pocketmine\network\mcpe\convert\TypeConverter; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\AnimatePacket; use pocketmine\network\mcpe\protocol\MovePlayerPacket; use pocketmine\network\mcpe\protocol\SetActorMotionPacket; -use pocketmine\network\mcpe\protocol\types\BlockPosition; +use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition; use pocketmine\network\mcpe\protocol\types\DimensionIds; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; @@ -274,7 +276,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ protected float $stepHeight = 0.6; - protected ?Vector3 $sleeping = null; + protected ?BlockPosition $sleeping = null; private ?Position $spawnPosition = null; private bool $respawnLocked = false; @@ -1112,8 +1114,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ return $this->sleeping !== null; } - public function sleepOn(Vector3 $pos) : bool{ - $pos = $pos->floor(); + public function sleepOn(BlockPosition $pos) : bool{ $b = $this->getWorld()->getBlock($pos); $ev = new PlayerBedEnterEvent($this, $b); @@ -1130,7 +1131,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->sleeping = $pos; $this->networkPropertiesDirty = true; - $this->setSpawn($pos); + $this->setSpawn($pos->asVector3()); $this->getWorld()->setSleepTicks(60); @@ -1138,7 +1139,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } public function stopSleep() : void{ - if($this->sleeping instanceof Vector3){ + if($this->sleeping !== null){ $b = $this->getWorld()->getBlock($this->sleeping); if($b instanceof Bed){ $b->setOccupied(false); @@ -1737,7 +1738,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } } - public function pickBlock(Vector3 $pos, bool $addTileNBT) : bool{ + public function pickBlock(BlockPosition $pos, bool $addTileNBT) : bool{ $block = $this->getWorld()->getBlock($pos); if($block instanceof UnknownBlock){ return true; @@ -1810,8 +1811,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ * * @return bool if an action took place successfully */ - public function attackBlock(Vector3 $pos, int $face) : bool{ - if($pos->distanceSquared($this->location) > 10000){ + public function attackBlock(BlockPosition $pos, int $face) : bool{ + if($pos->asVector3()->distanceSquared($this->location) > 10000){ return false; //TODO: maybe this should throw an exception instead? } @@ -1833,7 +1834,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $block = $target->getSide($face); if($block->hasTypeTag(BlockTypeTags::FIRE)){ $this->getWorld()->setBlock($block->getPosition(), VanillaBlocks::AIR()); - $this->getWorld()->addSound($block->getPosition()->add(0.5, 0.5, 0.5), new FireExtinguishSound()); + $this->getWorld()->addSound($block->getPosition()->asVector3()->add(0.5, 0.5, 0.5), new FireExtinguishSound()); return true; } @@ -1844,14 +1845,14 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ return true; } - public function continueBreakBlock(Vector3 $pos, int $face) : void{ - if($this->blockBreakHandler !== null && $this->blockBreakHandler->getBlockPos()->distanceSquared($pos) < 0.0001){ + public function continueBreakBlock(BlockPosition $pos, int $face) : void{ + if($this->blockBreakHandler !== null && $this->blockBreakHandler->getBlockPos()->asVector3()->distanceSquared($pos->asVector3()) < 0.0001){ $this->blockBreakHandler->setTargetedFace($face); } } - public function stopBreakBlock(Vector3 $pos) : void{ - if($this->blockBreakHandler !== null && $this->blockBreakHandler->getBlockPos()->distanceSquared($pos) < 0.0001){ + public function stopBreakBlock(BlockPosition $pos) : void{ + if($this->blockBreakHandler !== null && $this->blockBreakHandler->getBlockPos()->asVector3()->distanceSquared($pos->asVector3()) < 0.0001){ $this->blockBreakHandler = null; } } @@ -1861,10 +1862,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ * * @return bool if the block was successfully broken, false if a rollback needs to take place. */ - public function breakBlock(Vector3 $pos) : bool{ + public function breakBlock(BlockPosition $pos) : bool{ $this->removeCurrentWindow(); - if($this->canInteract($pos->add(0.5, 0.5, 0.5), $this->isCreative() ? self::MAX_REACH_DISTANCE_CREATIVE : self::MAX_REACH_DISTANCE_SURVIVAL)){ + if($this->canInteract($pos->asVector3()->add(0.5, 0.5, 0.5), $this->isCreative() ? self::MAX_REACH_DISTANCE_CREATIVE : self::MAX_REACH_DISTANCE_SURVIVAL)){ $this->broadcastAnimation(new ArmSwingAnimation($this), $this->getViewers()); $this->stopBreakBlock($pos); $item = $this->inventory->getItemInHand(); @@ -1887,10 +1888,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ * * @return bool if it did something */ - public function interactBlock(Vector3 $pos, int $face, Vector3 $clickOffset) : bool{ + public function interactBlock(BlockPosition $pos, int $face, Vector3 $clickOffset) : bool{ $this->setUsingItem(false); - if($this->canInteract($pos->add(0.5, 0.5, 0.5), $this->isCreative() ? self::MAX_REACH_DISTANCE_CREATIVE : self::MAX_REACH_DISTANCE_SURVIVAL)){ + if($this->canInteract($pos->asVector3()->add(0.5, 0.5, 0.5), $this->isCreative() ? self::MAX_REACH_DISTANCE_CREATIVE : self::MAX_REACH_DISTANCE_SURVIVAL)){ $this->broadcastAnimation(new ArmSwingAnimation($this), $this->getViewers()); $item = $this->inventory->getItemInHand(); //this is a copy of the real item $oldItem = clone $item; @@ -2572,15 +2573,15 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $properties->setGenericFlag(EntityMetadataFlags::HAS_COLLISION, $this->hasBlockCollision()); $properties->setPlayerFlag(PlayerMetadataFlags::SLEEP, $this->sleeping !== null); - $properties->setBlockPos(EntityMetadataProperties::PLAYER_BED_POSITION, $this->sleeping !== null ? BlockPosition::fromVector3($this->sleeping) : new BlockPosition(0, 0, 0)); + $properties->setBlockPos(EntityMetadataProperties::PLAYER_BED_POSITION, TypeConverter::getInstance()->coreBlockPositionToNet($this->sleeping)); if($this->deathPosition !== null && $this->deathPosition->world === $this->location->world){ - $properties->setBlockPos(EntityMetadataProperties::PLAYER_DEATH_POSITION, BlockPosition::fromVector3($this->deathPosition)); + $properties->setBlockPos(EntityMetadataProperties::PLAYER_DEATH_POSITION, ProtocolBlockPosition::fromVector3($this->deathPosition)); //TODO: this should be updated when dimensions are implemented $properties->setInt(EntityMetadataProperties::PLAYER_DEATH_DIMENSION, DimensionIds::OVERWORLD); $properties->setByte(EntityMetadataProperties::PLAYER_HAS_DIED, 1); }else{ - $properties->setBlockPos(EntityMetadataProperties::PLAYER_DEATH_POSITION, new BlockPosition(0, 0, 0)); + $properties->setBlockPos(EntityMetadataProperties::PLAYER_DEATH_POSITION, new ProtocolBlockPosition(0, 0, 0)); $properties->setInt(EntityMetadataProperties::PLAYER_DEATH_DIMENSION, DimensionIds::OVERWORLD); $properties->setByte(EntityMetadataProperties::PLAYER_HAS_DIED, 0); } @@ -2787,7 +2788,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ * Opens the player's sign editor GUI for the sign at the given position. * TODO: add support for editing the rear side of the sign (not currently supported due to technical limitations) */ - public function openSignEditor(Vector3 $position) : void{ + public function openSignEditor(BlockPosition $position) : void{ $block = $this->getWorld()->getBlock($position); if($block instanceof BaseSign){ $this->getWorld()->setBlock($position, $block->setEditorEntityRuntimeId($this->getId())); diff --git a/src/player/SurvivalBlockBreakHandler.php b/src/player/SurvivalBlockBreakHandler.php index e31e77ef7..472b6dcc9 100644 --- a/src/player/SurvivalBlockBreakHandler.php +++ b/src/player/SurvivalBlockBreakHandler.php @@ -24,9 +24,9 @@ declare(strict_types=1); namespace pocketmine\player; use pocketmine\block\Block; +use pocketmine\block\BlockPosition; use pocketmine\entity\animation\ArmSwingAnimation; use pocketmine\math\Facing; -use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\LevelEvent; use pocketmine\world\particle\BlockPunchParticle; @@ -43,7 +43,7 @@ final class SurvivalBlockBreakHandler{ public function __construct( private Player $player, - private Vector3 $blockPos, + private BlockPosition $blockPos, private Block $block, private int $targetedFace, private int $maxPlayerDistance, @@ -51,9 +51,10 @@ final class SurvivalBlockBreakHandler{ ){ $this->breakSpeed = $this->calculateBreakProgressPerTick(); if($this->breakSpeed > 0){ + $vector3 = $this->blockPos->asVector3(); $this->player->getWorld()->broadcastPacketToViewers( - $this->blockPos, - LevelEventPacket::create(LevelEvent::BLOCK_START_BREAK, (int) (65535 * $this->breakSpeed), $this->blockPos) + $vector3, + LevelEventPacket::create(LevelEvent::BLOCK_START_BREAK, (int) (65535 * $this->breakSpeed), $vector3) ); } } @@ -75,7 +76,8 @@ final class SurvivalBlockBreakHandler{ } public function update() : bool{ - if($this->player->getPosition()->distanceSquared($this->blockPos->add(0.5, 0.5, 0.5)) > $this->maxPlayerDistance ** 2){ + $vector3 = $this->blockPos->asVector3(); + if($this->player->getPosition()->distanceSquared($vector3->add(0.5, 0.5, 0.5)) > $this->maxPlayerDistance ** 2){ return false; } @@ -88,15 +90,15 @@ final class SurvivalBlockBreakHandler{ $this->breakProgress += $this->breakSpeed; if(($this->fxTicker++ % $this->fxTickInterval) === 0 && $this->breakProgress < 1){ - $this->player->getWorld()->addParticle($this->blockPos, new BlockPunchParticle($this->block, $this->targetedFace)); - $this->player->getWorld()->addSound($this->blockPos, new BlockPunchSound($this->block)); + $this->player->getWorld()->addParticle($vector3, new BlockPunchParticle($this->block, $this->targetedFace)); + $this->player->getWorld()->addSound($vector3, new BlockPunchSound($this->block)); $this->player->broadcastAnimation(new ArmSwingAnimation($this->player), $this->player->getViewers()); } return $this->breakProgress < 1; } - public function getBlockPos() : Vector3{ + public function getBlockPos() : BlockPosition{ return $this->blockPos; } @@ -118,10 +120,11 @@ final class SurvivalBlockBreakHandler{ } public function __destruct(){ - if($this->player->getWorld()->isInLoadedTerrain($this->blockPos)){ + $vector3 = $this->blockPos->asVector3(); + if($this->player->getWorld()->isInLoadedTerrain($vector3)){ $this->player->getWorld()->broadcastPacketToViewers( - $this->blockPos, - LevelEventPacket::create(LevelEvent::BLOCK_STOP_BREAK, 0, $this->blockPos) + $vector3, + LevelEventPacket::create(LevelEvent::BLOCK_STOP_BREAK, 0, $vector3) ); } } diff --git a/src/world/BlockTransaction.php b/src/world/BlockTransaction.php index 46cbc7903..96feb3575 100644 --- a/src/world/BlockTransaction.php +++ b/src/world/BlockTransaction.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\world; use pocketmine\block\Block; +use pocketmine\block\BlockPosition; use pocketmine\math\Vector3; use pocketmine\utils\Utils; @@ -51,8 +52,8 @@ class BlockTransaction{ * * @return $this */ - public function addBlock(Vector3 $pos, Block $state) : self{ - return $this->addBlockAt($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ(), $state); + public function addBlock(BlockPosition $pos, Block $state) : self{ + return $this->addBlockAt($pos->x, $pos->y, $pos->z, $state); } /** diff --git a/src/world/Explosion.php b/src/world/Explosion.php index 601f9109e..af0fa274c 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -206,7 +206,7 @@ class Explosion{ }else{ if(mt_rand(0, 100) < $yield){ foreach($block->getDrops($air) as $drop){ - $this->world->dropItem($pos->add(0.5, 0.5, 0.5), $drop); + $this->world->dropItem($pos->asVector3()->add(0.5, 0.5, 0.5), $drop); } } if(($t = $this->world->getTileAt($pos->x, $pos->y, $pos->z)) !== null){ diff --git a/src/world/World.php b/src/world/World.php index ff65377c0..1fff94426 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -28,6 +28,7 @@ namespace pocketmine\world; use pocketmine\block\Air; use pocketmine\block\Block; +use pocketmine\block\BlockPosition; use pocketmine\block\BlockTypeIds; use pocketmine\block\RuntimeBlockStateRegistry; use pocketmine\block\tile\Spawnable; @@ -72,7 +73,7 @@ use pocketmine\network\mcpe\convert\TypeConverter; use pocketmine\network\mcpe\NetworkBroadcastUtils; use pocketmine\network\mcpe\protocol\BlockActorDataPacket; use pocketmine\network\mcpe\protocol\ClientboundPacket; -use pocketmine\network\mcpe\protocol\types\BlockPosition; +use pocketmine\network\mcpe\protocol\types\BlockPosition as ProtocolBlockPosition; use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\player\Player; use pocketmine\promise\Promise; @@ -283,12 +284,12 @@ class World implements ChunkManager{ private array $chunks = []; /** - * @var Vector3[][] chunkHash => [relativeBlockHash => Vector3] - * @phpstan-var array> + * @var BlockPosition[][] chunkHash => [relativeBlockHash => BlockPosition] + * @phpstan-var array> */ private array $changedBlocks = []; - /** @phpstan-var ReversePriorityQueue */ + /** @phpstan-var ReversePriorityQueue */ private ReversePriorityQueue $scheduledBlockUpdateQueue; /** * @var int[] blockHash => tick delay @@ -953,10 +954,10 @@ class World implements ChunkManager{ $this->timings->scheduledBlockUpdates->startTiming(); //Delayed updates while($this->scheduledBlockUpdateQueue->count() > 0 && $this->scheduledBlockUpdateQueue->current()["priority"] <= $currentTick){ - /** @var Vector3 $vec */ + /** @var BlockPosition $vec */ $vec = $this->scheduledBlockUpdateQueue->extract()["data"]; unset($this->scheduledBlockUpdateQueueIndex[World::blockHash($vec->x, $vec->y, $vec->z)]); - if(!$this->isInLoadedTerrain($vec)){ + if(!$this->isChunkLoaded($vec->x >> Chunk::COORD_BIT_SIZE, $vec->z >> Chunk::COORD_BIT_SIZE)){ continue; } $block = $this->getBlock($vec); @@ -1083,8 +1084,8 @@ class World implements ChunkManager{ } /** - * @param Vector3[] $blocks - * @phpstan-param list $blocks + * @param BlockPosition[] $blocks + * @phpstan-param list $blocks * * @return ClientboundPacket[] * @phpstan-return list @@ -1095,12 +1096,12 @@ class World implements ChunkManager{ $blockTranslator = TypeConverter::getInstance()->getBlockTranslator(); foreach($blocks as $b){ - if(!($b instanceof Vector3)){ + if(!($b instanceof BlockPosition)){ throw new \TypeError("Expected Vector3 in blocks array, got " . (is_object($b) ? get_class($b) : gettype($b))); } $fullBlock = $this->getBlockAt($b->x, $b->y, $b->z); - $blockPosition = BlockPosition::fromVector3($b); + $blockPosition = new ProtocolBlockPosition($b->x, $b->y, $b->z); $tile = $this->getTileAt($b->x, $b->y, $b->z); if($tile instanceof Spawnable){ @@ -1449,7 +1450,7 @@ class World implements ChunkManager{ * Schedules a block update to be executed after the specified number of ticks. * Blocks will be updated with the scheduled update type. */ - public function scheduleDelayedBlockUpdate(Vector3 $pos, int $delay) : void{ + public function scheduleDelayedBlockUpdate(BlockPosition $pos, int $delay) : void{ if( !$this->isInWorld($pos->x, $pos->y, $pos->z) || (isset($this->scheduledBlockUpdateQueueIndex[$index = World::blockHash($pos->x, $pos->y, $pos->z)]) && $this->scheduledBlockUpdateQueueIndex[$index] <= $delay) @@ -1457,7 +1458,7 @@ class World implements ChunkManager{ return; } $this->scheduledBlockUpdateQueueIndex[$index] = $delay; - $this->scheduledBlockUpdateQueue->insert(new Vector3((int) $pos->x, (int) $pos->y, (int) $pos->z), $delay + $this->server->getTick()); + $this->scheduledBlockUpdateQueue->insert(new BlockPosition($pos->x, $pos->y, $pos->z, $this), $delay + $this->server->getTick()); } private function tryAddToNeighbourUpdateQueue(int $x, int $y, int $z) : void{ @@ -1673,11 +1674,8 @@ class World implements ChunkManager{ * Returns the highest level of any type of light at the given coordinates, adjusted for the current weather and * time of day. */ - public function getFullLight(Vector3 $pos) : int{ - $floorX = $pos->getFloorX(); - $floorY = $pos->getFloorY(); - $floorZ = $pos->getFloorZ(); - return $this->getFullLightAt($floorX, $floorY, $floorZ); + public function getFullLight(BlockPosition $pos) : int{ + return $this->getFullLightAt($pos->x, $pos->y, $pos->z); } /** @@ -1867,8 +1865,8 @@ class World implements ChunkManager{ * @param bool $cached Whether to use the block cache for getting the block (faster, but may be inaccurate) * @param bool $addToCache Whether to cache the block object created by this method call. */ - public function getBlock(Vector3 $pos, bool $cached = true, bool $addToCache = true) : Block{ - return $this->getBlockAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z), $cached, $addToCache); + public function getBlock(BlockPosition $pos, bool $cached = true, bool $addToCache = true) : Block{ + return $this->getBlockAt($pos->x, $pos->y, $pos->z, $cached, $addToCache); } /** @@ -1931,8 +1929,8 @@ class World implements ChunkManager{ * * @throws \InvalidArgumentException if the position is out of the world bounds */ - public function setBlock(Vector3 $pos, Block $block, bool $update = true) : void{ - $this->setBlockAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z), $block, $update); + public function setBlock(BlockPosition $pos, Block $block, bool $update = true) : void{ + $this->setBlockAt($pos->x, $pos->y, $pos->z, $block, $update); } /** @@ -1961,7 +1959,6 @@ class World implements ChunkManager{ $block->position($this, $x, $y, $z); $block->writeStateToWorld(); - $pos = new Vector3($x, $y, $z); $chunkHash = World::chunkHash($chunkX, $chunkZ); $relativeBlockHash = World::chunkBlockHash($x, $y, $z); @@ -1979,8 +1976,9 @@ class World implements ChunkManager{ if(!isset($this->changedBlocks[$chunkHash])){ $this->changedBlocks[$chunkHash] = []; } - $this->changedBlocks[$chunkHash][$relativeBlockHash] = $pos; + $this->changedBlocks[$chunkHash][$relativeBlockHash] = new BlockPosition($x, $y, $z, $this); + $pos = new Vector3($x, $y, $z); foreach($this->getChunkListeners($chunkX, $chunkZ) as $listener){ $listener->onBlockChanged($pos); } @@ -2037,11 +2035,9 @@ class World implements ChunkManager{ * @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped, if the inventory is full) * @phpstan-param-out Item $item */ - public function useBreakOn(Vector3 $vector, ?Item &$item = null, ?Player $player = null, bool $createParticles = false, array &$returnedItems = []) : bool{ - $vector = $vector->floor(); - - $chunkX = $vector->getFloorX() >> Chunk::COORD_BIT_SIZE; - $chunkZ = $vector->getFloorZ() >> Chunk::COORD_BIT_SIZE; + public function useBreakOn(BlockPosition $vector, ?Item &$item = null, ?Player $player = null, bool $createParticles = false, array &$returnedItems = []) : bool{ + $chunkX = $vector->x >> Chunk::COORD_BIT_SIZE; + $chunkZ = $vector->z >> Chunk::COORD_BIT_SIZE; if(!$this->isChunkLoaded($chunkX, $chunkZ) || $this->isChunkLocked($chunkX, $chunkZ)){ return false; } @@ -2105,7 +2101,7 @@ class World implements ChunkManager{ $item->onDestroyBlock($target, $returnedItems); if(count($drops) > 0){ - $dropPos = $vector->add(0.5, 0.5, 0.5); + $dropPos = $vector->asVector3()->add(0.5, 0.5, 0.5); foreach($drops as $drop){ if(!$drop->isNull()){ $this->dropItem($dropPos, $drop); @@ -2114,7 +2110,7 @@ class World implements ChunkManager{ } if($xpDrop > 0){ - $this->dropExperience($vector->add(0.5, 0.5, 0.5), $xpDrop); + $this->dropExperience($vector->asVector3()->add(0.5, 0.5, 0.5), $xpDrop); } return true; @@ -2125,7 +2121,7 @@ class World implements ChunkManager{ */ private function destroyBlockInternal(Block $target, Item $item, ?Player $player, bool $createParticles, array &$returnedItems) : void{ if($createParticles){ - $this->addParticle($target->getPosition()->add(0.5, 0.5, 0.5), new BlockBreakParticle($target)); + $this->addParticle($target->getPosition()->asVector3()->add(0.5, 0.5, 0.5), new BlockBreakParticle($target)); } $target->onBreak($item, $player, $returnedItems); @@ -2143,7 +2139,7 @@ class World implements ChunkManager{ * @param bool $playSound Whether to play a block-place sound if the block was placed successfully. * @param Item[] &$returnedItems Items to be added to the target's inventory (or dropped if the inventory is full) */ - public function useItemOn(Vector3 $vector, Item &$item, int $face, ?Vector3 $clickVector = null, ?Player $player = null, bool $playSound = false, array &$returnedItems = []) : bool{ + public function useItemOn(BlockPosition $vector, Item &$item, int $face, ?Vector3 $clickVector = null, ?Player $player = null, bool $playSound = false, array &$returnedItems = []) : bool{ $blockClicked = $this->getBlock($vector); $blockReplace = $blockClicked->getSide($face); @@ -2161,8 +2157,8 @@ class World implements ChunkManager{ //TODO: build height limit messages for custom world heights and mcregion cap return false; } - $chunkX = $blockReplace->getPosition()->getFloorX() >> Chunk::COORD_BIT_SIZE; - $chunkZ = $blockReplace->getPosition()->getFloorZ() >> Chunk::COORD_BIT_SIZE; + $chunkX = $blockReplace->getPosition()->x >> Chunk::COORD_BIT_SIZE; + $chunkZ = $blockReplace->getPosition()->z >> Chunk::COORD_BIT_SIZE; if(!$this->isChunkLoaded($chunkX, $chunkZ) || $this->isChunkLocked($chunkX, $chunkZ)){ return false; } @@ -2273,7 +2269,7 @@ class World implements ChunkManager{ } if($playSound){ - $this->addSound($hand->getPosition(), new BlockPlaceSound($hand)); + $this->addSound($hand->getPosition()->asVector3(), new BlockPlaceSound($hand)); } $item->pop(); @@ -2405,8 +2401,8 @@ class World implements ChunkManager{ * Note: This method wraps getTileAt(). If you're guaranteed to be passing integers, and you're using this method * in performance-sensitive code, consider using getTileAt() instead of this method for better performance. */ - public function getTile(Vector3 $pos) : ?Tile{ - return $this->getTileAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z)); + public function getTile(BlockPosition $pos) : ?Tile{ + return $this->getTileAt($pos->x, $pos->y, $pos->z); } /** @@ -2544,9 +2540,9 @@ class World implements ChunkManager{ $transferredTiles = 0; foreach($oldChunk->getTiles() as $oldTile){ $tilePosition = $oldTile->getPosition(); - $localX = $tilePosition->getFloorX() & Chunk::COORD_MASK; - $localY = $tilePosition->getFloorY(); - $localZ = $tilePosition->getFloorZ() & Chunk::COORD_MASK; + $localX = $tilePosition->x & Chunk::COORD_MASK; + $localY = $tilePosition->y; + $localZ = $tilePosition->z & Chunk::COORD_MASK; $newBlock = RuntimeBlockStateRegistry::getInstance()->fromStateId($chunk->getBlockStateId($localX, $localY, $localZ)); $expectedTileClass = $newBlock->getIdInfo()->getTileClass(); @@ -2772,12 +2768,12 @@ class World implements ChunkManager{ if(!$pos->isValid() || $pos->getWorld() !== $this){ throw new \InvalidArgumentException("Invalid Tile world"); } - if(!$this->isInWorld($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ())){ + if(!$this->isInWorld($pos->x, $pos->y, $pos->z)){ throw new \InvalidArgumentException("Tile position is outside the world bounds"); } - $chunkX = $pos->getFloorX() >> Chunk::COORD_BIT_SIZE; - $chunkZ = $pos->getFloorZ() >> Chunk::COORD_BIT_SIZE; + $chunkX = $pos->x >> Chunk::COORD_BIT_SIZE; + $chunkZ = $pos->z >> Chunk::COORD_BIT_SIZE; if(isset($this->chunks[$hash = World::chunkHash($chunkX, $chunkZ)])){ $this->chunks[$hash]->addTile($tile); @@ -2786,7 +2782,7 @@ class World implements ChunkManager{ } //delegate tile ticking to the corresponding block - $this->scheduleDelayedBlockUpdate($pos->asVector3(), 1); + $this->scheduleDelayedBlockUpdate($pos, 1); } /** @@ -2799,8 +2795,8 @@ class World implements ChunkManager{ throw new \InvalidArgumentException("Invalid Tile world"); } - $chunkX = $pos->getFloorX() >> Chunk::COORD_BIT_SIZE; - $chunkZ = $pos->getFloorZ() >> Chunk::COORD_BIT_SIZE; + $chunkX = $pos->x >> Chunk::COORD_BIT_SIZE; + $chunkZ = $pos->z >> Chunk::COORD_BIT_SIZE; if(isset($this->chunks[$hash = World::chunkHash($chunkX, $chunkZ)])){ $this->chunks[$hash]->removeTile($tile); @@ -2925,9 +2921,9 @@ class World implements ChunkManager{ } $tilePosition = $tile->getPosition(); - if(!$this->isChunkLoaded($tilePosition->getFloorX() >> Chunk::COORD_BIT_SIZE, $tilePosition->getFloorZ() >> Chunk::COORD_BIT_SIZE)){ + if(!$this->isChunkLoaded($tilePosition->x >> Chunk::COORD_BIT_SIZE, $tilePosition->z >> Chunk::COORD_BIT_SIZE)){ $logger->error("Found tile saved on wrong chunk - unable to fix due to correct chunk not loaded"); - }elseif(!$this->isInWorld($tilePosition->getFloorX(), $tilePosition->getFloorY(), $tilePosition->getFloorZ())){ + }elseif(!$this->isInWorld($tilePosition->x, $tilePosition->y, $tilePosition->z)){ $logger->error("Cannot add tile with position outside the world bounds: x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z"); }elseif($this->getTile($tilePosition) !== null){ $logger->error("Cannot add tile at x=$tilePosition->x,y=$tilePosition->y,z=$tilePosition->z: Another tile is already at that position"); diff --git a/src/world/generator/object/AcaciaTree.php b/src/world/generator/object/AcaciaTree.php index 75e58a9b3..9018c8b93 100644 --- a/src/world/generator/object/AcaciaTree.php +++ b/src/world/generator/object/AcaciaTree.php @@ -94,7 +94,7 @@ final class AcaciaTree extends Tree{ $nextBlockPos = $nextBlockPos->getSide($branchFacing); $diagonalPlaced++; } - $transaction->addBlock($nextBlockPos, $this->trunkBlock); + $transaction->addBlockAt($nextBlockPos->getFloorX(), $nextBlockPos->getFloorY(), $nextBlockPos->getFloorZ(), $this->trunkBlock); } return $nextBlockPos; diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index f15dc9d53..23eaeb27c 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -45,331 +45,6 @@ parameters: count: 1 path: ../../../src/VersionInfo.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 3 - path: ../../../src/block/Block.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 3 - path: ../../../src/block/Block.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\format\\\\Chunk\\:\\:setBlockStateId\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Block.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 3 - path: ../../../src/block/Block.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Cactus.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Cactus.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Cactus.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Cactus.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Cactus.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Cactus.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/block/ChorusFlower.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/block/ChorusFlower.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/block/ChorusFlower.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getRealBlockSkyLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/DaylightSensor.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getRealBlockSkyLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/DaylightSensor.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getRealBlockSkyLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/DaylightSensor.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/DragonEgg.php - - - - message: "#^Parameter \\#1 \\$xDiff of class pocketmine\\\\world\\\\particle\\\\DragonEggTeleportParticle constructor expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/DragonEgg.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int\\<\\-64, 319\\> given\\.$#" - count: 1 - path: ../../../src/block/DragonEgg.php - - - - message: "#^Parameter \\#2 \\$yDiff of class pocketmine\\\\world\\\\particle\\\\DragonEggTeleportParticle constructor expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/DragonEgg.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/DragonEgg.php - - - - message: "#^Parameter \\#3 \\$zDiff of class pocketmine\\\\world\\\\particle\\\\DragonEggTeleportParticle constructor expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/DragonEgg.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Fire.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Fire.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Fire.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Fire.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Fire.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Fire.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/FrostedIce.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/FrostedIce.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/FrostedIce.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/FrostedIce.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/FrostedIce.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/FrostedIce.php - - - - message: "#^Parameter \\#1 \\$min of function mt_rand expects int, float\\|int given\\.$#" - count: 3 - path: ../../../src/block/Grass.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Grass.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Grass.php - - - - message: "#^Parameter \\#2 \\$max of function mt_rand expects int, float\\|int given\\.$#" - count: 3 - path: ../../../src/block/Grass.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Grass.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Grass.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Grass.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Grass.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Ice.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Ice.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getHighestAdjacentBlockLight\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Ice.php - - - - message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Leaves.php - - - - message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Leaves.php - - - - message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Leaves.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Liquid.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Liquid.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Liquid.php - - - - message: "#^Parameter \\#1 \\$min of function mt_rand expects int, float\\|int given\\.$#" - count: 3 - path: ../../../src/block/Mycelium.php - - - - message: "#^Parameter \\#2 \\$max of function mt_rand expects int, float\\|int given\\.$#" - count: 3 - path: ../../../src/block/Mycelium.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/RedMushroom.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/RedMushroom.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/RedMushroom.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/SnowLayer.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/SnowLayer.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/SnowLayer.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Sugarcane.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Sugarcane.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Sugarcane.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Sugarcane.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Sugarcane.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/Sugarcane.php - - message: "#^Parameter \\#1 \\$x of class pocketmine\\\\math\\\\Vector3 constructor expects float\\|int, int\\|null given\\.$#" count: 1 @@ -385,11 +60,6 @@ parameters: count: 4 path: ../../../src/block/tile/Chest.php - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/tile/Chest.php - - message: "#^Parameter \\#3 \\$z of class pocketmine\\\\math\\\\Vector3 constructor expects float\\|int, int\\|null given\\.$#" count: 1 @@ -400,16 +70,6 @@ parameters: count: 1 path: ../../../src/block/tile/Chest.php - - - message: "#^Property pocketmine\\\\block\\\\tile\\\\Chest\\:\\:\\$pairX \\(int\\|null\\) does not accept float\\|int\\.$#" - count: 2 - path: ../../../src/block/tile/Chest.php - - - - message: "#^Property pocketmine\\\\block\\\\tile\\\\Chest\\:\\:\\$pairZ \\(int\\|null\\) does not accept float\\|int\\.$#" - count: 2 - path: ../../../src/block/tile/Chest.php - - message: "#^Constant pocketmine\\\\block\\\\tile\\\\MobHead\\:\\:TAG_MOUTH_MOVING is unused\\.$#" count: 1 @@ -420,26 +80,6 @@ parameters: count: 1 path: ../../../src/block/tile/MobHead.php - - - message: "#^Parameter \\#2 \\$value of method pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\:\\:setInt\\(\\) expects int, float\\|int given\\.$#" - count: 3 - path: ../../../src/block/tile/Spawnable.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getPotentialLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/utils/CropGrowthHelper.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getPotentialLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/utils/CropGrowthHelper.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getPotentialLightAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/block/utils/CropGrowthHelper.php - - message: "#^Cannot call method addParticle\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" count: 1 @@ -460,26 +100,6 @@ parameters: count: 1 path: ../../../src/command/defaults/TimeCommand.php - - - message: "#^Parameter \\#1 \\$stream of function fclose expects resource, resource\\|false given\\.$#" - count: 2 - path: ../../../src/command/defaults/TimingsCommand.php - - - - message: "#^Parameter \\#1 \\$stream of function fseek expects resource, resource\\|false given\\.$#" - count: 1 - path: ../../../src/command/defaults/TimingsCommand.php - - - - message: "#^Parameter \\#1 \\$stream of function fwrite expects resource, resource\\|false given\\.$#" - count: 1 - path: ../../../src/command/defaults/TimingsCommand.php - - - - message: "#^Parameter \\#1 \\$stream of function stream_get_contents expects resource, resource\\|false given\\.$#" - count: 1 - path: ../../../src/command/defaults/TimingsCommand.php - - message: "#^Parameter \\#1 \\$path of static method pocketmine\\\\utils\\\\Filesystem\\:\\:cleanPath\\(\\) expects string, mixed given\\.$#" count: 1 @@ -500,51 +120,6 @@ parameters: count: 1 path: ../../../src/entity/Living.php - - - message: "#^Parameter \\#2 \\$x of method pocketmine\\\\block\\\\Block\\:\\:position\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/object/FallingBlock.php - - - - message: "#^Parameter \\#3 \\$y of method pocketmine\\\\block\\\\Block\\:\\:position\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/object/FallingBlock.php - - - - message: "#^Parameter \\#4 \\$z of method pocketmine\\\\block\\\\Block\\:\\:position\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/object/FallingBlock.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/object/Painting.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/object/Painting.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/object/Painting.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/projectile/Projectile.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/projectile/Projectile.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/entity/projectile/Projectile.php - - message: "#^Parameter \\#2 \\$recipe of class pocketmine\\\\event\\\\inventory\\\\CraftItemEvent constructor expects pocketmine\\\\crafting\\\\CraftingRecipe, pocketmine\\\\crafting\\\\CraftingRecipe\\|null given\\.$#" count: 1 @@ -850,63 +425,18 @@ parameters: count: 1 path: ../../../src/utils/Utils.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:setBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - - - message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:setBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - - - message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:setBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - - - message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/Explosion.php - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" count: 1 path: ../../../src/world/World.php - - message: "#^Cannot access offset 'data' on array\\{priority\\: int, data\\: pocketmine\\\\math\\\\Vector3\\}\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#" + message: "#^Cannot access offset 'data' on array\\{priority\\: int, data\\: pocketmine\\\\block\\\\BlockPosition\\}\\|int\\|pocketmine\\\\block\\\\BlockPosition\\.$#" count: 1 path: ../../../src/world/World.php - - message: "#^Cannot access offset 'priority' on array\\{priority\\: int, data\\: pocketmine\\\\math\\\\Vector3\\}\\|int\\|pocketmine\\\\math\\\\Vector3\\.$#" + message: "#^Cannot access offset 'priority' on array\\{priority\\: int, data\\: pocketmine\\\\block\\\\BlockPosition\\}\\|int\\|pocketmine\\\\block\\\\BlockPosition\\.$#" count: 1 path: ../../../src/world/World.php @@ -915,81 +445,6 @@ parameters: count: 1 path: ../../../src/world/World.php - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#2 \\$x of method pocketmine\\\\block\\\\Block\\:\\:position\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#3 \\$y of method pocketmine\\\\block\\\\Block\\:\\:position\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getTileAt\\(\\) expects int, float\\|int given\\.$#" - count: 1 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:isInWorld\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\world\\\\World\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - - - message: "#^Parameter \\#4 \\$z of method pocketmine\\\\block\\\\Block\\:\\:position\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/World.php - - message: "#^Method pocketmine\\\\world\\\\biome\\\\BiomeRegistry\\:\\:getBiome\\(\\) should return pocketmine\\\\world\\\\biome\\\\Biome but returns pocketmine\\\\world\\\\biome\\\\Biome\\|null\\.$#" count: 1 @@ -1000,21 +455,6 @@ parameters: count: 1 path: ../../../src/world/format/Chunk.php - - - message: "#^Parameter \\#1 \\$x of static method pocketmine\\\\world\\\\format\\\\Chunk\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/format/Chunk.php - - - - message: "#^Parameter \\#2 \\$y of static method pocketmine\\\\world\\\\format\\\\Chunk\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/format/Chunk.php - - - - message: "#^Parameter \\#3 \\$z of static method pocketmine\\\\world\\\\format\\\\Chunk\\:\\:blockHash\\(\\) expects int, float\\|int given\\.$#" - count: 2 - path: ../../../src/world/format/Chunk.php - - message: "#^Method pocketmine\\\\world\\\\format\\\\HeightArray\\:\\:get\\(\\) should return int but returns int\\|null\\.$#" count: 1