Skip to content

Commit 4858c7d

Browse files
author
Shoghi Cervantes
committed
Merge pull request #1912 from Intyre/feature/block
EndPortal, EndStone, MonsterSpawner, Mycelium and Podzol blocks added
2 parents a3cc676 + ecc9e1d commit 4858c7d

File tree

7 files changed

+239
-9
lines changed

7 files changed

+239
-9
lines changed

src/pocketmine/block/Block.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ abstract class Block extends Position implements Metadatable{
9999
const OBSIDIAN = 49;
100100
const TORCH = 50;
101101
const FIRE = 51;
102-
102+
const MONSTER_SPAWNER = 52;
103103
const WOOD_STAIRS = 53;
104104
const WOODEN_STAIRS = 53;
105105
const OAK_WOOD_STAIRS = 53;
@@ -168,12 +168,16 @@ abstract class Block extends Position implements Metadatable{
168168
const FENCE_GATE = 107;
169169
const BRICK_STAIRS = 108;
170170
const STONE_BRICK_STAIRS = 109;
171+
const MYCELIUM = 110;
171172

172173
const NETHER_BRICKS = 112;
173174
const NETHER_BRICK_BLOCK = 112;
174175

175176
const NETHER_BRICKS_STAIRS = 114;
176177

178+
const END_PORTAL = 120;
179+
const END_STONE = 121;
180+
177181
const SANDSTONE_STAIRS = 128;
178182
const EMERALD_ORE = 129;
179183

@@ -220,6 +224,7 @@ abstract class Block extends Position implements Metadatable{
220224
const HARDENED_CLAY = 172;
221225
const COAL_BLOCK = 173;
222226

227+
const PODZOL = 243;
223228
const BEETROOT_BLOCK = 244;
224229
const STONECUTTER = 245;
225230
const GLOWING_OBSIDIAN = 246;
@@ -249,9 +254,9 @@ abstract class Block extends Position implements Metadatable{
249254
[Item::STONE, 5],
250255
[Item::STONE, 6],
251256
[Item::DIRT, 0],
252-
//TODO: PODZOL
257+
[Item::PODZOL, 0],
253258
[Item::GRASS, 0],
254-
//TODO: MYCELIUM
259+
[Item::MYCELIUM, 0],
255260
[Item::CLAY_BLOCK, 0],
256261
[Item::HARDENED_CLAY, 0],
257262
[Item::STAINED_CLAY, 0],
@@ -322,7 +327,7 @@ abstract class Block extends Position implements Metadatable{
322327
[Item::OBSIDIAN, 0],
323328
[Item::ICE, 0],
324329
[Item::SNOW_BLOCK, 0],
325-
//TODO: ENDSTONE
330+
[Item::END_STONE, 0],
326331

327332
//Decoration
328333
[Item::COBBLESTONE_WALL, 0],
@@ -355,6 +360,7 @@ abstract class Block extends Position implements Metadatable{
355360
[Item::CHEST, 0],
356361
[Item::FURNACE, 0],
357362
//TODO: End Portal
363+
[Item::END_PORTAL, 0],
358364
[Item::DANDELION, 0],
359365
[Item::POPPY, 0],
360366
//TODO: blue orchid
@@ -400,7 +406,7 @@ abstract class Block extends Position implements Metadatable{
400406
[Item::LEAVES2, 1],
401407
[Item::CAKE, 0],
402408
[Item::SIGN, 0],
403-
//TODO: Monster Spawner
409+
[Item::MONSTER_SPAWNER, 0],
404410
[Item::WOOL, 0],
405411
[Item::WOOL, 7],
406412
[Item::WOOL, 6],
@@ -565,7 +571,7 @@ public static function init(){
565571
self::OBSIDIAN => new Obsidian(),
566572
self::TORCH => new Torch(),
567573
self::FIRE => new Fire(),
568-
574+
self::MONSTER_SPAWNER => new MonsterSpawner(),
569575
self::WOOD_STAIRS => new WoodStairs(),
570576
self::CHEST => new Chest(),
571577

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

626+
self::MYCELIUM => new Mycelium(),
620627
self::NETHER_BRICKS => new NetherBrick(),
621628

622629
self::NETHER_BRICKS_STAIRS => new NetherBrickStairs(),
623630

631+
self::END_PORTAL => new EndPortal(),
632+
self::END_STONE => new EndStone(),
624633
self::SANDSTONE_STAIRS => new SandstoneStairs(),
625634
self::EMERALD_ORE => new EmeraldOre(),
626635

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

661+
self::PODZOL => new Podzol(),
652662
self::BEETROOT_BLOCK => new Beetroot(),
653663
self::STONECUTTER => new Stonecutter(),
654664
self::GLOWING_OBSIDIAN => new GlowingObsidian(),
@@ -893,4 +903,4 @@ public function removeMetadata($metadataKey, Plugin $plugin){
893903
$this->getLevel()->getBlockMetadata()->removeMetadata($this, $metadataKey, $plugin);
894904
}
895905
}
896-
}
906+
}

src/pocketmine/block/EndPortal.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
namespace pocketmine\block;
23+
24+
use pocketmine\item\Item;
25+
26+
class EndPortal extends Solid{
27+
public function __construct($meta = 0){
28+
parent::__construct(self::END_PORTAL, $meta, "End Portal");
29+
$this->hardness = 18000000;
30+
}
31+
}

src/pocketmine/block/EndStone.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
namespace pocketmine\block;
23+
24+
use pocketmine\item\Item;
25+
26+
class EndStone extends Solid{
27+
public function __construct(){
28+
parent::__construct(self::END_STONE, 0, "End Stone");
29+
$this->hardness = 45;
30+
}
31+
32+
public function getBreakTime(Item $item){
33+
switch($item->isPickaxe()){
34+
case 5:
35+
return 0.6;
36+
case 4:
37+
return 0.75;
38+
case 3:
39+
return 1.15;
40+
case 2:
41+
return 0.4;
42+
case 1:
43+
return 2.25;
44+
default:
45+
return 15;
46+
}
47+
}
48+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
namespace pocketmine\block;
23+
24+
use pocketmine\item\Item;
25+
26+
class MonsterSpawner extends Solid{
27+
public function __construct(){
28+
parent::__construct(self::MONSTER_SPAWNER, 0, "Monster Spawner");
29+
$this->hardness = 25;
30+
}
31+
32+
public function getBreakTime(Item $item){
33+
switch($item->isPickaxe()){
34+
case 5:
35+
return 0.95;
36+
case 4:
37+
return 1.25;
38+
case 3:
39+
return 1.9;
40+
case 2:
41+
return 0.65;
42+
case 1:
43+
return 3.75;
44+
default:
45+
return 25;
46+
}
47+
}
48+
49+
public function getDrops(Item $item){
50+
return [];
51+
}
52+
}

src/pocketmine/block/Mycelium.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
namespace pocketmine\block;
23+
24+
use pocketmine\item\Item;
25+
26+
class Mycelium extends Solid{
27+
public function __construct(){
28+
parent::__construct(self::MYCELIUM, 0, "Mycelium");
29+
$this->hardness = 2.5;
30+
}
31+
32+
public function getDrops(Item $item){
33+
return [
34+
[Item::DIRT, 0, 1],
35+
];
36+
}
37+
38+
public function onUpdate($type){
39+
if($type === Level::BLOCK_UPDATE_RANDOM){
40+
//TODO: light levels
41+
$x = mt_rand($this->x - 1, $this->x + 1);
42+
$y = mt_rand($this->y - 2, $this->y + 2);
43+
$z = mt_rand($this->z - 1, $this->z + 1);
44+
$block = $this->getLevel()->getBlockIdAt($x, $y, $z);
45+
if($block === Block::DIRT){
46+
$block = $this->getLevel()->getBlock(new Vector3($x, $y, $z));
47+
if($block->getSide(1) instanceof Transparent){
48+
$this->getLevel()->setBlock($block, new Mycelium());
49+
}
50+
}
51+
}
52+
}
53+
}

src/pocketmine/block/Podzol.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
*
5+
* ____ _ _ __ __ _ __ __ ____
6+
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7+
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8+
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9+
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Lesser General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* @author PocketMine Team
17+
* @link http://www.pocketmine.net/
18+
*
19+
*
20+
*/
21+
22+
namespace pocketmine\block;
23+
24+
use pocketmine\item\Item;
25+
26+
class Podzol extends Solid{
27+
public function __construct(){
28+
parent::__construct(self::PODZOL, 0, "Podzol");
29+
$this->hardness = 2.5;
30+
}
31+
}

src/pocketmine/item/Item.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class Item{
9595
const OBSIDIAN = 49;
9696
const TORCH = 50;
9797
const FIRE = 51;
98-
98+
const MONSTER_SPAWNER = 52;
9999
const WOOD_STAIRS = 53;
100100
const WOODEN_STAIRS = 53;
101101
const OAK_WOOD_STAIRS = 53;
@@ -164,12 +164,16 @@ class Item{
164164
const FENCE_GATE = 107;
165165
const BRICK_STAIRS = 108;
166166
const STONE_BRICK_STAIRS = 109;
167+
const MYCELIUM = 110;
167168

168169
const NETHER_BRICKS = 112;
169170
const NETHER_BRICK_BLOCK = 112;
170171

171172
const NETHER_BRICKS_STAIRS = 114;
172173

174+
const END_PORTAL = 120;
175+
const END_STONE = 121;
176+
173177
const SANDSTONE_STAIRS = 128;
174178
const EMERALD_ORE = 129;
175179

@@ -216,6 +220,7 @@ class Item{
216220
const HARDENED_CLAY = 172;
217221
const COAL_BLOCK = 173;
218222

223+
const PODZOL = 243;
219224
const BEETROOT_BLOCK = 244;
220225
const STONECUTTER = 245;
221226
const GLOWING_OBSIDIAN = 246;
@@ -620,4 +625,4 @@ public final function equals(Item $item, $checkDamage = false){
620625
return $this->id === $item->getID() and ($checkDamage === false or $this->getDamage() === $item->getDamage());
621626
}
622627

623-
}
628+
}

0 commit comments

Comments
 (0)