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


PHP Block::getZ方法代码示例

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


在下文中一共展示了Block::getZ方法的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;
 }
开发者ID:mattiasaxelsson,项目名称:PocketMine-MP,代码行数:18,代码来源:SpawnEgg.php

示例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;
 }
开发者ID:PepbookPvP,项目名称:Genisys,代码行数:25,代码来源:SpawnEgg.php

示例3: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($target->isTransparent() === false and $face > 1 and $block->isSolid() === false) {
         $faces = [2 => 0, 3 => 2, 4 => 1, 5 => 3];
         $motives = [["Kebab", 1, 1], ["Aztec", 1, 1], ["Alban", 1, 1], ["Aztec2", 1, 1], ["Bomb", 1, 1], ["Plant", 1, 1], ["Wasteland", 1, 1], ["Wanderer", 1, 2], ["Graham", 1, 2], ["Pool", 2, 1], ["Courbet", 2, 1], ["Sunset", 2, 1], ["Sea", 2, 1], ["Creebet", 2, 1], ["Match", 2, 2], ["Bust", 2, 2], ["Stage", 2, 2], ["Void", 2, 2], ["SkullAndRoses", 2, 2], ["Fighters", 4, 2], ["Skeleton", 4, 3], ["DonkeyKong", 4, 3], ["Pointer", 4, 4], ["Pigscene", 4, 4], ["Flaming Skull", 4, 4]];
         $motive = $motives[mt_rand(0, count($motives) - 1)];
         $data = ["x" => $target->x, "y" => $target->y + 0.4, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
         $nbt = new CompoundTag("", ["Motive" => new StringTag("Motive", $data["Motive"]), "Pos" => new EnumTag("Pos", [new DoubleTag("", $data["x"]), new DoubleTag("", $data["y"]), new DoubleTag("", $data["z"])]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", $data["yaw"]), new FloatTag("", 0)])]);
         $painting = new PaintingEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
         $painting->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);
         }
         //TODO
         //$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
         //$e->spawnToAll();
         /*if(($player->gamemode & 0x01) === 0x00){
         			$player->removeItem(Item::get($this->getId(), $this->getDamage(), 1));
         		}*/
         return true;
     }
     return false;
 }
开发者ID:MrDoni98,项目名称:Genisys,代码行数:30,代码来源:Painting.php

示例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;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:16,代码来源:Minecart.php

示例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;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:45,代码来源:SpawnEgg.php

示例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;
 }
开发者ID:1455931078,项目名称:Genisys,代码行数:18,代码来源:Minecart.php

示例7: 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);
             }
         }
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:15,代码来源:Leash.php

示例8: getDispenserId

 public function getDispenserId(Block $block)
 {
     return $block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName();
 }
开发者ID:sJimin,项目名称:EconomyPotionShop,代码行数:4,代码来源:Dispenser.php

示例9: 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);
     }
 }
开发者ID:JiangsNetworkAlpha,项目名称:CaptureTheFlag,代码行数:19,代码来源:CTFBlockBuilder.php

示例10: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($target->isTransparent() === false and $face !== 0 and $face !== 1 and $block->isSolid() === false) {
         $faces = [2 => 1, 3 => 3, 4 => 0, 5 => 2];
         $motives = PaintingEntity::MOTIVES;
         $face2side = [4, 5, 3, 2];
         $foundApplicableMotive = false;
         $searchedMotives = [];
         while (!$foundApplicableMotive) {
             if (count($searchedMotives) == count($motives)) {
                 break;
             }
             $rand = -1;
             while (!isset($motives[$rand])) {
                 $rand = mt_rand(0, count($motives) - 1);
             }
             $motive = $motives[$rand];
             $foundApplicableMotive = true;
             $searchedMotives[$rand] = true;
             for ($x = 0; $x < $motive[1] && $foundApplicableMotive; $x++) {
                 for ($z = 0; $z < $motive[2] && $foundApplicableMotive; $z++) {
                     if ($target->getSide($face2side[$face - 2], $x)->isTransparent() || $target->getSide(Vector3::SIDE_UP, $z)->isTransparent() || $block->getSide($face2side[$face - 2], $x)->isSolid() || $block->getSide(Vector3::SIDE_UP, $z)->isSolid()) {
                         $foundApplicableMotive = false;
                     }
                 }
             }
         }
         if (!$foundApplicableMotive) {
             return false;
         }
         //WIP overlapping calculation AND BTW: EVEN MCPE DOESN'T DO THIS!
         /*
         for($x = 0; $x < $motive[1] && $valid; $x++){
         	for($z = 0; $z < $motive[2] && $valid; $z++){
         		$entPos = $target->getSide($right[$face - 2], $x);
         		//getEntitiesAtThatPos (high intensive calculation)
         		if($entity instanceof PaintingEntity){
         			return false;
         		}
         	}
         }
         */
         $data = ["x" => $target->x, "y" => $target->y - 0.1, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
         if ($motive[2] <= 1) {
             $data["y"] = $data["y"] + 1;
         }
         if ($motive[2] >= 2) {
             $data["y"] = $data["y"] + 0.4;
         }
         if ($motive[2] >= 3) {
             $data["y"] = $data["y"] + 0.1;
         }
         switch ($face2side[$face - 2]) {
             case Vector3::SIDE_NORTH:
                 $data["z"] = $data["z"] + 0.1;
                 break;
             case Vector3::SIDE_SOUTH:
                 $data["z"] = $data["z"] - 0.1;
                 break;
             case Vector3::SIDE_WEST:
                 $data["x"] = $data["x"] + 0.1;
                 break;
             case Vector3::SIDE_EAST:
                 $data["x"] = $data["x"] - 0.1;
                 break;
         }
         $nbt = new CompoundTag("", ["Motive" => new StringTag("Motive", $data["Motive"]), "Pos" => new ListTag("Pos", [new DoubleTag("", $data["x"]), new DoubleTag("", $data["y"]), new DoubleTag("", $data["z"])]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $data["yaw"]), new FloatTag("", 0)])]);
         $painting = new PaintingEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
         $painting->spawnToAll();
         unset($player->getLevel()->updateEntities[$painting->getId()]);
         if ($player->isSurvival()) {
             $item = $player->getInventory()->getItemInHand();
             $count = $item->getCount();
             if (--$count <= 0) {
                 $player->getInventory()->setItemInHand(Item::get(Item::AIR));
             }
             $item->setCount($count);
             $player->getInventory()->setItemInHand($item);
         }
         return true;
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:83,代码来源:Painting.php

示例11: rotateBlockByOne

 private static function rotateBlockByOne(Block $block)
 {
     return Block::get($block->getID(), $block->getDamage(), new Position($block->getZ(), $block->getY(), -$block->getX(), $block->getLevel()));
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:4,代码来源:WorldEditArt.php

示例12: 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";
 }
开发者ID:Bluplayz,项目名称:BedwarsPE,代码行数:22,代码来源:Bedwars.php

示例13: 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);
 }
开发者ID:TuffDev,项目名称:HungerGames,代码行数:12,代码来源:ArenaManager.php

示例14: 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;
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:25,代码来源:TreeCapitator.php

示例15: 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++) {
//.........这里部分代码省略.........
开发者ID:PepbookPvP,项目名称:Genisys,代码行数:101,代码来源:FlintSteel.php


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