From 47b54cfd28c03c635c16805b6e1429fccdc0bd2c Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Mon, 20 May 2013 16:33:09 +0200 Subject: [PATCH] Fixed #270 Blocks that need to be broken with a pickaxe now give correct drops & items --- src/API/BlockAPI.php | 5 ++- src/material/Block.php | 2 +- src/material/Item.php | 10 +++--- src/material/block/StairBlock.php | 10 ++++-- src/material/block/ore/CoalOre.php | 22 ++++++++++++- src/material/block/ore/DiamondOre.php | 20 +++++++++-- src/material/block/ore/GlowingRedstoneOre.php | 17 +++++++++- src/material/block/ore/GoldOre.php | 23 +++++++++++++ src/material/block/ore/IronOre.php | 25 ++++++++++++++ src/material/block/ore/LapisOre.php | 20 +++++++++-- src/material/block/solid/Bricks.php | 29 ++++++++++++++++ src/material/block/solid/BurningFurnace.php | 20 +++++++++++ src/material/block/solid/Cobblestone.php | 29 ++++++++++++++++ src/material/block/solid/Diamond.php | 23 +++++++++++++ src/material/block/solid/DoubleSlab.php | 31 +++++++++++++++-- src/material/block/solid/Furnace.php | 1 - src/material/block/solid/Gold.php | 23 +++++++++++++ src/material/block/solid/Ice.php | 23 +++++++++++++ src/material/block/solid/Iron.php | 25 ++++++++++++++ src/material/block/solid/IronDoor.php | 33 ++++++++++++++++--- src/material/block/solid/Lapis.php | 26 +++++++++++++++ src/material/block/solid/MossStone.php | 29 ++++++++++++++++ src/material/block/solid/NetherBrick.php | 29 ++++++++++++++++ src/material/block/solid/Netherrack.php | 29 ++++++++++++++++ src/material/block/solid/Obsidian.php | 21 ++++++++++++ src/material/block/solid/Quartz.php | 29 ++++++++++++++++ src/material/block/solid/Sandstone.php | 30 +++++++++++++++++ src/material/block/solid/Slab.php | 33 ++++++++++++++++--- src/material/block/solid/Stone.php | 20 +++++++++++ src/material/block/solid/StoneBricks.php | 30 +++++++++++++++++ 30 files changed, 636 insertions(+), 31 deletions(-) diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 0059c4d6f..07f1a060e 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -266,13 +266,12 @@ class BlockAPI{ return $this->cancelAction($target, $player); } - if((!$target->isBreakable($item, $player) and $this->server->api->dhandle("player.block.break.invalid", array("player" => $player, "target" => $target, "item" => $item)) !== true) or ($player->gamemode & 0x02) === 0x02 or ($player->lastBreak + $target->getBreakTime($item, $player)) >= microtime(true)){ + if((!$target->isBreakable($item, $player) and $this->server->api->dhandle("player.block.break.invalid", array("player" => $player, "target" => $target, "item" => $item)) !== true) or ($player->gamemode & 0x02) === 0x02 or (($player->lastBreak - 0.02) + $target->getBreakTime($item, $player)) >= microtime(true)){ return $this->cancelAction($target, $player); } - + $player->lastBreak = microtime(true); if($this->server->api->dhandle("player.block.break", array("player" => $player, "target" => $target, "item" => $item)) !== false){ - $player->lastBreak = microtime(true); $drops = $target->getDrops($item, $player); $target->onBreak($item, $player); }else{ diff --git a/src/material/Block.php b/src/material/Block.php index c8b3b4adc..b0cde019b 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -188,7 +188,7 @@ abstract class Block extends Position{ public function getBreakTime(Item $item, Player $player){ if(($player->gamemode & 0x01) === 0x01){ - return 0.25; + return 0.20; } return $this->breakTime; } diff --git a/src/material/Item.php b/src/material/Item.php index 99b588d0e..2b70618ac 100644 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -108,15 +108,15 @@ class Item{ final public function isPickaxe(){ //Returns false or level of the pickaxe switch($this->id){ case IRON_PICKAXE: - return 3; + return 4; case WOODEN_PICKAXE: return 1; case STONE_PICKAXE: - return 2; - case DIAMOND_PICKAXE: - return 4; - case GOLD_PICKAXE: return 3; + case DIAMOND_PICKAXE: + return 5; + case GOLD_PICKAXE: + return 2; default: return false; } diff --git a/src/material/block/StairBlock.php b/src/material/block/StairBlock.php index b4bb4c10b..f1db2e913 100644 --- a/src/material/block/StairBlock.php +++ b/src/material/block/StairBlock.php @@ -46,8 +46,12 @@ class StairBlock extends TransparentBlock{ } public function getDrops(Item $item, Player $player){ - return array( - array($this->id, 0, 1), - ); + if($item->isPickaxe() >= 1){ + return array( + array($this->id, 0, 1), + ); + }else{ + return array(); + } } } \ No newline at end of file diff --git a/src/material/block/ore/CoalOre.php b/src/material/block/ore/CoalOre.php index adbad8053..980d7450d 100644 --- a/src/material/block/ore/CoalOre.php +++ b/src/material/block/ore/CoalOre.php @@ -30,10 +30,30 @@ class CoalOreBlock extends SolidBlock{ parent::__construct(COAL_ORE, 0, "Coal Ore"); } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + 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; + } + } + public function getDrops(Item $item, Player $player){ if($item->isPickaxe() >= 1){ return array( - array(263, 0, 1), //Coal + array(COAL, 0, 1), ); }else{ return array(); diff --git a/src/material/block/ore/DiamondOre.php b/src/material/block/ore/DiamondOre.php index 5178c1244..539dd59e3 100644 --- a/src/material/block/ore/DiamondOre.php +++ b/src/material/block/ore/DiamondOre.php @@ -30,13 +30,27 @@ class DiamondOreBlock extends SolidBlock{ parent::__construct(DIAMOND_ORE, 0, "Diamond Ore"); } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.6; + case 4: + return 0.75; + default: + return 15; + } + } + public function getDrops(Item $item, Player $player){ - if($item->isPickaxe() >= 3){ + if($item->isPickaxe() >= 4){ return array( - array(264, 0, 1), + array(DIAMOND, 0, 1), ); }else{ return array(); } - } + } } \ No newline at end of file diff --git a/src/material/block/ore/GlowingRedstoneOre.php b/src/material/block/ore/GlowingRedstoneOre.php index a9c787dcc..dea47a597 100644 --- a/src/material/block/ore/GlowingRedstoneOre.php +++ b/src/material/block/ore/GlowingRedstoneOre.php @@ -40,8 +40,23 @@ class GlowingRedstoneOreBlock extends SolidBlock{ return false; } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.6; + case 4: + return 0.75; + default: + return 15; + } + } + public function getDrops(Item $item, Player $player){ - if($item->isPickaxe() >= 2){ + if($item->isPickaxe() >= 4){ return array( //array(331, 4, mt_rand(4, 5)), ); diff --git a/src/material/block/ore/GoldOre.php b/src/material/block/ore/GoldOre.php index 955b4b52d..6d301fd0b 100644 --- a/src/material/block/ore/GoldOre.php +++ b/src/material/block/ore/GoldOre.php @@ -29,5 +29,28 @@ class GoldOreBlock extends SolidBlock{ public function __construct(){ parent::__construct(GOLD_ORE, 0, "Gold Ore"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.6; + case 4: + return 0.75; + default: + return 15; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 4){ + return array( + array(GOLD_ORE, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/ore/IronOre.php b/src/material/block/ore/IronOre.php index 4db3c7604..56111456a 100644 --- a/src/material/block/ore/IronOre.php +++ b/src/material/block/ore/IronOre.php @@ -29,5 +29,30 @@ class IronOreBlock extends SolidBlock{ public function __construct(){ parent::__construct(IRON_ORE, 0, "Iron Ore"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.6; + case 4: + return 0.75; + case 3: + return 1.15; + default: + return 15; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 3){ + return array( + array(IRON_ORE, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/ore/LapisOre.php b/src/material/block/ore/LapisOre.php index fa32e9549..67d925027 100644 --- a/src/material/block/ore/LapisOre.php +++ b/src/material/block/ore/LapisOre.php @@ -30,10 +30,26 @@ class LapisOreBlock extends SolidBlock{ parent::__construct(LAPIS_ORE, 0, "Lapis Ore"); } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.6; + case 4: + return 0.75; + case 3: + return 1.15; + default: + return 15; + } + } + public function getDrops(Item $item, Player $player){ - if($item->isPickaxe() >= 2){ + if($item->isPickaxe() >= 3){ return array( - array(351, 4, mt_rand(4, 8)), + array(DYE, 4, mt_rand(4, 8)), ); }else{ return array(); diff --git a/src/material/block/solid/Bricks.php b/src/material/block/solid/Bricks.php index 6dc76032d..dec487be7 100644 --- a/src/material/block/solid/Bricks.php +++ b/src/material/block/solid/Bricks.php @@ -29,5 +29,34 @@ class BricksBlock extends SolidBlock{ public function __construct(){ parent::__construct(BRICKS_BLOCK, 0, "Bricks"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.4; + case 4: + return 0.5; + case 3: + return 0.75; + case 2: + return 0.25; + case 1: + return 1.5; + default: + return 10; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(BRICKS_BLOCK, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/BurningFurnace.php b/src/material/block/solid/BurningFurnace.php index 1747a8aa3..03e8ab0aa 100644 --- a/src/material/block/solid/BurningFurnace.php +++ b/src/material/block/solid/BurningFurnace.php @@ -110,6 +110,26 @@ class BurningFurnaceBlock extends SolidBlock{ return true; } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.7; + case 4: + return 0.9; + case 3: + return 1.35; + case 2: + return 0.45; + case 1: + return 2.65; + default: + return 17.5; + } + } + public function getDrops(Item $item, Player $player){ if($item->isPickaxe() >= 1){ return array( diff --git a/src/material/block/solid/Cobblestone.php b/src/material/block/solid/Cobblestone.php index 98c0c4668..b14d29248 100644 --- a/src/material/block/solid/Cobblestone.php +++ b/src/material/block/solid/Cobblestone.php @@ -29,5 +29,34 @@ class CobblestoneBlock extends SolidBlock{ public function __construct(){ parent::__construct(COBBLESTONE, 0, "Cobblestone"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.4; + case 4: + return 0.5; + case 3: + return 0.75; + case 2: + return 0.25; + case 1: + return 1.5; + default: + return 10; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(COBBLESTONE, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/Diamond.php b/src/material/block/solid/Diamond.php index 2fe26e77e..26026364e 100644 --- a/src/material/block/solid/Diamond.php +++ b/src/material/block/solid/Diamond.php @@ -30,4 +30,27 @@ class DiamondBlock extends SolidBlock{ parent::__construct(DIAMOND_BLOCK, 0, "Diamond Block"); } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.95; + case 4: + return 1.25; + default: + return 25; + } + } + + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 4){ + return array( + array(DIAMOND_BLOCK, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/DoubleSlab.php b/src/material/block/solid/DoubleSlab.php index 136ba9224..d154cf9e1 100644 --- a/src/material/block/solid/DoubleSlab.php +++ b/src/material/block/solid/DoubleSlab.php @@ -40,10 +40,35 @@ class DoubleSlabBlock extends SolidBlock{ ); $this->name = "Double " . $names[$this->meta & 0x07] . " Slab"; } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.4; + case 4: + return 0.5; + case 3: + return 0.75; + case 2: + return 0.25; + case 1: + return 1.5; + default: + return 10; + } + } + public function getDrops(Item $item, Player $player){ - return array( - array(SLAB, $this->meta & 0x07, 2), - ); + if($item->isPickaxe() >= 1){ + return array( + array(SLAB, $this->meta & 0x07, 2), + ); + }else{ + return array(); + } } } \ No newline at end of file diff --git a/src/material/block/solid/Furnace.php b/src/material/block/solid/Furnace.php index 4cac0daf8..93e9f44eb 100644 --- a/src/material/block/solid/Furnace.php +++ b/src/material/block/solid/Furnace.php @@ -37,5 +37,4 @@ class FurnaceBlock extends BurningFurnaceBlock{ $this->name = "Furnace"; $this->isActivable = true; } - } \ No newline at end of file diff --git a/src/material/block/solid/Gold.php b/src/material/block/solid/Gold.php index 6402e4ea3..7684ca629 100644 --- a/src/material/block/solid/Gold.php +++ b/src/material/block/solid/Gold.php @@ -29,5 +29,28 @@ class GoldBlock extends SolidBlock{ public function __construct(){ parent::__construct(GOLD_BLOCK, 0, "Gold Block"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.6; + case 4: + return 0.75; + default: + return 15; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 4){ + return array( + array(GOLD_BLOCK, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/Ice.php b/src/material/block/solid/Ice.php index afc534598..8daae7e3c 100644 --- a/src/material/block/solid/Ice.php +++ b/src/material/block/solid/Ice.php @@ -30,4 +30,27 @@ class IceBlock extends TransparentBlock{ parent::__construct(ICE, 0, "Ice"); } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.1; + case 4: + return 0.15; + case 3: + return 0.2; + case 2: + return 0.1; + case 1: + return 0.4; + default: + return 0.75; + } + } + + public function getDrops(Item $item, Player $player){ + return array(); + } } \ No newline at end of file diff --git a/src/material/block/solid/Iron.php b/src/material/block/solid/Iron.php index 3a25b0d0b..64aef0ffd 100644 --- a/src/material/block/solid/Iron.php +++ b/src/material/block/solid/Iron.php @@ -29,5 +29,30 @@ class IronBlock extends SolidBlock{ public function __construct(){ parent::__construct(IRON_BLOCK, 0, "Iron Block"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.95; + case 4: + return 1.25; + case 3: + return 1.9; + default: + return 25; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 3){ + return array( + array(IRON_BLOCK, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/IronDoor.php b/src/material/block/solid/IronDoor.php index 0fbde94a3..6706deecc 100644 --- a/src/material/block/solid/IronDoor.php +++ b/src/material/block/solid/IronDoor.php @@ -30,9 +30,34 @@ class IronDoorBlock extends DoorBlock{ parent::__construct(IRON_DOOR_BLOCK, $meta, "Iron Door Block"); //$this->isActivable = true; } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + 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, Player $player){ - return array( - array(IRON_DOOR, 0, 1), - ); - } + if($item->isPickaxe() >= 1){ + return array( + array(IRON_DOOR, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/Lapis.php b/src/material/block/solid/Lapis.php index e58e0d26a..7b2499d4a 100644 --- a/src/material/block/solid/Lapis.php +++ b/src/material/block/solid/Lapis.php @@ -29,5 +29,31 @@ class LapisBlock extends SolidBlock{ public function __construct(){ parent::__construct(LAPIS_BLOCK, 0, "Lapis Block"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.6; + case 4: + return 0.75; + case 3: + return 1.15; + default: + return 15; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 3){ + return array( + array(LAPIS_BLOCK, 0, 1), + ); + }else{ + return array(); + } + } + } \ No newline at end of file diff --git a/src/material/block/solid/MossStone.php b/src/material/block/solid/MossStone.php index 888c714eb..538554a63 100644 --- a/src/material/block/solid/MossStone.php +++ b/src/material/block/solid/MossStone.php @@ -29,5 +29,34 @@ class MossStoneBlock extends SolidBlock{ public function __construct(){ parent::__construct(MOSS_STONE, 0, "Moss Stone"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.4; + case 4: + return 0.5; + case 3: + return 0.75; + case 2: + return 0.25; + case 1: + return 1.5; + default: + return 10; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(MOSS_STONE, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/NetherBrick.php b/src/material/block/solid/NetherBrick.php index 659f3431b..a2b186af0 100644 --- a/src/material/block/solid/NetherBrick.php +++ b/src/material/block/solid/NetherBrick.php @@ -29,5 +29,34 @@ class NetherBricksBlock extends SolidBlock{ public function __construct(){ parent::__construct(NETHER_BRICKS, 0, "Nether Bricks"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.4; + case 4: + return 0.5; + case 3: + return 0.75; + case 2: + return 0.25; + case 1: + return 1.5; + default: + return 10; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(NETHER_BRICKS, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/Netherrack.php b/src/material/block/solid/Netherrack.php index 062d563aa..92e9bf54d 100644 --- a/src/material/block/solid/Netherrack.php +++ b/src/material/block/solid/Netherrack.php @@ -30,4 +30,33 @@ class NetherrackBlock extends SolidBlock{ parent::__construct(NETHERRACK, 0, "Netherrack"); } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.1; + case 4: + return 0.1; + case 3: + return 0.15; + case 2: + return 0.05; + case 1: + return 0.3; + default: + return 2; + } + } + + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(NETHERRACK, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/Obsidian.php b/src/material/block/solid/Obsidian.php index 7707ca0b7..6d973d4f9 100644 --- a/src/material/block/solid/Obsidian.php +++ b/src/material/block/solid/Obsidian.php @@ -28,6 +28,27 @@ the Free Software Foundation, either version 3 of the License, or class ObsidianBlock extends SolidBlock{ public function __construct(){ parent::__construct(OBSIDIAN, 0, "Obsidian"); + } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + if($item->isPickaxe() >= 5){ + return 9.4; + }else{ + return 250; + } + } + + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 5){ + return array( + array(OBSIDIAN, 0, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/Quartz.php b/src/material/block/solid/Quartz.php index 33e2acab0..429dab9f1 100644 --- a/src/material/block/solid/Quartz.php +++ b/src/material/block/solid/Quartz.php @@ -36,5 +36,34 @@ class QuartzBlock extends SolidBlock{ ); $this->name = $names[$this->meta & 0x03]; } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.15; + case 4: + return 0.2; + case 3: + return 0.3; + case 2: + return 0.1; + case 1: + return 0.6; + default: + return 4; + } + } + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(QUARTZ_BLOCK, $this->meta & 0x03, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/Sandstone.php b/src/material/block/solid/Sandstone.php index 76fcfafb6..18324feb7 100644 --- a/src/material/block/solid/Sandstone.php +++ b/src/material/block/solid/Sandstone.php @@ -36,4 +36,34 @@ class SandstoneBlock extends SolidBlock{ $this->name = $names[$this->meta & 0x03]; } + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.15; + case 4: + return 0.2; + case 3: + return 0.3; + case 2: + return 0.1; + case 1: + return 0.6; + default: + return 4; + } + } + + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(SANDSTONE, $this->meta & 0x03, 1), + ); + }else{ + return array(); + } + } + } \ No newline at end of file diff --git a/src/material/block/solid/Slab.php b/src/material/block/solid/Slab.php index ec1970868..78520575c 100644 --- a/src/material/block/solid/Slab.php +++ b/src/material/block/solid/Slab.php @@ -76,9 +76,34 @@ class SlabBlock extends TransparentBlock{ $this->level->setBlock($block, $this); return true; } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.4; + case 4: + return 0.5; + case 3: + return 0.75; + case 2: + return 0.25; + case 1: + return 1.5; + default: + return 10; + } + } + public function getDrops(Item $item, Player $player){ - return array( - array($this->id, $this->meta & 0x07, 1), - ); - } + if($item->isPickaxe() >= 1){ + return array( + array($this->id, $this->meta & 0x07, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file diff --git a/src/material/block/solid/Stone.php b/src/material/block/solid/Stone.php index d789babf6..d26fe91f4 100644 --- a/src/material/block/solid/Stone.php +++ b/src/material/block/solid/Stone.php @@ -29,6 +29,26 @@ class StoneBlock extends SolidBlock{ public function __construct(){ parent::__construct(STONE, 0, "Stone"); } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.4; + case 4: + return 0.5; + case 3: + return 0.75; + case 2: + return 0.25; + case 1: + return 1.5; + default: + return 7.5; + } + } public function getDrops(Item $item, Player $player){ if($item->isPickaxe() >= 1){ diff --git a/src/material/block/solid/StoneBricks.php b/src/material/block/solid/StoneBricks.php index 9026bc434..2ac0be86d 100644 --- a/src/material/block/solid/StoneBricks.php +++ b/src/material/block/solid/StoneBricks.php @@ -36,5 +36,35 @@ class StoneBricksBlock extends SolidBlock{ ); $this->name = $names[$this->meta & 0x03]; } + + public function getBreakTime(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return 0.20; + } + switch($item->isPickaxe()){ + case 5: + return 0.4; + case 4: + return 0.5; + case 3: + return 0.75; + case 2: + return 0.25; + case 1: + return 1.5; + default: + return 7.5; + } + } + + public function getDrops(Item $item, Player $player){ + if($item->isPickaxe() >= 1){ + return array( + array(STONE_BRICKS, $this->meta & 0x03, 1), + ); + }else{ + return array(); + } + } } \ No newline at end of file