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


PHP block\Block类代码示例

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


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

示例1: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $block->getSide(Vector3::SIDE_DOWN);
     if ($down->isTransparent() === false || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
         $this->getLevel()->setBlock($this, Block::get($this->id, 0));
         $up = $block->getSide(Vector3::SIDE_UP);
         if ($block->getSide(Vector3::SIDE_EAST) && $block->getSide(Vector3::SIDE_WEST)) {
             if ($up->getSide(Vector3::SIDE_EAST)) {
                 $this->setDirection(Vector3::SIDE_EAST, true);
             } elseif ($up->getSide(Vector3::SIDE_WEST)) {
                 $this->setDirection(Vector3::SIDE_WEST, true);
             } else {
                 $this->setDirection(Vector3::SIDE_EAST);
             }
         } elseif ($block->getSide(Vector3::SIDE_SOUTH) && $block->getSide(Vector3::SIDE_NORTH)) {
             if ($up->getSide(Vector3::SIDE_SOUTH)) {
                 $this->setDirection(Vector3::SIDE_SOUTH, true);
             } elseif ($up->getSide(Vector3::SIDE_NORTH)) {
                 $this->setDirection(Vector3::SIDE_NORTH, true);
             } else {
                 $this->setDirection(Vector3::SIDE_SOUTH);
             }
         } else {
             $this->setDirection(Vector3::SIDE_NORTH);
         }
         return true;
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:29,代码来源:ActivatorRail.php

示例2: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($this->meta === Item::AIR) {
         if ($target instanceof Liquid) {
             $level->setBlock($target, new Air(), true);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = $target instanceof Water ? Item::WATER : Item::LAVA;
             }
             return true;
         }
     } elseif ($this->meta === Item::WATER) {
         //Support Make Non-Support Water to Support Water
         if ($block->getID() === self::AIR || $block instanceof Water && ($block->getDamage() & 0x7) != 0x0) {
             $water = new Water();
             $level->setBlock($block, $water, true);
             $water->place(clone $this, $block, $target, $face, $fx, $fy, $fz, $player);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = 0;
             }
             return true;
         }
     } elseif ($this->meta === Item::LAVA) {
         if ($block->getID() === self::AIR) {
             $level->setBlock($block, new Lava(), true);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = 0;
             }
             return true;
         }
     }
     return false;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:32,代码来源:Bucket.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: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $this->getSide(0);
     if ($target->isTransparent() === false and $face !== 0) {
         $faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
         $this->meta = $faces[$face];
         $side = $faces[$face];
         $faces = [1 => 4, 2 => 5, 3 => 2, 4 => 3, 5 => 0, 6 => 0, 0 => 0];
         if ($this->getSide($faces[$side])->isCharged($this->getHash())) {
             $this->id = 75;
             $this->getLevel()->setBlock($block, $this);
             return;
         }
         $this->getLevel()->setBlock($block, $this);
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
         return true;
     } elseif ($down->isTransparent() === false or $down->getId() === self::FENCE or $down->getId() === self::COBBLE_WALL or $down->getId() === self::GLASS || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
         $this->meta = 0;
         if ($target->isCharged($this->getHash())) {
             $this->id = 75;
             $this->getLevel()->setBlock($block, $this);
             return;
         }
         $this->getLevel()->setBlock($block, $this);
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
         return true;
     }
     return false;
 }
开发者ID:starterdragon,项目名称:ClearSky,代码行数:29,代码来源:LitRedstoneTorch.php

