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


PHP Block::getMetadata方法代码示例

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


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

示例1: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($this->meta === AIR) {
         if ($target instanceof LiquidBlock) {
             $level->setBlock($target, new AirBlock(), true, false, true);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = $target instanceof WaterBlock ? WATER : LAVA;
             }
             return true;
         }
     } elseif ($this->meta === WATER) {
         //Support Make Non-Support Water to Support Water
         if ($block->getID() === AIR || $block instanceof WaterBlock && ($block->getMetadata() & 0x7) != 0x0) {
             $water = new WaterBlock();
             $level->setBlock($block, $water, true, false, true);
             $water->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = 0;
             }
             return true;
         }
     } elseif ($this->meta === LAVA) {
         if ($block->getID() === AIR) {
             $level->setBlock($block, new LavaBlock(), true, false, true);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = 0;
             }
             return true;
         }
     }
     return false;
 }
开发者ID:ungarscool1,项目名称:Multicraft,代码行数:32,代码来源:Bucket.php

示例2: place

 public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     $this->meta &= 0x7;
     if ($face === 0) {
         if ($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x8) === 0x8 and ($target->getMetadata() & 0x7) === ($this->meta & 0x7)) {
             $this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
             return true;
         } elseif ($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x7) === ($this->meta & 0x7)) {
             $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
             return true;
         } else {
             $this->meta |= 0x8;
         }
     } elseif ($face === 1) {
         if ($target->getID() === WOOD_SLAB and ($target->getMetadata() & 0x8) === 0 and ($target->getMetadata() & 0x7) === ($this->meta & 0x7)) {
             $this->level->setBlock($target, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
             return true;
         } elseif ($block->getID() === WOOD_SLAB and ($block->getMetadata() & 0x7) === ($this->meta & 0x7)) {
             $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
             return true;
         }
     } elseif (!$player->entity->inBlock($block)) {
         if ($block->getID() === WOOD_SLAB) {
             if (($block->getMetadata() & 0x7) === ($this->meta & 0x7)) {
                 $this->level->setBlock($block, BlockAPI::get(DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
                 return true;
             }
             return false;
         } else {
             if ($fy > 0.5) {
                 $this->meta |= 0x8;
             }
         }
     } else {
         return false;
     }
     if ($block->getID() === WOOD_SLAB and ($target->getMetadata() & 0x7) !== ($this->meta & 0x7)) {
         return false;
     }
     $this->level->setBlock($block, $this, true, false, true);
     return true;
 }
开发者ID:ungarscool1,项目名称:Multicraft,代码行数:42,代码来源:WoodSlab.php

示例3: setBlock

 public function setBlock(Vector3 $pos, Block $block, $update = true, $tiles = false, $direct = false)
 {
     if (!isset($this->level) or $pos instanceof Position and $pos->level !== $this or $pos->x < 0 or $pos->y < 0 or $pos->z < 0) {
         return false;
     }
     $ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata());
     if ($ret === true) {
         if (!$pos instanceof Position) {
             $pos = new Position($pos->x, $pos->y, $pos->z, $this);
         }
         $block->position($pos);
         if ($direct === true) {
             $pk = new UpdateBlockPacket();
             $pk->x = $pos->x;
             $pk->y = $pos->y;
             $pk->z = $pos->z;
             $pk->block = $block->getID();
             $pk->meta = $block->getMetadata();
             $this->server->api->player->broadcastPacket($this->players, $pk);
         } else {
             $i = ($pos->x >> 4) . ":" . ($pos->y >> 4) . ":" . ($pos->z >> 4);
             if (!isset($this->changedBlocks[$i])) {
                 $this->changedBlocks[$i] = array();
                 $this->changedCount[$i] = 0;
             }
             if (ADVANCED_CACHE == true) {
                 Cache::remove("world:{$this->name}:" . ($pos->x >> 4) . ":" . ($pos->z >> 4));
             }
             $this->changedBlocks[$i][] = clone $block;
             ++$this->changedCount[$i];
         }
         if ($update === true) {
             $this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL, 1);
             $this->server->api->entity->updateRadius($pos, 3);
         }
         if ($tiles === true) {
             if (($t = $this->server->api->tile->get($pos)) !== false) {
                 $t->close();
             }
         }
     }
     return $ret;
 }
开发者ID:ungarscool1,项目名称:Multicraft,代码行数:43,代码来源:Level.php

示例4: cancelAction

 private function cancelAction(Block $block, Player $player, $send = true)
 {
     $pk = new UpdateBlockPacket();
     $pk->x = $block->x;
     $pk->y = $block->y;
     $pk->z = $block->z;
     $pk->block = $block->getID();
     $pk->meta = $block->getMetadata();
     $player->dataPacket($pk);
     if ($send === true) {
         $player->sendInventorySlot($player->slot);
     }
     return false;
 }
开发者ID:ungarscool1,项目名称:Multicraft,代码行数:14,代码来源:BlockAPI.php


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