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


PHP Item::useOn方法代码示例

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


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

示例1: onActivate

 public function onActivate(Item $item, Player $player = \null)
 {
     if ($item->getId() === Item::DYE and $item->getDamage() === 0xf) {
         $item->count--;
         TallGrassObject::growGrass($this->getLevel(), $this, new Random(\mt_rand()), 8, 2);
         return \true;
     } elseif ($item->isHoe()) {
         $item->useOn($this);
         $this->getLevel()->setBlock($this, new Farmland());
         return \true;
     } elseif ($item->isShovel() and $this->getSide(1)->getId() === Block::AIR) {
         $item->useOn($this);
         $this->getLevel()->setBlock($this, new GrassPath());
         return \true;
     }
     return \false;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:17,代码来源:Grass.php

示例2: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->isHoe()) {
         $item->useOn($this);
         $this->getLevel()->setBlock($this, Block::get(Item::FARMLAND, 0), true);
         return true;
     }
     return false;
 }
开发者ID:PepbookPvP,项目名称:Genisys,代码行数:9,代码来源:Dirt.php

示例3: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::FLINT_STEEL) {
         $item->useOn($this);
         $this->getLevel()->setBlock($this, new Air(), true);
         $mot = (new Random())->nextSignedFloat() * M_PI * 2;
         $tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + 0.5), new DoubleTag("", $this->y), new DoubleTag("", $this->z + 0.5)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($mot) * 0.02), new DoubleTag("", 0.2), new DoubleTag("", -cos($mot) * 0.02)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)]), "Fuse" => new ByteTag("Fuse", 80)]));
         $tnt->spawnToAll();
         return true;
     }
     return false;
 }
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:12,代码来源:TNT.php

示例4: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getID() === Item::DYE and $item->getDamage() === 0xf) {
         $item->count--;
         TallGrassObject::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);
         return true;
     } elseif ($item->isHoe()) {
         $item->useOn($this);
         $this->getLevel()->setBlock($this, new Farmland());
         return true;
     }
     return false;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:13,代码来源:Grass.php

示例5: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getID() === Item::FLINT_STEEL) {
         if (($player->gamemode & 0x1) === 0) {
             $item->useOn($this);
         }
         $data = ["x" => $this->x + 0.5, "y" => $this->y + 0.5, "z" => $this->z + 0.5, "power" => 4, "fuse" => 20 * 4];
         $this->getLevel()->setBlock($this, new Air(), false, false, true);
         //TODO
         //$e = Server::getInstance()->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_PRIMEDTNT, $data);
         //$e->spawnToAll();
         return true;
     }
     return false;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:15,代码来源:TNT.php

示例6: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::SAPLING || $item->getId() === Item::BROWN_MUSHROOM || $item->getId() === Item::RED_MUSHROOM || $item->getId() === Item::ROSE || $item->getId() === Item::DEAD_BUSH || $item->getId() === Item::DANDELION || $item->getId() === Item::TALL_GRASS || $item->getId() === Item::CACTUS) {
         $item->useOn($this);
         $meta = 0;
         switch ($item->getId()) {
             case ITEM::ROSE:
                 $meta = 1;
             case Item::DANDELION:
                 $meta = 2;
             case Item::RED_MUSHROOM:
                 $meta = 7;
             case Item::BROWN_MUSHROOM:
                 $meta = 8;
             case Item::CACTUS:
                 $meta = 9;
             case Item::DEAD_BUSH:
                 $meta = 10;
             case Item::SAPLING:
                 $species = $item->getDamage();
                 /*
                  * GENERIC(0x00),
                  * REDWOOD(0x01),
                  * BIRCH(0x02),
                  * JUNGLE(0x03),
                  * ACACIA(0x04),
                  * DARK_OAK(0x05),
                  */
                 if ($species == 0x0) {
                     $meta = 3;
                 } elseif ($species == 0x1) {
                     $meta = 4;
                 } elseif ($species == 0x2) {
                     $meta = 5;
                 } elseif ($species == 0x3) {
                     $meta = 6;
                 } elseif ($species == 0x4) {
                     $meta = 12;
                 } else {
                     $meta = 13;
                 }
             case Item::TALL_GRASS:
                 $species = $item->getDamage();
                 if ($species == 0x2) {
                     $meta = 11;
                 }
         }
         $this->setDamage($meta);
         $this->getLevel()->setBlock($this, $this, true);
         return true;
     }
     return false;
 }
开发者ID:xHFx,项目名称:ImagicalMine,代码行数:53,代码来源:FlowerPot.php

示例7: onActivate

 public function onActivate(Item $item, Player $player = null)
 {
     if ($item->getId() === Item::FLINT_STEEL) {
         $this->prime($player);
         $this->getLevel()->setBlock($this, new Air(), true);
         $item->useOn($this);
         return true;
     }
     return false;
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:10,代码来源:TNT.php


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