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


PHP Block::add方法代码示例

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


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

示例1: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if (!in_array($target->getId(), array(Block::RAIL, Block::ACTIVATOR_RAIL, Block::DETECTOR_RAIL, Block::POWERED_RAIL))) {
         return false;
     }
     $realPos = $target->add(0.5, 0, 0.5);
     $cart = new MinecartHopperEntity($player->getLevel()->getChunk($realPos->getX() >> 4, $realPos->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $realPos->getX()), new DoubleTag("", $realPos->getY()), new DoubleTag("", $realPos->getZ())]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
     $cart->spawnToAll();
     if ($player->isSurvival()) {
         --$this->count;
     }
     return true;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:13,代码来源:MinecartHopper.php

示例2: 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 CompoundTag("", ["Pos" => new EnumTag("Pos", [new DoubleTag("", $block->getX()), new DoubleTag("", $block->getY() + 1), new DoubleTag("", $block->getZ())]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("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;
         }
         $item->setCount($count);
         $player->getInventory()->setItemInHand($item);
     }
     return true;
 }
开发者ID:PepbookPvP,项目名称:Genisys,代码行数:18,代码来源:Minecart.php

示例3: 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(!$block instanceof RailBlock || !$block instanceof Rail) return false; in previuos version IM
     //if($blockTemp->getId() != self::RAIL and $blockTemp->getId() != self::POWERED_RAIL) return; in previuos version Genisys
     $minecart = new MinecartEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), new Compound("", array("Pos" => new Enum("Pos", array(new Double("", $block->getX()), new Double("", $block->getY() + 1), new Double("", $block->getZ()))), "Motion" => new Enum("Motion", array(new Double("", 0), new Double("", 0), new Double("", 0))), "Rotation" => new Enum("Rotation", array(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:ecoron,项目名称:MinionsLandPE,代码行数:19,代码来源:Minecart.php

示例4: 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;
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:29,代码来源:ChopTree.php


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