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


PHP Block::getId方法代码示例

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


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

示例1: activateBlockWithoutWire

 public function activateBlockWithoutWire(Block $block)
 {
     if ($block instanceof Door or $block instanceof Trapdoor or $block instanceof FenceGate) {
         if (!$block->isOpened()) {
             $block->onActivate(new Item(0));
         }
     }
     if ($block->getId() == Block::TNT) {
         $block->onActivate(new Item(Item::FLINT_AND_STEEL));
     }
     /** @var InactiveRedstoneLamp $block */
     if ($block->getId() == Block::INACTIVE_REDSTONE_LAMP) {
         $block->turnOn();
     }
     /** @var Dropper|Dispenser $block */
     if ($block->getId() == Block::DROPPER or $block->getId() == Block::DISPENSER) {
         $block->activate();
     }
     /** @var PoweredRepeater $block */
     if ($block->getId() == Block::UNPOWERED_REPEATER_BLOCK) {
         if ($this->equals($block->getSide($block->getDirection()))) {
             $block->activate();
         }
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:25,代码来源:RedstoneSource.php

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

示例3: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false || $target->getId() === Block::LEAVES || $target->getId() === Block::LEAVES2) {
         $faces = [2 => 2, 3 => 3, 4 => 4, 5 => 5];
         if (isset($faces[$face])) {
             $this->meta = $faces[$face];
             $this->getLevel()->setBlock($block, $this, true, true);
             return true;
         }
     }
     return false;
 }
开发者ID:XxDXM-hippiexX,项目名称:ImagicalMine,代码行数:12,代码来源:Vine.php

示例4: useOn

 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  *
  * @return bool
  */
 public function useOn($object)
 {
     if ($this->isHoe()) {
         if ($object instanceof Block and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)) {
             $this->meta++;
         }
     } elseif ($object instanceof Entity and !$this->isSword()) {
         $this->meta += 2;
     } else {
         $this->meta++;
     }
     return true;
 }
开发者ID:mattiasaxelsson,项目名称:PocketMine-MP,代码行数:20,代码来源:Tool.php

