diff --git a/src/block/Bamboo.php b/src/block/Bamboo.php index a6a08859b..dae857206 100644 --- a/src/block/Bamboo.php +++ b/src/block/Bamboo.php @@ -131,7 +131,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->isSameType($this)){ + while(($next = $world->getBlock($top->position->up())) instanceof Bamboo && $next->hasSameTypeId($this)){ $top = $next; } return $top; @@ -156,7 +156,7 @@ class Bamboo extends Transparent{ public function onNearbyBlockChange() : void{ $world = $this->position->getWorld(); $below = $world->getBlock($this->position->down()); - if(!$this->canBeSupportedBy($below) && !$below->isSameType($this)){ + if(!$this->canBeSupportedBy($below) && !$below->hasSameTypeId($this)){ $world->useBreakOn($this->position); } } @@ -168,7 +168,7 @@ class Bamboo extends Transparent{ } $height = 1; - while($world->getBlock($this->position->subtract(0, $height, 0))->isSameType($this)){ + while($world->getBlock($this->position->subtract(0, $height, 0))->hasSameTypeId($this)){ if(++$height >= $maxHeight){ return false; } diff --git a/src/block/Block.php b/src/block/Block.php index b818cbac9..d5cd821fd 100644 --- a/src/block/Block.php +++ b/src/block/Block.php @@ -144,7 +144,7 @@ class Block{ * Type properties (e.g. colour, skull type, etc.) are not compared. This means that different colours of wool, * concrete, etc. will all be considered as having the same type. */ - public function isSameType(Block $other) : bool{ + public function hasSameTypeId(Block $other) : bool{ return $this->getTypeId() === $other->getTypeId(); } diff --git a/src/block/Cactus.php b/src/block/Cactus.php index 18dd726e7..3563eded7 100644 --- a/src/block/Cactus.php +++ b/src/block/Cactus.php @@ -79,7 +79,7 @@ class Cactus extends Transparent{ } private function canBeSupportedBy(Block $block) : bool{ - return $block->isSameType($this) || $block->hasTypeTag(BlockTypeTags::SAND); + return $block->hasSameTypeId($this) || $block->hasTypeTag(BlockTypeTags::SAND); } public function onNearbyBlockChange() : void{ @@ -102,7 +102,7 @@ class Cactus extends Transparent{ } public function onRandomTick() : void{ - if(!$this->getSide(Facing::DOWN)->isSameType($this)){ + if(!$this->getSide(Facing::DOWN)->hasSameTypeId($this)){ $world = $this->position->getWorld(); if($this->age === self::MAX_AGE){ for($y = 1; $y < 3; ++$y){ diff --git a/src/block/Candle.php b/src/block/Candle.php index 4870277cc..d95815222 100644 --- a/src/block/Candle.php +++ b/src/block/Candle.php @@ -95,7 +95,7 @@ class Candle extends Transparent{ } protected function getCandleIfCompatibleType(Block $block) : ?Candle{ - return $block instanceof Candle && $block->isSameType($this) ? $block : null; + return $block instanceof Candle && $block->hasSameTypeId($this) ? $block : null; } public function canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool{ diff --git a/src/block/Chest.php b/src/block/Chest.php index bb10e91df..45c190505 100644 --- a/src/block/Chest.php +++ b/src/block/Chest.php @@ -57,13 +57,13 @@ class Chest extends Transparent{ foreach([false, true] as $clockwise){ $side = Facing::rotateY($this->facing, $clockwise); $c = $this->getSide($side); - if($c instanceof Chest && $c->isSameType($this) && $c->facing === $this->facing){ + if($c instanceof Chest && $c->hasSameTypeId($this) && $c->facing === $this->facing){ $pair = $world->getTile($c->position); if($pair instanceof TileChest && !$pair->isPaired()){ [$left, $right] = $clockwise ? [$c, $this] : [$this, $c]; $ev = new ChestPairEvent($left, $right); $ev->call(); - if(!$ev->isCancelled() && $world->getBlock($this->position)->isSameType($this) && $world->getBlock($c->position)->isSameType($c)){ + if(!$ev->isCancelled() && $world->getBlock($this->position)->hasSameTypeId($this) && $world->getBlock($c->position)->hasSameTypeId($c)){ $pair->pairWith($tile); $tile->pairWith($pair); break; diff --git a/src/block/ChorusPlant.php b/src/block/ChorusPlant.php index ebc5308ee..f7642bd04 100644 --- a/src/block/ChorusPlant.php +++ b/src/block/ChorusPlant.php @@ -40,7 +40,7 @@ final class ChorusPlant extends Flowable{ $bb = AxisAlignedBB::one(); foreach($this->getAllSides() as $facing => $block){ $id = $block->getTypeId(); - if($id !== BlockTypeIds::END_STONE && $id !== BlockTypeIds::CHORUS_FLOWER && !$block->isSameType($this)){ + if($id !== BlockTypeIds::END_STONE && $id !== BlockTypeIds::CHORUS_FLOWER && !$block->hasSameTypeId($this)){ $bb->trim($facing, 2 / 16); } } @@ -49,7 +49,7 @@ final class ChorusPlant extends Flowable{ } private function canBeSupportedBy(Block $block) : bool{ - return $block->isSameType($this) || $block->getTypeId() === BlockTypeIds::END_STONE; + return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE; } private function canStay(Position $position) : bool{ diff --git a/src/block/Door.php b/src/block/Door.php index 98a8f5309..d3a2abfb6 100644 --- a/src/block/Door.php +++ b/src/block/Door.php @@ -53,7 +53,7 @@ class Door extends Transparent{ //copy door properties from other half $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); - if($other instanceof Door && $other->isSameType($this)){ + if($other instanceof Door && $other->hasSameTypeId($this)){ if($this->top){ $this->facing = $other->facing; $this->open = $other->open; @@ -126,7 +126,7 @@ class Door extends Transparent{ $next = $this->getSide(Facing::rotateY($this->facing, false)); $next2 = $this->getSide(Facing::rotateY($this->facing, true)); - if($next->isSameType($this) || (!$next2->isTransparent() && $next->isTransparent())){ //Door hinge + if($next->hasSameTypeId($this) || (!$next2->isTransparent() && $next->isTransparent())){ //Door hinge $this->hingeRight = true; } @@ -145,7 +145,7 @@ class Door extends Transparent{ $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); $world = $this->position->getWorld(); - if($other instanceof Door && $other->isSameType($this)){ + if($other instanceof Door && $other->hasSameTypeId($this)){ $other->open = $this->open; $world->setBlock($other->position, $other); } @@ -166,7 +166,7 @@ class Door extends Transparent{ public function getAffectedBlocks() : array{ $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); - if($other->isSameType($this)){ + if($other->hasSameTypeId($this)){ return [$this, $other]; } return parent::getAffectedBlocks(); diff --git a/src/block/DoublePlant.php b/src/block/DoublePlant.php index be231c1ea..cb341adad 100644 --- a/src/block/DoublePlant.php +++ b/src/block/DoublePlant.php @@ -65,7 +65,7 @@ class DoublePlant extends Flowable{ return ( $other instanceof DoublePlant && - $other->isSameType($this) && + $other->hasSameTypeId($this) && $other->top !== $this->top ); } diff --git a/src/block/Liquid.php b/src/block/Liquid.php index 476a8f8c7..ba04510a0 100644 --- a/src/block/Liquid.php +++ b/src/block/Liquid.php @@ -144,7 +144,7 @@ abstract class Liquid extends Transparent{ } protected function getEffectiveFlowDecay(Block $block) : int{ - if(!($block instanceof Liquid) || !$block->isSameType($this)){ + if(!($block instanceof Liquid) || !$block->hasSameTypeId($this)){ return -1; } @@ -282,7 +282,7 @@ abstract class Liquid extends Transparent{ $minAdjacentSources = $this->getMinAdjacentSourcesToFormSource(); if($minAdjacentSources !== null && $this->adjacentSources >= $minAdjacentSources){ $bottomBlock = $world->getBlockAt($this->position->x, $this->position->y - 1, $this->position->z); - if($bottomBlock->isSolid() || ($bottomBlock instanceof Liquid && $bottomBlock->isSameType($this) && $bottomBlock->isSource())){ + if($bottomBlock->isSolid() || ($bottomBlock instanceof Liquid && $bottomBlock->hasSameTypeId($this) && $bottomBlock->isSource())){ $newDecay = 0; $falling = false; } @@ -343,7 +343,7 @@ abstract class Liquid extends Transparent{ /** @phpstan-impure */ private function getSmallestFlowDecay(Block $block, int $decay) : int{ - if(!($block instanceof Liquid) || !$block->isSameType($this)){ + if(!($block instanceof Liquid) || !$block->hasSameTypeId($this)){ return $decay; } diff --git a/src/block/NetherVines.php b/src/block/NetherVines.php index d00580624..34ab406c6 100644 --- a/src/block/NetherVines.php +++ b/src/block/NetherVines.php @@ -87,7 +87,7 @@ class NetherVines extends Flowable{ } private function canBeSupportedBy(Block $block) : bool{ - return $block->getSupportType($this->getSupportFace())->hasCenterSupport() || $block->isSameType($this); + return $block->getSupportType($this->getSupportFace())->hasCenterSupport() || $block->hasSameTypeId($this); } public function onNearbyBlockChange() : void{ @@ -101,7 +101,7 @@ class NetherVines extends Flowable{ */ private function seekToTip() : NetherVines{ $top = $this; - while(($next = $top->getSide($this->growthFace)) instanceof NetherVines && $next->isSameType($this)){ + while(($next = $top->getSide($this->growthFace)) instanceof NetherVines && $next->hasSameTypeId($this)){ $top = $next; } return $top; diff --git a/src/block/Slab.php b/src/block/Slab.php index fa5833d7c..265dce695 100644 --- a/src/block/Slab.php +++ b/src/block/Slab.php @@ -69,7 +69,7 @@ class Slab extends Transparent{ return true; } - if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->isSameType($this)){ + if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->hasSameTypeId($this)){ if($blockReplace->slabType->equals(SlabType::TOP())){ //Trying to combine with top slab return $clickVector->y <= 0.5 || (!$isClickedBlock && $face === Facing::UP); }else{ @@ -81,7 +81,7 @@ class Slab extends Transparent{ } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ - if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->isSameType($this) && ( + if($blockReplace instanceof Slab && !$blockReplace->slabType->equals(SlabType::DOUBLE()) && $blockReplace->hasSameTypeId($this) && ( ($blockReplace->slabType->equals(SlabType::TOP()) && ($clickVector->y <= 0.5 || $face === Facing::UP)) || ($blockReplace->slabType->equals(SlabType::BOTTOM()) && ($clickVector->y >= 0.5 || $face === Facing::DOWN)) )){ diff --git a/src/block/Stem.php b/src/block/Stem.php index 3c7d1d2c3..5f06a46cb 100644 --- a/src/block/Stem.php +++ b/src/block/Stem.php @@ -47,7 +47,7 @@ abstract class Stem extends Crops{ }else{ $grow = $this->getPlant(); foreach(Facing::HORIZONTAL as $side){ - if($this->getSide($side)->isSameType($grow)){ + if($this->getSide($side)->hasSameTypeId($grow)){ return; } } diff --git a/src/block/Sugarcane.php b/src/block/Sugarcane.php index cc41c0fb0..136527e78 100644 --- a/src/block/Sugarcane.php +++ b/src/block/Sugarcane.php @@ -45,7 +45,7 @@ class Sugarcane extends Flowable{ private function seekToBottom() : Position{ $world = $this->position->getWorld(); $bottom = $this->position; - while(($next = $world->getBlock($bottom->down()))->isSameType($this)){ + while(($next = $world->getBlock($bottom->down()))->hasSameTypeId($this)){ $bottom = $next->position; } return $bottom; @@ -67,7 +67,7 @@ class Sugarcane extends Flowable{ } $world->setBlock($b->position, $ev->getNewState()); $grew = true; - }elseif(!$b->isSameType($this)){ + }elseif(!$b->hasSameTypeId($this)){ break; } } @@ -108,7 +108,7 @@ class Sugarcane extends Flowable{ public function onNearbyBlockChange() : void{ $down = $this->getSide(Facing::DOWN); - if(!$down->isSameType($this) && !$this->canBeSupportedBy($down)){ + if(!$down->hasSameTypeId($this) && !$this->canBeSupportedBy($down)){ $this->position->getWorld()->useBreakOn($this->position); } } @@ -118,7 +118,7 @@ class Sugarcane extends Flowable{ } public function onRandomTick() : void{ - if(!$this->getSide(Facing::DOWN)->isSameType($this)){ + if(!$this->getSide(Facing::DOWN)->hasSameTypeId($this)){ if($this->age === self::MAX_AGE){ $this->grow($this->position); }else{ @@ -130,7 +130,7 @@ class Sugarcane extends Flowable{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); - if($down->isSameType($this)){ + if($down->hasSameTypeId($this)){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); }elseif($this->canBeSupportedBy($down)){ foreach(Facing::HORIZONTAL as $side){ diff --git a/src/world/World.php b/src/world/World.php index 4cd7c61f6..5c0233d0d 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -1922,7 +1922,7 @@ class World implements ChunkManager{ $itemParser = LegacyStringToItemParser::getInstance(); foreach($item->getCanDestroy() as $v){ $entry = $itemParser->parse($v); - if($entry->getBlock()->isSameType($target)){ + if($entry->getBlock()->hasSameTypeId($target)){ $canBreak = true; break; } @@ -2077,7 +2077,7 @@ class World implements ChunkManager{ $itemParser = LegacyStringToItemParser::getInstance(); foreach($item->getCanPlaceOn() as $v){ $entry = $itemParser->parse($v); - if($entry->getBlock()->isSameType($blockClicked)){ + if($entry->getBlock()->hasSameTypeId($blockClicked)){ $canPlace = true; break; } diff --git a/src/world/generator/object/Ore.php b/src/world/generator/object/Ore.php index e56ddc457..533b73175 100644 --- a/src/world/generator/object/Ore.php +++ b/src/world/generator/object/Ore.php @@ -40,7 +40,7 @@ class Ore{ } public function canPlaceObject(ChunkManager $world, int $x, int $y, int $z) : bool{ - return $world->getBlockAt($x, $y, $z)->isSameType($this->type->replaces); + return $world->getBlockAt($x, $y, $z)->hasSameTypeId($this->type->replaces); } public function placeObject(ChunkManager $world, int $x, int $y, int $z) : void{ @@ -80,7 +80,7 @@ class Ore{ $sizeZ = ($zz + 0.5 - $seedZ) / $size; $sizeZ *= $sizeZ; - if(($sizeX + $sizeY + $sizeZ) < 1 && $world->getBlockAt($xx, $yy, $zz)->isSameType($this->type->replaces)){ + if(($sizeX + $sizeY + $sizeZ) < 1 && $world->getBlockAt($xx, $yy, $zz)->hasSameTypeId($this->type->replaces)){ $world->setBlockAt($xx, $yy, $zz, $this->type->material); } }