示例5: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($player === null or $player->isSurvival() !== true) {
         return false;
     }
     if ($target->getId() === Block::STILL_WATER or $target->getId() === Block::WATER) {
         $player->getServer()->getPluginManager()->callEvent($ev = new PlayerGlassBottleEvent($player, $target, $this));
         if ($ev->isCancelled()) {
             return false;
         } else {
             if ($this->count <= 1) {
                 $player->getInventory()->setItemInHand(Item::get(Item::POTION, 0, 1));
                 return true;
             } else {
                 $this->count--;
                 $player->getInventory()->setItemInHand($this);
             }
             if ($player->getInventory()->canAddItem(Item::get(Item::POTION, 0, 1)) === true) {
                 $player->getInventory()->AddItem(Item::get(Item::POTION, 0, 1));
             } else {
                 $motion = $player->getDirectionVector()->multiply(0.4);
                 $position = clone $player->getPosition();
                 $player->getLevel()->dropItem($position->add(0, 0.5, 0), Item::get(Item::POTION, 0, 1), $motion, 40);
             }
             return true;
         }
     }
     return false;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:29,代码来源:GlassBottle.php

示例6: isFreezable

 /**
  * @param Block $block
  * @return bool
  */
 public function isFreezable(Block $block)
 {
     if (isset($this->configs[$ilevel = strtolower($block->getLevel()->getName())])) {
         return $this->configs[$ilevel]->exists($block->getId() . ":" . $block->getDamage(), true);
     }
     return false;
 }
开发者ID:NameNoOne100,项目名称:PocketMine-Plugins,代码行数:11,代码来源:BlockFreezer.php

示例7: 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

示例8: isBlockSpecified

 /**
  * @param Block $block
  * @return bool
  */
 private function isBlockSpecified(Block $block)
 {
     $key = array_change_key_case($this->getConfig()->getNested("level." . $block->getLevel()->getName()), CASE_LOWER);
     if (is_array($key)) {
         return in_array($block->getId() . ":" . $block->getDamage(), $key);
     }
 }
开发者ID:pomee4,项目名称:PocketMine-Plugins,代码行数:11,代码来源:BlockFreezer.php

示例9: isBlockSpecified

 /**
  * @param Block $block
  * @return bool
  */
 public function isBlockSpecified(Block $block)
 {
     $key = array_change_key_case($this->getConfig()->get("level"), CASE_LOWER);
     $levelKey = $key[strtolower($block->getLevel()->getName())];
     if (is_array($levelKey)) {
         return in_array($block->getId() . ":" . $block->getDamage(), $levelKey);
     }
 }
开发者ID:happyexceed,项目名称:PocketMine-Plugins-1,代码行数:12,代码来源:BlockFreezer.php

示例10: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false || $target->getId() === self::FENCE) {
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
开发者ID:WhyMastar,项目名称:ImagicalMine,代码行数:8,代码来源:WoodenPressurePlate.php

示例11: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($block->getSide(0)->getID() === self::FARMLAND) {
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
开发者ID:organization,项目名称:CropPlus,代码行数:8,代码来源:Crops.php

示例12: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $target->getSide(Vector3::SIDE_DOWN);
     if ($down->isTransparent() === false || $down instanceof Fence || $down instanceof FenceGate) {
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
开发者ID:XxDXM-hippiexX,项目名称:ImagicalMine,代码行数:9,代码来源:StonePressurePlate.php

示例13: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($face !== 0 && $face !== 1 && !$target->isTransparent()) {
         $ret = $this->setFacingDirection($face);
         $this->getLevel()->setBlock($block, $this, true);
         return $ret;
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:9,代码来源:TripwireHook.php

示例14: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (!$target->isTransparent() || ($face === 0 && ($this->getSide(0) instanceof Slab && ($this->getSide(0)->meta & 0x8) === 0x8) || $this->getSide(0) instanceof WoodSlab && ($this->getSide(0)->meta & 0x8) === 0x8 || $this->getSide(0) instanceof Stair && ($this->getSide(0)->meta & 0x4) === 0x4)) {
         $this->meta = $face;
         $this->getLevel()->setBlock($block, $this, true, false);
         return true;
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:9,代码来源:WoodenButton.php

示例15: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (!$target->isTransparent()) {
         $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
开发者ID:Creeperface01,项目名称:ImagicalMine,代码行数:10,代码来源:UnlitRedstoneRepeater.php


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