mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Remove hardcoded facing literals in for loops
This commit is contained in:
parent
65684eec99
commit
f488e594f6
13
composer.lock
generated
13
composer.lock
generated
@ -187,12 +187,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/Math.git",
|
||||
"reference": "ec66eaa959b86ec3d3d22084a534ae466910aabe"
|
||||
"reference": "6511fb0dcfeb60705d4169cc0422258b325af5c6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/ec66eaa959b86ec3d3d22084a534ae466910aabe",
|
||||
"reference": "ec66eaa959b86ec3d3d22084a534ae466910aabe",
|
||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/6511fb0dcfeb60705d4169cc0422258b325af5c6",
|
||||
"reference": "6511fb0dcfeb60705d4169cc0422258b325af5c6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -205,6 +205,11 @@
|
||||
"pocketmine\\math\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"pocketmine\\math\\": "tests/phpunit/"
|
||||
}
|
||||
},
|
||||
"license": [
|
||||
"LGPL-3.0"
|
||||
],
|
||||
@ -213,7 +218,7 @@
|
||||
"source": "https://github.com/pmmp/Math/tree/master",
|
||||
"issues": "https://github.com/pmmp/Math/issues"
|
||||
},
|
||||
"time": "2018-09-05T18:50:26+00:00"
|
||||
"time": "2018-09-13T18:32:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/nbt",
|
||||
|
@ -69,7 +69,7 @@ class Cactus extends Transparent{
|
||||
if($down->getId() !== self::SAND and $down->getId() !== self::CACTUS){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
}else{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
$b = $this->getSide($side);
|
||||
if($b->isSolid()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
@ -107,13 +107,13 @@ class Cactus extends Transparent{
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||
$down = $this->getSide(Facing::DOWN);
|
||||
if($down->getId() === self::SAND or $down->getId() === self::CACTUS){
|
||||
$block0 = $this->getSide(Facing::NORTH);
|
||||
$block1 = $this->getSide(Facing::SOUTH);
|
||||
$block2 = $this->getSide(Facing::WEST);
|
||||
$block3 = $this->getSide(Facing::EAST);
|
||||
if(!$block0->isSolid() and !$block1->isSolid() and !$block2->isSolid() and !$block3->isSolid()){
|
||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
if($this->getSide($side)->isSolid()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\block\utils\ColorBlockMetaHelper;
|
||||
use pocketmine\math\Facing;
|
||||
|
||||
class ConcretePowder extends Fallable{
|
||||
|
||||
@ -64,7 +65,10 @@ class ConcretePowder extends Fallable{
|
||||
* @return null|Block
|
||||
*/
|
||||
private function checkAdjacentWater() : ?Block{
|
||||
for($i = 1; $i < 6; ++$i){ //Do not check underneath
|
||||
foreach(Facing::ALL as $i){
|
||||
if($i === Facing::DOWN){
|
||||
continue;
|
||||
}
|
||||
if($this->getSide($i) instanceof Water){
|
||||
return BlockFactory::get(Block::CONCRETE, $this->meta);
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ class Fire extends Flowable{
|
||||
}
|
||||
|
||||
private function hasAdjacentFlammableBlocks() : bool{
|
||||
for($i = 0; $i <= 5; ++$i){
|
||||
if($this->getSide($i)->isFlammable()){
|
||||
foreach(Facing::ALL as $face){
|
||||
if($this->getSide($face)->isFlammable()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\entity\Entity;
|
||||
use pocketmine\event\entity\EntityCombustByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageByBlockEvent;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\Server;
|
||||
|
||||
@ -72,7 +73,10 @@ class Lava extends Liquid{
|
||||
|
||||
protected function checkForHarden(){
|
||||
$colliding = null;
|
||||
for($side = 1; $side <= 5; ++$side){ //don't check downwards side
|
||||
foreach(Facing::ALL as $side){
|
||||
if($side === Facing::DOWN){
|
||||
continue;
|
||||
}
|
||||
$blockSide = $this->getSide($side);
|
||||
if($blockSide instanceof Water){
|
||||
$colliding = $blockSide;
|
||||
|
@ -51,13 +51,13 @@ class MelonStem extends Crops{
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true);
|
||||
}
|
||||
}else{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
$b = $this->getSide($side);
|
||||
if($b->getId() === self::MELON_BLOCK){
|
||||
return;
|
||||
}
|
||||
}
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$side = $this->getSide(Facing::HORIZONTAL[array_rand(Facing::HORIZONTAL)]);
|
||||
$d = $side->getSide(Facing::DOWN);
|
||||
if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, BlockFactory::get(Block::MELON_BLOCK)));
|
||||
|
@ -51,13 +51,13 @@ class PumpkinStem extends Crops{
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true);
|
||||
}
|
||||
}else{
|
||||
for($side = 2; $side <= 5; ++$side){
|
||||
foreach(Facing::HORIZONTAL as $side){
|
||||
$b = $this->getSide($side);
|
||||
if($b->getId() === self::PUMPKIN){
|
||||
return;
|
||||
}
|
||||
}
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$side = $this->getSide(Facing::HORIZONTAL[array_rand(Facing::HORIZONTAL)]);
|
||||
$d = $side->getSide(Facing::DOWN);
|
||||
if($side->getId() === self::AIR and ($d->getId() === self::FARMLAND or $d->getId() === self::GRASS or $d->getId() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, BlockFactory::get(Block::PUMPKIN)));
|
||||
|
@ -37,6 +37,7 @@ use pocketmine\item\ItemFactory;
|
||||
use pocketmine\level\particle\HugeExplodeSeedParticle;
|
||||
use pocketmine\level\utils\SubChunkIteratorManager;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\ExplodePacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
@ -228,7 +229,7 @@ class Explosion{
|
||||
|
||||
$pos = new Vector3($block->x, $block->y, $block->z);
|
||||
|
||||
for($side = 0; $side <= 5; $side++){
|
||||
foreach(Facing::ALL as $side){
|
||||
$sideBlock = $pos->getSide($side);
|
||||
if(!$this->level->isInWorld($sideBlock->x, $sideBlock->y, $sideBlock->z)){
|
||||
continue;
|
||||
|
@ -61,6 +61,7 @@ use pocketmine\level\particle\DestroyBlockParticle;
|
||||
use pocketmine\level\particle\Particle;
|
||||
use pocketmine\level\sound\Sound;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector2;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\metadata\BlockMetadataStore;
|
||||
@ -1087,8 +1088,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
public function scheduleNeighbourBlockUpdates(Vector3 $pos){
|
||||
$pos = $pos->floor();
|
||||
|
||||
for($i = 0; $i <= 5; ++$i){
|
||||
$side = $pos->getSide($i);
|
||||
foreach(Facing::ALL as $face){
|
||||
$side = $pos->getSide($face);
|
||||
if($this->isInWorld($side->x, $side->y, $side->z)){
|
||||
$this->neighbourBlockUpdateQueue->enqueue(Level::blockHash($side->x, $side->y, $side->z));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user