示例5: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (($target->isTransparent() === false or $target->getId() === self::SLAB or $target->getId() === self::PACKED_ICE) and $face !== 0 and $face !== 1) {
         $faces = [2 => 3, 3 => 2, 4 => 1, 5 => 0];
         $this->meta = $faces[$face] & 0x3;
         if ($fy > 0.5) {
             $this->meta |= 0x4;
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:13,代码来源:IronTrapdoor.php

示例6: useOn

 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  *
  * @return bool
  */
 public function useOn($object)
 {
     if ($this->isUnbreakable()) {
         return false;
     }
     $break = true;
     if (($ench = $this->getEnchantment(Enchantment::TYPE_MINING_DURABILITY)) != null) {
         $rnd = mt_rand(1, 100);
         if ($rnd <= 100 / ($ench->getLevel() + 1)) {
             $break = false;
         }
     }
     if ($object instanceof Block) {
         if (!$break) {
             return false;
         }
         if ($object->getToolType() === Tool::TYPE_PICKAXE and $this->isPickaxe() or $object->getToolType() === Tool::TYPE_SHOVEL and $this->isShovel() or $object->getToolType() === Tool::TYPE_AXE and $this->isAxe() or $object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or $object->getToolType() === Tool::TYPE_SHEARS and $this->isShears()) {
             $this->meta++;
         } elseif (!$this->isShears() and $object->getBreakTime($this) > 0) {
             $this->meta += 2;
         }
     } elseif ($this->isHoe()) {
         if (!$break) {
             return false;
         }
         if ($object instanceof Block and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)) {
             $this->meta++;
         }
     } elseif ($object instanceof Entity) {
         $return = true;
         if (!$this->isSword()) {
             if ($break) {
                 $this->meta += 2;
                 $return = false;
             }
         } else {
             if ($break) {
                 $this->meta++;
                 $return = false;
             }
             if (!$this->hasEnchantments()) {
                 return $return;
             }
             //TODO: move attacking from player class here
             //$fire = $this->getEnchantment(Enchantment::TYPE_WEAPON_FIRE_ASPECT);
             //$object->setOnFire($fire->getLevel() * 4);
         }
     }
     return true;
 }
开发者ID:Cecil107,项目名称:PocketMine-0.13.0,代码行数:57,代码来源:Tool.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: 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

示例10: sendBlockInfo

 /**
  * @param CommandSender $sender
  * @param Block $block
  */
 public function sendBlockInfo(CommandSender $sender, Block $block)
 {
     $sender->sendMessage("Name: " . $block->getName());
     $sender->sendMessage("XYZ: " . $block->getFloorX() . ":" . $block->getFloorY() . ":" . $block->getFloorZ());
     $sender->sendMessage("Level: " . $block->getLevel()->getName());
     $sender->sendMessage("Block-id: " . $block->getId() . ":" . $block->getDamage());
     $sender->sendMessage("Hardness: " . $block->getHardness());
     $sender->sendMessage("Resistance: " . $block->getResistance());
     $sender->sendMessage("Tool-type: " . $block->getToolType());
     $sender->sendMessage("Friction: " . $block->getFrictionFactor());
     $sender->sendMessage("Light-level: " . $block->getLightLevel());
     //$sender->sendMessage("Is-placeable: ".($block->canBePlaced() ? TextFormat::GREEN."yes" : TextFormat::RED."no"));
     $sender->sendMessage("Is-replaceable: " . ($block->canBeReplaced() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-transparent: " . ($block->isTransparent() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-solid: " . ($block->isSolid() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     //$sender->sendMessage("Is-flowable: ".($block->canBeFlowedInto() ? TextFormat::GREEN."yes" : TextFormat::RED."no"));
     //$sender->sendMessage("Is-activateable: ".($block->canBeActivated() ? TextFormat::GREEN."yes" : TextFormat::RED."no"));
     $sender->sendMessage("Is-passable: " . ($block->canPassThrough() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $dropCount = 0;
     $dropNames = "";
     foreach ($block->getDrops() as $drop) {
         $dropNames .= $drop->getName() . ", ";
         $dropCount++;
     }
     $sender->sendMessage("Drops (" . $dropCount . "): " . substr($dropNames, 0, -2));
 }
开发者ID:happyexceed,项目名称:PocketMine-Plugins-1,代码行数:30,代码来源:InfoFetcher.php

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

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

示例13: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->getId() === Block::WOOD and $target->getDamage() === Wood::JUNGLE) {
         if ($face !== 0 and $face !== 1) {
             $faces = [2 => 0, 3 => 2, 4 => 3, 5 => 1];
             $this->meta = $faces[$face];
             $this->getLevel()->setBlock($block, $this, true);
             return true;
         }
     }
     return false;
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:12,代码来源:CocoaPod.php

示例14: fillUpChest

 public static function fillUpChest(Block $chest, Player $player)
 {
     if ($chest->getId() == Item::CHEST || $chest->getId()) {
         if ($player->gamemode == Player::CREATIVE) {
             $player->sendMessage("[HG] You are in creative Mode");
             return;
         }
         if (!$player->isOp()) {
             $pk = new ContainerSetContentPacket();
             $pk->windowid = $player->getWindowId($player->getInventory());
             // ContainerSetContentPacket::SPECIAL_INVENTORY;
             for ($i = 1; $i < 5; $i++) {
                 $pk->slots[] = HungerGameKit::randomItems();
             }
             $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
             if ($player->getInventory() != null) {
                 $player->getInventory()->sendContents($player);
             }
             // $player->sendMessage ( "[HG] openning chest" );
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:22,代码来源:PlayerHelper.php

示例15: place

 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = \null)
 {
     if (($target->isTransparent() === \false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1) {
         $faces = [2 => 0, 3 => 1, 4 => 2, 5 => 3];
         $this->meta = $faces[$face] & 0x3;
         if ($fy > 0.5) {
             $this->meta |= 0x8;
         }
         $this->getLevel()->setBlock($block, $this, \true, \true);
         return \true;
     }
     return \false;
 }
开发者ID:ken77731,项目名称:PocketMine-0.13.0,代码行数:13,代码来源:Trapdoor.php


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