From e91781cbf2a03c5ad95eafbe4ed81d07219289ec Mon Sep 17 00:00:00 2001 From: Intyre Date: Sun, 17 Aug 2014 02:00:17 +0200 Subject: [PATCH 1/3] EndPortal, EndStone, MonsterSpawner, Mycelium and Podzol blocks added --- src/pocketmine/block/Block.php | 24 +++++++++++++------ src/pocketmine/block/EndPortal.php | 31 +++++++++++++++++++++++++ src/pocketmine/block/EndStone.php | 31 +++++++++++++++++++++++++ src/pocketmine/block/MonsterSpawner.php | 31 +++++++++++++++++++++++++ src/pocketmine/block/Mycelium.php | 31 +++++++++++++++++++++++++ src/pocketmine/block/Podzol.php | 31 +++++++++++++++++++++++++ src/pocketmine/item/Item.php | 9 +++++-- 7 files changed, 179 insertions(+), 9 deletions(-) create mode 100644 src/pocketmine/block/EndPortal.php create mode 100644 src/pocketmine/block/EndStone.php create mode 100644 src/pocketmine/block/MonsterSpawner.php create mode 100644 src/pocketmine/block/Mycelium.php create mode 100644 src/pocketmine/block/Podzol.php diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index c49771dc2..23a271806 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -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; @@ -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; @@ -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; @@ -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], @@ -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], @@ -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 @@ -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], @@ -565,7 +571,7 @@ abstract class Block extends Position implements Metadatable{ 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(), @@ -617,10 +623,13 @@ abstract class Block extends Position implements Metadatable{ 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(), @@ -649,6 +658,7 @@ abstract class Block extends Position implements Metadatable{ 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(), @@ -893,4 +903,4 @@ abstract class Block extends Position implements Metadatable{ $this->getLevel()->getBlockMetadata()->removeMetadata($this, $metadataKey, $plugin); } } -} +} \ No newline at end of file diff --git a/src/pocketmine/block/EndPortal.php b/src/pocketmine/block/EndPortal.php new file mode 100644 index 000000000..593e9f21a --- /dev/null +++ b/src/pocketmine/block/EndPortal.php @@ -0,0 +1,31 @@ +hardness = 18000000; + } +} \ No newline at end of file diff --git a/src/pocketmine/block/EndStone.php b/src/pocketmine/block/EndStone.php new file mode 100644 index 000000000..08499caf1 --- /dev/null +++ b/src/pocketmine/block/EndStone.php @@ -0,0 +1,31 @@ +hardness = 45; + } +} \ No newline at end of file diff --git a/src/pocketmine/block/MonsterSpawner.php b/src/pocketmine/block/MonsterSpawner.php new file mode 100644 index 000000000..1babe0bb7 --- /dev/null +++ b/src/pocketmine/block/MonsterSpawner.php @@ -0,0 +1,31 @@ +hardness = 25; + } +} \ No newline at end of file diff --git a/src/pocketmine/block/Mycelium.php b/src/pocketmine/block/Mycelium.php new file mode 100644 index 000000000..cecdb30a7 --- /dev/null +++ b/src/pocketmine/block/Mycelium.php @@ -0,0 +1,31 @@ +hardness = 2.5; + } +} \ No newline at end of file diff --git a/src/pocketmine/block/Podzol.php b/src/pocketmine/block/Podzol.php new file mode 100644 index 000000000..47d557045 --- /dev/null +++ b/src/pocketmine/block/Podzol.php @@ -0,0 +1,31 @@ +hardness = 2.5; + } +} \ No newline at end of file diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index d47cae100..4d6a53e76 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -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; @@ -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; @@ -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; @@ -620,4 +625,4 @@ class Item{ return $this->id === $item->getID() and ($checkDamage === false or $this->getDamage() === $item->getDamage()); } -} +} \ No newline at end of file From 532b12c6c0af73ad47a8e8c5c29741da047b9c31 Mon Sep 17 00:00:00 2001 From: Intyre Date: Mon, 18 Aug 2014 20:06:18 +0200 Subject: [PATCH 2/3] Mycelium spreads like grass and MonsterSpawner breaktime added --- src/pocketmine/block/MonsterSpawner.php | 21 +++++++++++++++++++++ src/pocketmine/block/Mycelium.php | 22 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/pocketmine/block/MonsterSpawner.php b/src/pocketmine/block/MonsterSpawner.php index 1babe0bb7..54dc91b25 100644 --- a/src/pocketmine/block/MonsterSpawner.php +++ b/src/pocketmine/block/MonsterSpawner.php @@ -28,4 +28,25 @@ class MonsterSpawner extends Solid{ 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 []; + } } \ No newline at end of file diff --git a/src/pocketmine/block/Mycelium.php b/src/pocketmine/block/Mycelium.php index cecdb30a7..2d9389a30 100644 --- a/src/pocketmine/block/Mycelium.php +++ b/src/pocketmine/block/Mycelium.php @@ -28,4 +28,26 @@ class Mycelium extends Solid{ 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()); + } + } + } + } } \ No newline at end of file From ecc9e1d223cfdced03f50d86b0fdf7cddaf2a5a1 Mon Sep 17 00:00:00 2001 From: Intyre Date: Thu, 21 Aug 2014 19:26:41 +0200 Subject: [PATCH 3/3] EndPortal meta and Endstone breaktime --- src/pocketmine/block/EndPortal.php | 4 ++-- src/pocketmine/block/EndStone.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/block/EndPortal.php b/src/pocketmine/block/EndPortal.php index 593e9f21a..9af0c9016 100644 --- a/src/pocketmine/block/EndPortal.php +++ b/src/pocketmine/block/EndPortal.php @@ -24,8 +24,8 @@ namespace pocketmine\block; use pocketmine\item\Item; class EndPortal extends Solid{ - public function __construct(){ - parent::__construct(self::END_PORTAL, 0, "End Portal"); + public function __construct($meta = 0){ + parent::__construct(self::END_PORTAL, $meta, "End Portal"); $this->hardness = 18000000; } } \ No newline at end of file diff --git a/src/pocketmine/block/EndStone.php b/src/pocketmine/block/EndStone.php index 08499caf1..42d887702 100644 --- a/src/pocketmine/block/EndStone.php +++ b/src/pocketmine/block/EndStone.php @@ -28,4 +28,21 @@ class EndStone extends Solid{ 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; + } + } } \ No newline at end of file