diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 9e53682d..3ed109b8 100755 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -69,6 +69,8 @@ class BlockAPI{ [OBSIDIAN, 0], [ICE, 0], [SNOW_BLOCK, 0], + [BROWN_MUSHROOM_BLOCK, 0], + [RED_MUSHROOM_BLOCK, 0], //Decoration [COBBLESTONE_WALL, 0], @@ -165,6 +167,7 @@ class BlockAPI{ [CARPET, 9], [CARPET, 8], [END_PORTAL_FRAME, 0], + [MONSTER_SPAWNER, 0], //Tools [RAIL, 0], diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 01248b7c..f3725b72 100755 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -173,8 +173,8 @@ define("TRAPDOOR", 96); define("STONE_BRICKS", 98); define("STONE_BRICK", 98); //ANOTHER STONE BRICKS -define("HUGE_BROWN_MUSHROOM", 99); -define("HUGE_RED_MUSHROOM", 100); +define("BROWN_MUSHROOM_BLOCK", 99); +define("RED_MUSHROOM_BLOCK", 100); define("IRON_BAR", 101); define("IRON_BARS", 101); define("GLASS_PANE", 102); @@ -211,7 +211,7 @@ define("JUNGLE_WOODEN_STAIRS", 136); define("COBBLE_WALL", 139); define("STONE_WALL", 139); define("COBBLESTONE_WALL", 139); -//MOSSY STONE WALL? +define("MOSSY_COBBLESTONE_WALL", "139:1"); define("CARROT_BLOCK", 141); define("POTATO_BLOCK", 142); diff --git a/src/material/Block.php b/src/material/Block.php index 143db859..942d0b08 100755 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -142,6 +142,10 @@ abstract class Block extends Position{ LOG2 => "Log2Block", LEAVES2 => "Leaves2Block", END_PORTAL_FRAME => "EndPortalFrameBlock", + COCOA => "CocoaBlock", + RED_MUSHROOM_BLOCK => "RedMushroomSolidBlock", + BROWN_MUSHROOM_BLOCK => "BrownMushroomSolidBlock", + MONSTER_SPAWNER => "MonsterSpawnerBlock", ); protected $id; protected $meta; diff --git a/src/material/block/attachable/LadderBlock.php b/src/material/block/attachable/LadderBlock.php index 9b3f939a..a4386336 100644 --- a/src/material/block/attachable/LadderBlock.php +++ b/src/material/block/attachable/LadderBlock.php @@ -7,6 +7,7 @@ class LadderBlock extends TransparentBlock{ $this->isFullBlock = false; $this->hardness = 2; } + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($face === 0 || $face === 1){ return false; //fix of placing invalid ids without array @@ -20,7 +21,6 @@ class LadderBlock extends TransparentBlock{ } public function onUpdate($type){ - if($type === BLOCK_UPDATE_NORMAL){ $side = $this->getMetadata(); $faces = array( //magical tranformation diff --git a/src/material/block/nonfull/StoneWallBlock.php b/src/material/block/nonfull/StoneWallBlock.php index 1629f2d4..1856ecaa 100644 --- a/src/material/block/nonfull/StoneWallBlock.php +++ b/src/material/block/nonfull/StoneWallBlock.php @@ -2,14 +2,15 @@ class StoneWallBlock extends TransparentBlock{ public function __construct($meta = 0){ - parent::__construct(STONE_WALL, $meta & 0x01, $meta === 1 ? "Mossy Cobblestone Wall" : "Cobblestone Wall"); + parent::__construct(COBBLESTONE_WALL, $meta & 0x01, $meta === 1 ? "Mossy Cobblestone Wall" : "Cobblestone Wall"); $this->isFullBlock = false; $this->isSolid = false; $this->hardness = 30; } + public function getDrops(Item $item, Player $player){ if($item->isPickaxe()){ - return [[STONE_WALL, $this->getMetadata(),1]]; + return [[COBBLESTONE_WALL, $this->getMetadata(), 1]]; } return []; } diff --git a/src/material/block/plant/CocoaBlock.php b/src/material/block/plant/CocoaBlock.php new file mode 100644 index 00000000..5e055529 --- /dev/null +++ b/src/material/block/plant/CocoaBlock.php @@ -0,0 +1,71 @@ +isActivable = true; + $this->hardness = 0; + } + + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + if($target->getID() === WOOD and ($target->getMetadata() & 0x03) === 0x03){ + //$this->meta = $face; + $this->level->setBlock($block, $this, true, false, true); + return true; + } + return false; + } + + public function onActivate(Item $item, Player $player){ + if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal + $this->meta++; + if($this->meta > 0x02){ + $this->meta = 0x02; + } + $this->level->setBlock($this, $this, true, false, true); + if(($player->gamemode & 0x01) === 0){ + $player->removeItem(DYE, 0x0F, 1); + } + return true; + } + return false; + } + + public function onUpdate($type){ + if($type === BLOCK_UPDATE_NORMAL){ + /*$side = $this->getMetadata(); + $faces = array( //magical tranformation + 3 => 2, + 2 => 3, + 5 => 4, + 4 => 5, + ); + if($this->getSide($faces[$side]) instanceof AirBlock){ //Replace with common break method + ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1)); + $this->level->setBlock($this, new AirBlock(), true, false, true); + return BLOCK_UPDATE_NORMAL; + }*/ + }elseif($type === BLOCK_UPDATE_RANDOM){ + if(mt_rand(0, 2) == 1){ + if($this->meta < 0x03){ + ++$this->meta; + $this->level->setBlock($this, $this, true, false, true); + return BLOCK_UPDATE_RANDOM; + } + }else{ + return BLOCK_UPDATE_RANDOM; + } + } + return false; + } + + public function getDrops(Item $item, Player $player){ + $drops = []; + if($this->meta >= 0x02){ + $drops[] = [DYE, 3, mt_rand(1, 4)]; + }else{ + $drops[] = [DYE, 3, 1]; + } + return $drops; + } +} \ No newline at end of file diff --git a/src/material/block/solid/BrownMushroomBlock.php b/src/material/block/solid/BrownMushroomBlock.php new file mode 100644 index 00000000..dbbd1750 --- /dev/null +++ b/src/material/block/solid/BrownMushroomBlock.php @@ -0,0 +1,19 @@ +hardness = 0.2; + } + + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + //todo + $this->level->setBlock($this, $this, true, false, true); + } + + public function getDrops(Item $item, Player $player){ + return [ + [BROWN_MUSHROOM, 0, mt_rand(0, 2)] + ]; + } +} \ No newline at end of file diff --git a/src/material/block/solid/Leaves2.php b/src/material/block/solid/Leaves2Block.php similarity index 100% rename from src/material/block/solid/Leaves2.php rename to src/material/block/solid/Leaves2Block.php diff --git a/src/material/block/solid/Log2.php b/src/material/block/solid/Log2Block.php similarity index 100% rename from src/material/block/solid/Log2.php rename to src/material/block/solid/Log2Block.php diff --git a/src/material/block/solid/MonsterSpawnerBlock.php b/src/material/block/solid/MonsterSpawnerBlock.php new file mode 100644 index 00000000..11ac5c3e --- /dev/null +++ b/src/material/block/solid/MonsterSpawnerBlock.php @@ -0,0 +1,12 @@ +hardness = 5; + } + + public function getDrops(Item $item, Player $player){ + return []; + } +} \ No newline at end of file diff --git a/src/material/block/solid/RedMushroomBlock.php b/src/material/block/solid/RedMushroomBlock.php new file mode 100644 index 00000000..88b45801 --- /dev/null +++ b/src/material/block/solid/RedMushroomBlock.php @@ -0,0 +1,19 @@ +hardness = 0.2; + } + + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + //todo + $this->level->setBlock($this, $this, true, false, true); + } + + public function getDrops(Item $item, Player $player){ + return [ + [RED_MUSHROOM, 0, mt_rand(0, 2)] + ]; + } +} \ No newline at end of file