mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-05 17:41:46 +00:00
Block: use isSameType() in some places
This commit is contained in:
parent
72c0af2e82
commit
e95b9fa432
@ -72,7 +72,7 @@ class Cactus extends Transparent{
|
|||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
$down = $this->getSide(Facing::DOWN);
|
$down = $this->getSide(Facing::DOWN);
|
||||||
if($down->getId() !== BlockLegacyIds::SAND and $down->getId() !== BlockLegacyIds::CACTUS){
|
if($down->getId() !== BlockLegacyIds::SAND and !$down->isSameType($this)){
|
||||||
$this->getWorld()->useBreakOn($this);
|
$this->getWorld()->useBreakOn($this);
|
||||||
}else{
|
}else{
|
||||||
foreach(Facing::HORIZONTAL as $side){
|
foreach(Facing::HORIZONTAL as $side){
|
||||||
@ -90,7 +90,7 @@ class Cactus extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onRandomTick() : void{
|
public function onRandomTick() : void{
|
||||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::CACTUS){
|
if(!$this->getSide(Facing::DOWN)->isSameType($this)){
|
||||||
if($this->age === 15){
|
if($this->age === 15){
|
||||||
for($y = 1; $y < 3; ++$y){
|
for($y = 1; $y < 3; ++$y){
|
||||||
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||||
@ -116,7 +116,7 @@ class Cactus extends Transparent{
|
|||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
$down = $this->getSide(Facing::DOWN);
|
$down = $this->getSide(Facing::DOWN);
|
||||||
if($down->getId() === BlockLegacyIds::SAND or $down->getId() === BlockLegacyIds::CACTUS){
|
if($down->getId() === BlockLegacyIds::SAND or $down->isSameType($this)){
|
||||||
foreach(Facing::HORIZONTAL as $side){
|
foreach(Facing::HORIZONTAL as $side){
|
||||||
if($this->getSide($side)->isSolid()){
|
if($this->getSide($side)->isSolid()){
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,7 +55,7 @@ class Sugarcane extends Flowable{
|
|||||||
|
|
||||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
if($item instanceof Fertilizer){
|
if($item instanceof Fertilizer){
|
||||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::SUGARCANE_BLOCK){
|
if(!$this->getSide(Facing::DOWN)->isSameType($this)){
|
||||||
for($y = 1; $y < 3; ++$y){
|
for($y = 1; $y < 3; ++$y){
|
||||||
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||||
if($b->getId() === BlockLegacyIds::AIR){
|
if($b->getId() === BlockLegacyIds::AIR){
|
||||||
@ -83,7 +83,7 @@ class Sugarcane extends Flowable{
|
|||||||
|
|
||||||
public function onNearbyBlockChange() : void{
|
public function onNearbyBlockChange() : void{
|
||||||
$down = $this->getSide(Facing::DOWN);
|
$down = $this->getSide(Facing::DOWN);
|
||||||
if($down->isTransparent() and $down->getId() !== BlockLegacyIds::SUGARCANE_BLOCK){
|
if($down->isTransparent() and !$down->isSameType($this)){
|
||||||
$this->getWorld()->useBreakOn($this);
|
$this->getWorld()->useBreakOn($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ class Sugarcane extends Flowable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onRandomTick() : void{
|
public function onRandomTick() : void{
|
||||||
if($this->getSide(Facing::DOWN)->getId() !== BlockLegacyIds::SUGARCANE_BLOCK){
|
if(!$this->getSide(Facing::DOWN)->isSameType($this)){
|
||||||
if($this->age === 15){
|
if($this->age === 15){
|
||||||
for($y = 1; $y < 3; ++$y){
|
for($y = 1; $y < 3; ++$y){
|
||||||
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
$b = $this->getWorld()->getBlockAt($this->x, $this->y + $y, $this->z);
|
||||||
@ -113,7 +113,7 @@ class Sugarcane extends Flowable{
|
|||||||
|
|
||||||
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||||
$down = $this->getSide(Facing::DOWN);
|
$down = $this->getSide(Facing::DOWN);
|
||||||
if($down->getId() === BlockLegacyIds::SUGARCANE_BLOCK){
|
if($down->isSameType($this)){
|
||||||
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}elseif($down->getId() === BlockLegacyIds::GRASS or $down->getId() === BlockLegacyIds::DIRT or $down->getId() === BlockLegacyIds::SAND){
|
}elseif($down->getId() === BlockLegacyIds::GRASS or $down->getId() === BlockLegacyIds::DIRT or $down->getId() === BlockLegacyIds::SAND){
|
||||||
foreach(Facing::HORIZONTAL as $side){
|
foreach(Facing::HORIZONTAL as $side){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user