new Air(), self::STONE => new Stone(), self::GRASS => new Grass(), self::DIRT => new Dirt(), self::COBBLESTONE => new Cobblestone(), self::PLANKS => new Planks(), self::SAPLING => new Sapling(), self::BEDROCK => new Bedrock(), self::WATER => new Water(), self::STILL_WATER => new StillWater(), self::LAVA => new Lava(), self::STILL_LAVA => new StillLava(), self::SAND => new Sand(), self::GRAVEL => new Gravel(), self::GOLD_ORE => new GoldOre(), self::IRON_ORE => new IronOre(), self::COAL_ORE => new CoalOre(), self::WOOD => new Wood(), self::LEAVES => new Leaves(), self::SPONGE => new Sponge(), self::GLASS => new Glass(), self::LAPIS_ORE => new LapisOre(), self::LAPIS_BLOCK => new Lapis(), self::SANDSTONE => new Sandstone(), self::BED_BLOCK => new Bed(), self::COBWEB => new Cobweb(), self::TALL_GRASS => new TallGrass(), self::DEAD_BUSH => new DeadBush(), self::WOOL => new Wool(), self::DANDELION => new Dandelion(), self::CYAN_FLOWER => new CyanFlower(), self::BROWN_MUSHROOM => new BrownMushroom(), self::RED_MUSHROOM => new RedMushRoom(), self::GOLD_BLOCK => new Gold(), self::IRON_BLOCK => new Iron(), self::DOUBLE_SLAB => new DoubleSlab(), self::SLAB => new Slab(), self::BRICKS_BLOCK => new Bricks(), self::TNT => new TNT(), self::BOOKSHELF => new Bookshelf(), self::MOSS_STONE => new MossStone(), self::OBSIDIAN => new Obsidian(), self::TORCH => new Torch(), self::FIRE => new Fire(), self::WOOD_STAIRS => new WoodStairs(), self::CHEST => new Chest(), self::DIAMOND_ORE => new DiamondOre(), self::DIAMOND_BLOCK => new Diamond(), self::WORKBENCH => new Workbench(), self::WHEAT_BLOCK => new Wheat(), self::FARMLAND => new Farmland(), self::FURNACE => new Furnace(), self::BURNING_FURNACE => new BurningFurnace(), self::SIGN_POST => new SignPost(), self::WOOD_DOOR_BLOCK => new WoodDoor(), self::LADDER => new Ladder(), self::COBBLESTONE_STAIRS => new CobblestoneStairs(), self::WALL_SIGN => new WallSign(), self::IRON_DOOR_BLOCK => new IronDoor(), self::REDSTONE_ORE => new RedstoneOre(), self::GLOWING_REDSTONE_ORE => new GlowingRedstoneOre(), self::SNOW_LAYER => new SnowLayer(), self::ICE => new Ice(), self::SNOW_BLOCK => new Snow(), self::CACTUS => new Cactus(), self::CLAY_BLOCK => new Clay(), self::SUGARCANE_BLOCK => new Sugarcane(), self::FENCE => new Fence(), self::PUMPKIN => new Pumpkin(), self::NETHERRACK => new Netherrack(), self::SOUL_SAND => new SoulSand(), self::GLOWSTONE_BLOCK => new Glowstone(), self::LIT_PUMPKIN => new LitPumpkin(), self::CAKE_BLOCK => new Cake(), self::TRAPDOOR => new Trapdoor(), self::STONE_BRICKS => new StoneBricks(), self::IRON_BARS => new IronBars(), self::GLASS_PANE => new GlassPane(), self::MELON_BLOCK => new Melon(), self::PUMPKIN_STEM => new PumpkinStem(), self::MELON_STEM => new MelonStem(), self::FENCE_GATE => new FenceGate(), self::BRICK_STAIRS => new BrickStairs(), self::STONE_BRICK_STAIRS => new StoneBrickStairs(), self::NETHER_BRICKS => new NetherBrick(), self::NETHER_BRICKS_STAIRS => new NetherBrickStairs(), self::SANDSTONE_STAIRS => new SandstoneStairs(), self::SPRUCE_WOOD_STAIRS => new SpruceWoodStairs(), self::BIRCH_WOOD_STAIRS => new BirchWoodStairs(), self::JUNGLE_WOOD_STAIRS => new JungleWoodStairs(), self::STONE_WALL => new StoneWall(), self::CARROT_BLOCK => new Carrot(), self::POTATO_BLOCK => new Potato(), self::QUARTZ_BLOCK => new Quartz(), self::QUARTZ_STAIRS => new QuartzStairs(), self::DOUBLE_WOOD_SLAB => new DoubleWoodSlab(), self::WOOD_SLAB => new WoodSlab(), self::HAY_BALE => new HayBale(), self::CARPET => new Carpet(), self::COAL_BLOCK => new Coal(), self::BEETROOT_BLOCK => new Beetroot(), self::STONECUTTER => new Stonecutter(), self::GLOWING_OBSIDIAN => new GlowingObsidian(), ); } } /** * @param int $id * @param int $meta * @param Position $pos * * @return Block */ public static function get($id, $meta = 0, Position $pos = null){ if(isset(self::$list[$id])){ $block = clone self::$list[$id]; $block->setMetadata($meta); } else{ $block = new Generic($id, $meta); } if($pos instanceof Position){ $block->position($pos); } return $block; } public function __construct($id, $meta = 0, $name = "Unknown"){ $this->id = (int) $id; $this->meta = (int) $meta; $this->name = $name; $this->breakTime = 0.20; $this->hardness = 10; } /** * @return int */ final public function getHardness(){ return $this->hardness; } /** * @return string */ final public function getName(){ return $this->name; } /** * @return int */ final public function getID(){ return $this->id; } /** * @return int */ final public function getMetadata(){ return $this->meta; } /** * @param int $meta */ final public function setMetadata($meta){ $this->meta = $meta & 0x0F; } /** * Sets the block position to a new Position object * * @param Position $v */ final public function position(Position $v){ $this->level = $v->level; $this->x = (int) $v->x; $this->y = (int) $v->y; $this->z = (int) $v->z; } /** * Returns an array of Item objects to be dropped * * @param Item $item * @param Player $player * * @return array */ public function getDrops(Item $item, PocketMine\Player $player){ if(!isset(self::$class[$this->id])){ //Unknown blocks return array(); } else{ return array( array($this->id, $this->meta, 1), ); } } /** * Returns the seconds that this block takes to be broken using an specific Item * * @param Item $item * @param Player $player * * @return float */ public function getBreakTime(Item $item, PocketMine\Player $player){ if(($player->gamemode & 0x01) === 0x01){ return 0.15; } return $this->breakTime; } /** * Returns the Block on the side $side, works like Vector3::side() * * @param int $side * * @return Block */ public function getSide($side){ $v = parent::getSide($side); if($this->level instanceof Level){ return $this->level->getBlock($v); } return $v; } final public function __toString(){ return "Block " . $this->name . " (" . $this->id . ":" . $this->meta . ")"; } /** * Returns if the item can be broken with an specific Item * * @param Item $item * @param Player $player * * @return bool */ abstract function isBreakable(Item $item, PocketMine\Player $player); /** * Do the actions needed so the block is broken with the Item * * @param Item $item * @param Player $player * * @return mixed */ abstract function onBreak(Item $item, PocketMine\Player $player); /** * Places the Block, using block space and block target, and side. Returns if the block has been placed. * * @param Item $item * @param Player $player * @param Block $block * @param Block $target * @param int $face * @param float $fx * @param float $fy * @param float $fz * * @return bool */ abstract function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz); /** * Do actions when activated by Item. Returns if it has done anything * * @param Item $item * @param Player $player * * @return bool */ abstract function onActivate(Item $item, PocketMine\Player $player); /** * Fires a block update on the Block * * @param int $type * * @return void */ abstract function onUpdate($type); }