Skip to content

Commit

Permalink
Merge pull request #1912 from Intyre/feature/block
Browse files Browse the repository at this point in the history
EndPortal, EndStone, MonsterSpawner, Mycelium and Podzol blocks added
  • Loading branch information
Shoghi Cervantes committed Aug 21, 2014
2 parents a3cc676 + ecc9e1d commit 4858c7d
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 9 deletions.
24 changes: 17 additions & 7 deletions src/pocketmine/block/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ abstract class Block extends Position implements Metadatable{
const OBSIDIAN = 49;
const TORCH = 50;
const FIRE = 51;

const MONSTER_SPAWNER = 52;
const WOOD_STAIRS = 53;
const WOODEN_STAIRS = 53;
const OAK_WOOD_STAIRS = 53;
Expand Down Expand Up @@ -168,12 +168,16 @@ abstract class Block extends Position implements Metadatable{
const FENCE_GATE = 107;
const BRICK_STAIRS = 108;
const STONE_BRICK_STAIRS = 109;
const MYCELIUM = 110;

const NETHER_BRICKS = 112;
const NETHER_BRICK_BLOCK = 112;

const NETHER_BRICKS_STAIRS = 114;

const END_PORTAL = 120;
const END_STONE = 121;

const SANDSTONE_STAIRS = 128;
const EMERALD_ORE = 129;

Expand Down Expand Up @@ -220,6 +224,7 @@ abstract class Block extends Position implements Metadatable{
const HARDENED_CLAY = 172;
const COAL_BLOCK = 173;

const PODZOL = 243;
const BEETROOT_BLOCK = 244;
const STONECUTTER = 245;
const GLOWING_OBSIDIAN = 246;
Expand Down Expand Up @@ -249,9 +254,9 @@ abstract class Block extends Position implements Metadatable{
[Item::STONE, 5],
[Item::STONE, 6],
[Item::DIRT, 0],
//TODO: PODZOL
[Item::PODZOL, 0],
[Item::GRASS, 0],
//TODO: MYCELIUM
[Item::MYCELIUM, 0],
[Item::CLAY_BLOCK, 0],
[Item::HARDENED_CLAY, 0],
[Item::STAINED_CLAY, 0],
Expand Down Expand Up @@ -322,7 +327,7 @@ abstract class Block extends Position implements Metadatable{
[Item::OBSIDIAN, 0],
[Item::ICE, 0],
[Item::SNOW_BLOCK, 0],
//TODO: ENDSTONE
[Item::END_STONE, 0],

//Decoration
[Item::COBBLESTONE_WALL, 0],
Expand Down Expand Up @@ -355,6 +360,7 @@ abstract class Block extends Position implements Metadatable{
[Item::CHEST, 0],
[Item::FURNACE, 0],
//TODO: End Portal
[Item::END_PORTAL, 0],
[Item::DANDELION, 0],
[Item::POPPY, 0],
//TODO: blue orchid
Expand Down Expand Up @@ -400,7 +406,7 @@ abstract class Block extends Position implements Metadatable{
[Item::LEAVES2, 1],
[Item::CAKE, 0],
[Item::SIGN, 0],
//TODO: Monster Spawner
[Item::MONSTER_SPAWNER, 0],
[Item::WOOL, 0],
[Item::WOOL, 7],
[Item::WOOL, 6],
Expand Down Expand Up @@ -565,7 +571,7 @@ public static function init(){
self::OBSIDIAN => new Obsidian(),
self::TORCH => new Torch(),
self::FIRE => new Fire(),

self::MONSTER_SPAWNER => new MonsterSpawner(),
self::WOOD_STAIRS => new WoodStairs(),
self::CHEST => new Chest(),

Expand Down Expand Up @@ -617,10 +623,13 @@ public static function init(){
self::BRICK_STAIRS => new BrickStairs(),
self::STONE_BRICK_STAIRS => new StoneBrickStairs(),

self::MYCELIUM => new Mycelium(),
self::NETHER_BRICKS => new NetherBrick(),

self::NETHER_BRICKS_STAIRS => new NetherBrickStairs(),

self::END_PORTAL => new EndPortal(),
self::END_STONE => new EndStone(),
self::SANDSTONE_STAIRS => new SandstoneStairs(),
self::EMERALD_ORE => new EmeraldOre(),

Expand Down Expand Up @@ -649,6 +658,7 @@ public static function init(){
self::HARDENED_CLAY => new HardenedClay(),
self::COAL_BLOCK => new Coal(),

self::PODZOL => new Podzol(),
self::BEETROOT_BLOCK => new Beetroot(),
self::STONECUTTER => new Stonecutter(),
self::GLOWING_OBSIDIAN => new GlowingObsidian(),
Expand Down Expand Up @@ -893,4 +903,4 @@ public function removeMetadata($metadataKey, Plugin $plugin){
$this->getLevel()->getBlockMetadata()->removeMetadata($this, $metadataKey, $plugin);
}
}
}
}
31 changes: 31 additions & 0 deletions src/pocketmine/block/EndPortal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

namespace pocketmine\block;

use pocketmine\item\Item;

class EndPortal extends Solid{
public function __construct($meta = 0){
parent::__construct(self::END_PORTAL, $meta, "End Portal");
$this->hardness = 18000000;
}
}
48 changes: 48 additions & 0 deletions src/pocketmine/block/EndStone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

namespace pocketmine\block;

use pocketmine\item\Item;

class EndStone extends Solid{
public function __construct(){
parent::__construct(self::END_STONE, 0, "End Stone");
$this->hardness = 45;
}

public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.6;
case 4:
return 0.75;
case 3:
return 1.15;
case 2:
return 0.4;
case 1:
return 2.25;
default:
return 15;
}
}
}
52 changes: 52 additions & 0 deletions src/pocketmine/block/MonsterSpawner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

namespace pocketmine\block;

use pocketmine\item\Item;

class MonsterSpawner extends Solid{
public function __construct(){
parent::__construct(self::MONSTER_SPAWNER, 0, "Monster Spawner");
$this->hardness = 25;
}

public function getBreakTime(Item $item){
switch($item->isPickaxe()){
case 5:
return 0.95;
case 4:
return 1.25;
case 3:
return 1.9;
case 2:
return 0.65;
case 1:
return 3.75;
default:
return 25;
}
}

public function getDrops(Item $item){
return [];
}
}
53 changes: 53 additions & 0 deletions src/pocketmine/block/Mycelium.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

namespace pocketmine\block;

use pocketmine\item\Item;

class Mycelium extends Solid{
public function __construct(){
parent::__construct(self::MYCELIUM, 0, "Mycelium");
$this->hardness = 2.5;
}

public function getDrops(Item $item){
return [
[Item::DIRT, 0, 1],
];
}

public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_RANDOM){
//TODO: light levels
$x = mt_rand($this->x - 1, $this->x + 1);
$y = mt_rand($this->y - 2, $this->y + 2);
$z = mt_rand($this->z - 1, $this->z + 1);
$block = $this->getLevel()->getBlockIdAt($x, $y, $z);
if($block === Block::DIRT){
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
if($block->getSide(1) instanceof Transparent){
$this->getLevel()->setBlock($block, new Mycelium());
}
}
}
}
}
31 changes: 31 additions & 0 deletions src/pocketmine/block/Podzol.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/

namespace pocketmine\block;

use pocketmine\item\Item;

class Podzol extends Solid{
public function __construct(){
parent::__construct(self::PODZOL, 0, "Podzol");
$this->hardness = 2.5;
}
}
9 changes: 7 additions & 2 deletions src/pocketmine/item/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Item{
const OBSIDIAN = 49;
const TORCH = 50;
const FIRE = 51;

const MONSTER_SPAWNER = 52;
const WOOD_STAIRS = 53;
const WOODEN_STAIRS = 53;
const OAK_WOOD_STAIRS = 53;
Expand Down Expand Up @@ -164,12 +164,16 @@ class Item{
const FENCE_GATE = 107;
const BRICK_STAIRS = 108;
const STONE_BRICK_STAIRS = 109;
const MYCELIUM = 110;

const NETHER_BRICKS = 112;
const NETHER_BRICK_BLOCK = 112;

const NETHER_BRICKS_STAIRS = 114;

const END_PORTAL = 120;
const END_STONE = 121;

const SANDSTONE_STAIRS = 128;
const EMERALD_ORE = 129;

Expand Down Expand Up @@ -216,6 +220,7 @@ class Item{
const HARDENED_CLAY = 172;
const COAL_BLOCK = 173;

const PODZOL = 243;
const BEETROOT_BLOCK = 244;
const STONECUTTER = 245;
const GLOWING_OBSIDIAN = 246;
Expand Down Expand Up @@ -620,4 +625,4 @@ public final function equals(Item $item, $checkDamage = false){
return $this->id === $item->getID() and ($checkDamage === false or $this->getDamage() === $item->getDamage());
}

}
}

0 comments on commit 4858c7d

Please sign in to comment.