pocketmine\tile\Tile::createTile PHP Method

createTile() public static method

public static createTile ( string $type, pocketmine\level\format\FullChunk $chunk, CompoundTag $nbt, $args ) : Tile
$type string
$chunk pocketmine\level\format\FullChunk
$nbt pocketmine\nbt\tag\CompoundTag
$args
return Tile
    public static function createTile($type, FullChunk $chunk, CompoundTag $nbt, ...$args)
    {
        if (isset(self::$knownTiles[$type])) {
            $class = self::$knownTiles[$type];
            return new $class($chunk, $nbt, ...$args);
        }
        return null;
    }

Usage Example

Ejemplo n.º 1
1
 public function onActivate(Item $item, Player $player = null)
 {
     if ($player instanceof Player) {
         $t = $this->getLevel()->getTile($this);
         if ($t instanceof FurnaceTile) {
             $furnace = $t;
         } else {
             $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::FURNACE), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]);
             $nbt->Items->setTagType(NBT::TAG_Compound);
             $furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
         }
         if (isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof StringTag) {
             if ($furnace->namedtag->Lock->getValue() !== $item->getCustomName()) {
                 return true;
             }
         }
         if ($player->isCreative() and $player->getServer()->limitedCreative) {
             return true;
         }
         $player->addWindow($furnace->getInventory());
     }
     return true;
 }
All Usage Examples Of pocketmine\tile\Tile::createTile