本文整理汇总了PHP中pocketmine\level\Level::getBlockDataAt方法的典型用法代码示例。如果您正苦于以下问题:PHP Level::getBlockDataAt方法的具体用法?PHP Level::getBlockDataAt怎么用?PHP Level::getBlockDataAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\level\Level
的用法示例。
在下文中一共展示了Level::getBlockDataAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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}";
}
示例2: 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;
}
}