当前位置: 首页>>代码示例>>PHP>>正文


PHP Level::getBlockIdAt方法代码示例

本文整理汇总了PHP中pocketmine\level\Level::getBlockIdAt方法的典型用法代码示例。如果您正苦于以下问题:PHP Level::getBlockIdAt方法的具体用法?PHP Level::getBlockIdAt怎么用?PHP Level::getBlockIdAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\level\Level的用法示例。


在下文中一共展示了Level::getBlockIdAt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sideCheck

 public function sideCheck($x, $y, $z, Level $level, $name)
 {
     if ($level->getBlockIdAt($x, $y, $z) == Block::CHEST) {
         if (isset($this->configData["{$x}:{$y}:{$z}"])) {
             if ($this->configData["{$x}:{$y}:{$z}"] != $name) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:11,代码来源:ChestGuard.php

示例2: countNotEmptyBlocks

 /**
  *
  * @param Level $level        	
  * @param Position $pos1        	
  * @param Position $pos2        	
  * @param string $output        	
  * @return number
  */
 public function countNotEmptyBlocks(Level $level, Position $pos1, Position $pos2, &$output = null)
 {
     $count = 0;
     $startX = min($pos1->x, $pos2->x);
     $endX = max($pos1->x, $pos2->x);
     $startY = min($pos1->y + 6, $pos2->y);
     $endY = max($pos1->y, $pos2->y);
     $startZ = min($pos1->z, $pos2->z);
     $endZ = max($pos1->z, $pos2->z);
     for ($x = $startX; $x <= $endX; ++$x) {
         for ($y = $startY; $y <= $endY; ++$y) {
             for ($z = $startZ; $z <= $endZ; ++$z) {
                 $blockid = $level->getBlockIdAt($x, $y, $z);
                 if ($blockid != 0) {
                     $count++;
                 }
             }
         }
     }
     $output .= "{$count} block(s) have been updated.\n";
     return $count;
 }
开发者ID:robozeri,项目名称:SG,代码行数:30,代码来源:GameLevelModel.php

示例3: setWaterField

 public function setWaterField(Player $player, $x, $y, $z, Level $level)
 {
     if (isset($this->waterField[$player->getName()]["pos"]) and $this->waterField[$player->getName()]["pos"] == "{$x}:{$y}:{$z}") {
         return;
     }
     $downId = $level->getBlockIdAt($x, $y, $z);
     $pk = new UpdateBlockPacket();
     if (isset($this->waterField[$player->getName()]["pos"])) {
         $pos = explode(":", $this->waterField[$player->getName()]["pos"]);
         $sides = [[1, 1], [1, 0], [1, 1], [0, -1], [0, 0], [0, 1], [-1, -1], [-1, 0], [-1, 0]];
         foreach ($sides as $side) {
             $downId = $level->getBlockIdAt($pos[0] + $side[0], $pos[2], $pos[1] + $side[1]);
             $downDmg = $level->getBlockDataAt($pos[0] + $side[0], $pos[2], $pos[1] + $side[1]);
             $pk->records[] = [$pos[0] + $side[0], $pos[1] + $side[1], $pos[2], $downId, $downDmg, UpdateBlockPacket::FLAG_NONE];
         }
     }
     if ($downId != Block::STILL_WATER) {
         $pos = explode(":", $this->waterField[$player->getName()]["pos"]);
         $sides = [[1, 1], [1, 0], [1, 1], [0, -1], [0, 0], [0, 1], [-1, -1], [-1, 0], [-1, 0]];
         foreach ($sides as $side) {
             $downId = $level->getBlockIdAt($pos[0] + $side[0], $pos[2], $pos[1] + $side[1]);
             $downDmg = $level->getBlockDataAt($pos[0] + $side[0], $pos[2], $pos[1] + $side[1]);
             $pk->records[] = [$pos[0] + $side[0], $pos[1] + $side[1], $pos[2], $downId, $downDmg, UpdateBlockPacket::FLAG_NONE];
         }
     }
     $player->directDataPacket($pk->setChannel(Network::CHANNEL_BLOCKS));
     $this->waterField[$player->getName()]["pos"] = "{$x}:{$z}:{$y}";
 }
开发者ID:JiangsNetworkAlpha,项目名称:FlyingBoats,代码行数:28,代码来源:EventListener.php

示例4: canActivate

 public function canActivate(Level $level, Position $pos)
 {
     // +-x y +-z
     $minLength = 4;
     $minHeight = 5;
     $loopLimit = 27;
     $x = $pos->x;
     $y = $pos->y;
     $z = $pos->z;
     // INITIAL
     $nowLoop = 0;
     $firstPos = null;
     $secondPos = null;
     $height = 0;
     $initailSuccess = false;
     // DOWN LENGTH CHECK
     for (;;) {
         $x--;
         if ($nowLoop >= $loopLimit) {
             break;
         }
         if ($level->getBlockIdAt($x, $y, $z) != Block::OBSIDIAN) {
             break;
         }
         if ($level->getBlockIdAt($x, $y + 1, $z) != Block::AIR) {
             break;
         }
         if ($level->getBlockIdAt($x - 1, $y + 1, $z) == Block::OBSIDIAN) {
             $initailSuccess = true;
         }
         $nowLoop++;
     }
     if (!$initailSuccess) {
         $nowLoop = 0;
         $x = $pos->x;
         $y = $pos->y;
         $z = $pos->z;
         for (;;) {
             $z--;
             if ($nowLoop >= $loopLimit) {
                 break;
             }
             if ($level->getBlockIdAt($x, $y, $z) != Block::OBSIDIAN) {
                 break;
             }
             if ($level->getBlockIdAt($x, $y + 1, $z) != Block::AIR) {
                 break;
             }
             if ($level->getBlockIdAt($x, $y + 1, $z - 1) == Block::OBSIDIAN) {
                 $initailSuccess = true;
             }
             $nowLoop++;
         }
         if (!$initailSuccess) {
             return false;
         }
         $firstPos = new Vector3($x, $y, $z);
         $z += $nowLoop;
         for (;;) {
             $z++;
             if ($nowLoop >= $loopLimit) {
                 break;
             }
             if ($level->getBlockIdAt($x, $y, $z) != Block::OBSIDIAN) {
                 break;
             }
             if ($level->getBlockIdAt($x, $y + 1, $z) != Block::AIR) {
                 break;
             }
             if ($level->getBlockIdAt($x, $y + 1, $z + 1) == Block::OBSIDIAN) {
                 $initailSuccess = true;
             }
             $nowLoop++;
         }
         if (!$initailSuccess) {
             return false;
         }
         $secondPos = new Vector3($x, $y, $z);
     } else {
         if ($secondPos == null) {
             $firstPos = new Vector3($x, $y, $z);
             $x += $nowLoop;
             for (;;) {
                 $x++;
                 if ($nowLoop >= $loopLimit) {
                     break;
                 }
                 if ($level->getBlockIdAt($x, $y, $z) != Block::OBSIDIAN) {
                     break;
                 }
                 if ($level->getBlockIdAt($x, $y + 1, $z) != Block::AIR) {
                     break;
                 }
                 if ($level->getBlockIdAt($x + 1, $y + 1, $z) == Block::OBSIDIAN) {
                     $initailSuccess = true;
                 }
                 $nowLoop++;
             }
             if (!$initailSuccess) {
                 return false;
//.........这里部分代码省略.........
开发者ID:JiangsNetworkAlpha,项目名称:JiangsNeather,代码行数:101,代码来源:NetherWorld.php

示例5: whatBlock

 public function whatBlock(Level $level, $v3)
 {
     //boybook的y轴判断法 核心 什么方块?
     $id = $level->getBlockIdAt($v3->x, $v3->y, $v3->z);
     $damage = $level->getBlockDataAt($v3->x, $v3->y, $v3->z);
     switch ($id) {
         case 0:
         case 6:
         case 27:
         case 30:
         case 31:
         case 37:
         case 38:
         case 39:
         case 40:
         case 50:
         case 51:
         case 63:
         case 66:
         case 68:
         case 78:
         case 111:
         case 141:
         case 142:
         case 171:
         case 175:
         case 244:
         case 323:
             //透明方块
             return "air";
             break;
         case 8:
         case 9:
             //水
             return "water";
             break;
         case 10:
         case 11:
             //岩浆
             return "lava";
             break;
         case 44:
         case 158:
             //半砖
             if ($damage >= 8) {
                 return "block";
             } else {
                 return "half";
             }
             break;
         case 64:
             //门
             //var_dump($damage." ");
             //TODO 不知如何判断门是否开启,因为以下条件永远满足
             if (($damage & 0x8) === 0x8) {
                 return "air";
             } else {
                 return "block";
             }
             break;
         case 85:
         case 107:
         case 139:
             //1.5格高的无法跳跃物
             return "high";
             break;
         case 65:
         case 106:
             //可攀爬物
             return "climb";
             break;
         default:
             //普通方块
             return "block";
             break;
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:77,代码来源:Creature.php

示例6: updateHorizontalGrowingCrops

 /**
  * @param $key
  * @param Level $level
  * @param Vector3 $position
  * @return bool
  */
 public function updateHorizontalGrowingCrops($key, Level $level, Vector3 $position)
 {
     $cropBlock = null;
     switch ($this->farmData[$key]["id"]) {
         case Block::PUMPKIN_STEM:
             $cropBlock = Block::get(Block::PUMPKIN);
             break;
         case Block::MELON_STEM:
             $cropBlock = Block::get(Block::MELON_BLOCK);
             break;
         default:
             return true;
     }
     if (++$this->farmData[$key]["damage"] >= 8) {
         // FULL GROWN!
         for ($xOffset = -1; $xOffset <= 1; $xOffset++) {
             for ($zOffset = -1; $zOffset <= 1; $zOffset++) {
                 if ($xOffset === 0 and $zOffset === 0) {
                     //STEM
                     continue;
                 }
                 $cropPosition = $position->setComponents($position->x + $xOffset, $position->y, $position->z + $zOffset);
                 if ($level->getBlockIdAt($cropPosition->x, $cropPosition->y, $cropPosition->z) !== Item::AIR) {
                     //SOMETHING EXISTS
                     $level->setBlock($cropPosition, $cropBlock);
                     return true;
                 }
             }
         }
         return true;
     }
     $level->setBlock($position, Block::get($this->farmData[$key]["id"], $this->farmData[$key]["damage"]));
     return false;
 }
开发者ID:pilock,项目名称:Farms,代码行数:40,代码来源:Farms.php

示例7: lavaSpawn

 public function lavaSpawn(Level $level, $x, $y, $z)
 {
     $level->getServer()->getLogger()->info("生成岩浆中 " . "floor({$x})" . ", " . "floor({$y})" . ", " . floor($z));
     for ($xx = $x - 20; $xx <= $x + 20; $xx++) {
         for ($zz = $z - 20; $zz <= $z + 20; $zz++) {
             for ($yy = $y; $yy > $y - 4; $yy--) {
                 $id = $level->getBlockIdAt($xx, $yy, $zz);
                 if ($id == 0) {
                     $level->setBlockIdAt($xx, $yy, $zz, 10);
                     $level->setBlockDataAt($xx, $yy, $zz, 0);
                 }
             }
         }
     }
     $level->setBlock(new Vector3($x, $y, $z), new Lava());
 }
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:16,代码来源:CaveCommand.php


注:本文中的pocketmine\level\Level::getBlockIdAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。