本文整理汇总了PHP中pocketmine\block\Block::getY方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::getY方法的具体用法?PHP Block::getY怎么用?PHP Block::getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\block\Block
的用法示例。
在下文中一共展示了Block::getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$entity = null;
$chunk = $level->getChunk($block->getX() >> 4, $block->getZ() >> 4);
if (!$chunk instanceof FullChunk) {
return false;
}
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $block->getX() + 0.5), new Double("", $block->getY()), new Double("", $block->getZ() + 0.5)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", lcg_value() * 360), new Float("", 0)])]);
$entity = Entity::createEntity($this->meta, $chunk, $nbt);
if ($entity instanceof Entity) {
if ($player->isSurvival()) {
--$this->count;
}
$entity->spawnToAll();
return true;
}
return false;
}
示例2: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($target->getId() == Block::MONSTER_SPAWNER) {
return true;
} else {
$entity = null;
$chunk = $level->getChunk($block->getX() >> 4, $block->getZ() >> 4);
if (!$chunk instanceof FullChunk) {
return false;
}
$nbt = new CompoundTag("", ["Pos" => new EnumTag("Pos", [new DoubleTag("", $block->getX() + 0.5), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ() + 0.5)]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", lcg_value() * 360), new FloatTag("", 0)])]);
if ($this->hasCustomName()) {
$nbt->CustomName = new StringTag("CustomName", $this->getCustomName());
}
$entity = Entity::createEntity($this->meta, $chunk, $nbt);
if ($entity instanceof Entity) {
if ($player->isSurvival()) {
--$this->count;
}
$entity->spawnToAll();
return true;
}
}
return false;
}
示例3: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if (!$target instanceof Fence) {
return false;
}
foreach ($level->getChunkEntities($target->x >> 4, $target->z >> 4) as $entity) {
if ($entity->isLeashed()) {
if ($entity->leadHolder === $player->getId()) {
$nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $block->getX() + 0.5), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ() + 0.5)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", lcg_value() * 360), new FloatTag("", 0)])]);
$level->addEntity($knot = new LeashKnot($level->getChunkAt($target->x >> 4, $target->z >> 4), $nbt));
$entity->setLeashHolder($knot);
}
}
}
}
示例4: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$minecart = new MinecartEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $block->getX()), new DoubleTag("", $block->getY() + 0.8), new DoubleTag("", $block->getZ())]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
$minecart->spawnToAll();
if ($player->isSurvival()) {
$item = $player->getInventory()->getItemInHand();
$count = $item->getCount();
if (--$count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return true;
}
$item->setCount($count);
$player->getInventory()->setItemInHand($item);
}
return true;
}
示例5: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$entity = null;
$chunk = $level->getChunkAt($block->getX() >> 4, $block->getZ() >> 4);
if (!$chunk instanceof FullChunk) {
return false;
}
$nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $block->getX()), new Double("", $block->getY()), new Double("", $block->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", lcg_value() * 360), new Float("", 0)])]);
switch ($this->meta) {
case Villager::NETWORK_ID:
$nbt->Health = new Short("Health", 20);
$entity = new Villager($chunk, $nbt);
break;
case Zombie::NETWORK_ID:
$nbt->Health = new Short("Health", 20);
$entity = new Zombie($chunk, $nbt);
break;
/*
//TODO: use entity constants
case 10:
case 11:
case 12:
case 13:
$data = array(
"x" => $block->x + 0.5,
"y" => $block->y,
"z" => $block->z + 0.5,
);
//$e = Server::getInstance()->api->entity->add($block->level, ENTITY_MOB, $this->meta, $data);
//Server::getInstance()->api->entity->spawnToAll($e);
if(($player->gamemode & 0x01) === 0){
--$this->count;
}
return true;*/
}
if ($entity instanceof Entity) {
if (($player->gamemode & 0x1) === 0) {
--$this->count;
}
$entity->spawnToAll();
return true;
}
return false;
}
示例6: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$blockTemp = $level->getBlock($block->add(0, -1, 0));
//if($blockTemp->getId() != self::RAIL and $blockTemp->getId() != self::POWERED_RAIL) return;
$minecart = new MinecartEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $block->getX()), new Double("", $block->getY() + 1), new Double("", $block->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
$minecart->spawnToAll();
if ($player->isSurvival()) {
$item = $player->getInventory()->getItemInHand();
$count = $item->getCount();
if (--$count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return;
}
$item->setCount($count);
$player->getInventory()->setItemInHand($item);
}
return true;
}
示例7: getDispenserId
public function getDispenserId(Block $block)
{
return $block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName();
}
示例8: updateBlock2
public function updateBlock2(Block $block, Level $level, $blockType)
{
$players = $level->getPlayers();
foreach ($players as $p) {
$pk = new UpdateBlockPacket();
$pk->x = $block->getX();
$pk->y = $block->getY();
$pk->z = $block->getZ();
$pk->block = $blockType;
$pk->meta = 0;
$p->dataPacket($pk);
$level->setBlockIdAt($block->getX(), $block->getY(), $block->getZ(), $blockType);
$pos = new Position($block->x, $block->y, $block->z);
$block = $level->getBlock($pos, true);
$direct = true;
$update = true;
$level->setBlock($pos, $block, $direct, $update);
}
}
示例9: getTreetop
/**
* @param Block $stump
* @return int
*/
public function getTreetop(Block $stump)
{
$level = $stump->getLevel();
$floor = $level->getBlock($stump->getSide(0));
if (!in_array($floor->getId(), self::FLOORS)) {
return -1;
}
$found = null;
$maxHeight = $this->getConfig()->get("maxWorldHeight") - $stump->getY();
for ($height = 0; $height < $maxHeight; $height++) {
$block = $level->getBlock($stump->add(0, $height, 0));
if (in_array($block->getId(), self::WOODS)) {
if ($found === null) {
$found = [$block->getId(), $block->getDamage()];
} elseif ($found[0] !== $block->getId() or $found[1] !== $block->getDamage()) {
return -1;
}
} elseif ($found !== null and in_array($block->getId(), self::LEAVES)) {
return $height;
} else {
return -1;
}
}
return -1;
}
示例10: rotateBlockByOne
private static function rotateBlockByOne(Block $block)
{
return Block::get($block->getID(), $block->getDamage(), new Position($block->getZ(), $block->getY(), -$block->getX(), $block->getLevel()));
}
示例11: getTeamByBed
public function getTeamByBed($arena, Block $block)
{
foreach ($this->getTeams($arena) as $team) {
$config = new Config($this->getDataFolder() . "Arenas/" . $arena . ".yml", Config::YAML);
$x = $config->getNested("Bed." . $team . ".X");
$y = $config->getNested("Bed." . $team . ".Y");
$z = $config->getNested("Bed." . $team . ".Z");
$x2 = $config->getNested("Bed." . $team . ".X2");
$y2 = $config->getNested("Bed." . $team . ".Y2");
$z2 = $config->getNested("Bed." . $team . ".Z2");
$x3 = $block->getX();
$y3 = $block->getY();
$z3 = $block->getZ();
if ($x == $x3 && $y == $y3 && $z == $z3) {
return $team;
}
if ($x2 == $x3 && $y2 == $y3 && $z2 == $z3) {
return $team;
}
}
return "WHITE";
}
示例12: addChest
/**
* Adds a resettable chest
* @param Block $chest
*/
public function addChest(Block $chest)
{
$chests = $this->config->chests;
$chests[count($this->chests)] = ['id' => $chest->getId(), 'x' => $chest->getX(), 'y' => $chest->getY(), 'z' => $chest->getZ(), 'level' => $chest->getLevel()->getId()];
$this->config->set("chests", $chests);
$this->config->save();
array_push($this->chests, $chest);
}
示例13: destroyTrunk
private function destroyTrunk(Block $bl)
{
$damage = 0;
if ($bl->getId() != Block::WOOD) {
return $damage;
}
$down = $bl->getSide(Vector3::SIDE_DOWN);
if ($down->getId() == Block::WOOD) {
return $damage;
}
$l = $bl->getLevel();
for ($y = $bl->getY() + 1; $y < 128; ++$y) {
$x = $bl->getX();
$z = $bl->getZ();
$bl = $l->getBlock(new Vector3($x, $y, $z));
if ($bl->getId() != Block::WOOD) {
break;
}
++$damage;
$l->dropItem($bl, new ItemBlock($bl));
$l->setBlockIdAt($x, $y, $z, 0);
$l->setBlockDataAt($x, $y, $z, 0);
}
return $damage;
}
示例14: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if (($player->gamemode & 0x1) === 0 and $this->useOn($block) and $this->getDamage() >= $this->getMaxDurability()) {
$player->getInventory()->setItemInHand(new Item(Item::AIR, 0, 0));
}
if ($target->getId() === 49 and $player->getServer()->netherEnabled) {
//黑曜石 4*5最小 23*23最大
$level->setBlock($block, new Fire(), true);
$tx = $target->getX();
$ty = $target->getY();
$tz = $target->getZ();
//x方向
$x_max = $tx;
//x最大值
$x_min = $tx;
//x最小值
$count_x = 0;
//x方向方块
for ($x = $tx + 1; $level->getBlock(new Vector3($x, $ty, $tz))->getId() == 49; $x++) {
$x_max++;
}
for ($x = $tx - 1; $level->getBlock(new Vector3($x, $ty, $tz))->getId() == 49; $x--) {
$x_min--;
}
$count_x = $x_max - $x_min + 1;
if ($count_x >= 4 and $count_x <= 23) {
//4 23
$x_max_y = $ty;
//x最大值时的y最大值
$x_min_y = $ty;
//x最小值时的y最大值
for ($y = $ty; $level->getBlock(new Vector3($x_max, $y, $tz))->getId() == 49; $y++) {
$x_max_y++;
}
for ($y = $ty; $level->getBlock(new Vector3($x_min, $y, $tz))->getId() == 49; $y++) {
$x_min_y++;
}
$y_max = min($x_max_y, $x_min_y) - 1;
//y最大值
$count_y = $y_max - $ty + 2;
//方向方块
//Server::getInstance()->broadcastMessage("$y_max $x_max_y $x_min_y $x_max $x_min");
if ($count_y >= 5 and $count_y <= 23) {
//5 23
$count_up = 0;
//上面
for ($ux = $x_min; $level->getBlock(new Vector3($ux, $y_max, $tz))->getId() == 49 and $ux <= $x_max; $ux++) {
$count_up++;
}
//Server::getInstance()->broadcastMessage("$count_up $count_x");
if ($count_up == $count_x) {
for ($px = $x_min + 1; $px < $x_max; $px++) {
for ($py = $ty + 1; $py < $y_max; $py++) {
$level->setBlock(new Vector3($px, $py, $tz), new Block(90, 0));
}
}
}
}
}
//z方向
$z_max = $tz;
//z最大值
$z_min = $tz;
//z最小值
$count_z = 0;
//z方向方块
for ($z = $tz + 1; $level->getBlock(new Vector3($tx, $ty, $z))->getId() == 49; $z++) {
$z_max++;
}
for ($z = $tz - 1; $level->getBlock(new Vector3($tx, $ty, $z))->getId() == 49; $z--) {
$z_min--;
}
$count_z = $z_max - $z_min + 1;
if ($count_z >= 4 and $count_z <= 23) {
//4 23
$z_max_y = $ty;
//z最大值时的y最大值
$z_min_y = $ty;
//z最小值时的y最大值
for ($y = $ty; $level->getBlock(new Vector3($tx, $y, $z_max))->getId() == 49; $y++) {
$z_max_y++;
}
for ($y = $ty; $level->getBlock(new Vector3($tx, $y, $z_min))->getId() == 49; $y++) {
$z_min_y++;
}
$y_max = min($z_max_y, $z_min_y) - 1;
//y最大值
$count_y = $y_max - $ty + 2;
//方向方块
if ($count_y >= 5 and $count_y <= 23) {
//5 23
$count_up = 0;
//上面
for ($uz = $z_min; $level->getBlock(new Vector3($tx, $y_max, $uz))->getId() == 49 and $uz <= $z_max; $uz++) {
$count_up++;
}
//Server::getInstance()->broadcastMessage("$count_up $count_z");
if ($count_up == $count_z) {
for ($pz = $z_min + 1; $pz < $z_max; $pz++) {
for ($py = $ty + 1; $py < $y_max; $py++) {
//.........这里部分代码省略.........
示例15: DestroyBlock
public function DestroyBlock(Block $Block, Player $Destroyer)
{
$X = $Block->GetX();
$Y = $Block->GetY();
$Z = $Block->GetZ();
if ($Team = $this->getTeamByPlayer($Destroyer)) {
if ($X == $Team->Bed[0]->getX() && $Y == $Team->Bed[0]->getY() && $Z == $Team->Bed[0]->getZ() || $X == $Team->Bed[1]->getX() && $Y == $Team->Bed[1]->getY() && $Z == $Team->Bed[1]->getZ()) {
return true;
}
}
foreach ($this->Teams as $name => $Team) {
if ($X == $Team->Bed[0]->getX() && $Y == $Team->Bed[0]->getY() && $Z == $Team->Bed[0]->getZ() || $X == $Team->Bed[1]->getX() && $Y == $Team->Bed[1]->getY() && $Z == $Team->Bed[1]->getZ()) {
$Team->BedStatus = 0;
$this->sendMessageToAll(TextFormat::RED . $this->plugin->getMessage("bedwars.team.destroyed", $name));
$this->updateTeams();
$this->Level->setBlock(new Vector3($Team->Bed[0]->getX(), $Team->Bed[0]->getY(), $Team->Bed[0]->getZ()), Block::get(0), true, true);
$this->Level->setBlock(new Vector3($Team->Bed[1]->getX(), $Team->Bed[1]->getY(), $Team->Bed[1]->getZ()), Block::get(0), true, true);
return false;
}
}
foreach ($this->BlocksPlaced as $Block) {
if ($X == $Block->getX() && $Y == $Block->getY() && $Z == $Block->getZ()) {
return false;
}
}
return true;
}