diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 0033c89a..ea9cc5f2 100755 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -402,13 +402,37 @@ class BlockAPI{ return $this->cancelAction($target, $player, false); } } - - if((!$target->isBreakable($item, $player) and $this->server->api->dhandle("player.block.break.invalid", ["player" => $player, "target" => $target, "item" => $item]) !== true) or ($player->gamemode & 0x02) === 0x02 or (($player->lastBreak - $player->getLag() / 1000) + $target->getBreakTime($item, $player) - 0.2) >= microtime(true)){ + + $currentTime = microtime(true); + $isIndestructible = (!$target->isBreakable($item, $player) && $this->server->api->dhandle("player.block.break.invalid", ["player" => $player, "target" => $target, "item" => $item]) !== true); + $isAdventure = ($player->gamemode & 0x02) === 0x02; + $progress = $target->getDestroyProgress($player); + + $tooFast = false; + if($progress == 0 || is_nan($progress)){ + $exceptedTimeMS = INF; + $tooFast = true; + }else{ + $exceptedTimeMS = ceil(1 / $progress)*0.05; + + } + + if($player->gamemode == 1){ //creative + $exceptedTimeMS = 0.05; //1 block/tick + $tooFast = false; + } + + $exceptedTimeAfter = $player->lastBreak + $exceptedTimeMS; + if($currentTime < $exceptedTimeAfter) $tooFast = true; + if($isIndestructible || $isAdventure || $tooFast){ if($this->server->api->dhandle("player.block.break.bypass", ["player" => $player, "target" => $target, "item" => $item]) !== true){ + if($tooFast){ + ConsoleAPI::warn("{$player->username} tried destroying block({$target->getID()} {$target->getMetadata()}) too fast($currentTime < $exceptedTimeAfter)"); + } return $this->cancelAction($target, $player, false); } } - $player->lastBreak = microtime(true); + $player->lastBreak = $currentTime; if($this->server->api->dhandle("player.block.break", ["player" => $player, "target" => $target, "item" => $item]) !== false){ $drops = $target->getDrops($item, $player); diff --git a/src/Player.php b/src/Player.php index 4852797e..37607591 100755 --- a/src/Player.php +++ b/src/Player.php @@ -731,6 +731,17 @@ class Player{ public $currentChunk = false; + public function getDestroySpeed($id, $meta){ + return $this->getHeldItem()->getDestroySpeed($id, $meta); + } + + public function canDestroy($id, $meta){ + $mat = StaticBlock::getMaterial($id); + if($mat->alwaysDestroyable) return true; + + return $this->getHeldItem()->canDestroySpecial($id, $meta); + } + public function onChunkReceived($blockX, $blockZ){ $minX = $blockX; $maxX = $blockX + 15; diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 8abf26d7..b779896a 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -34,6 +34,7 @@ class PocketMinecraftServer{ @cli_set_process_title("NostalgiaCore ".MAJOR_VERSION); }*/ console("[INFO] Starting Minecraft PE server on " . ($this->serverip === "0.0.0.0" ? "*" : $this->serverip) . ":" . $this->port); + Material::init(); EntityRegistry::registerEntities(); PlayerNull::$INSTANCE = new PlayerNull(); Feature::init(); diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 4cd937e9..52e352a2 100755 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -105,7 +105,7 @@ define("SUGARCANE_BLOCK", 83); define("FENCE", 85); define("PUMPKIN", 86); define("NETHERRACK", 87); -define("SOUL_SAND", 88); +define("SOUL_SAND", 88); //doesnt exist define("GLOWSTONE", 89); define("GLOWSTONE_BLOCK", 89); @@ -136,7 +136,7 @@ define("NETHER_BRICKS", 112); define("NETHER_BRICK_BLOCK", 112); define("NETHER_BRICKS_STAIRS", 114); - +//TODO missing tile: 126 dt 0.500000 h 2.500000 b CakeTile n activatorRail, mat cake define("SANDSTONE_STAIRS", 128); define("SPRUCE_WOOD_STAIRS", 134); diff --git a/src/material/Block.php b/src/material/Block.php index 7fd7cdac..49e1af41 100755 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -133,12 +133,18 @@ abstract class Block extends Position{ INFO_UPDATE2 => "InfoUpdate2Block", RESERVED6 => "Reserved6Block", ); + + /** + * @var Material + */ + public $material; + public $id; public $meta; public $name; - public $breakTime; public $boundingBox; public $hardness; + public $breakTime = 0; public $isActivable = false; public $breakable = true; public $isFlowable = false; @@ -259,6 +265,17 @@ abstract class Block extends Position{ return $this->meta & 0x0F; } + public function getDestroyProgress(Player $player){ + if($this->breakTime < 0) return 0; + $id = $this->getID(); + $meta = $this->getMetadata(); + if($player->canDestroy($id, $meta)){ + return $player->getDestroySpeed($id, $meta) / $this->breakTime / 30; + } + if($this->breakTime == 0) return INF; //instabreak + return (1 / $this->breakTime) / 100; + } + final public function position(Position $v){ $this->level = $v->level; $this->x = (int) $v->x; @@ -278,9 +295,11 @@ abstract class Block extends Position{ } public function getBreakTime(Item $item, Player $player){ + if($this->hardness < 0) return INF; if(($player->gamemode & 0x01) === 0x01){ return 0.15; } + if($player->canDestroy($this->getID(), $this->getMetadata())) return $this->breakTime; } @@ -296,7 +315,9 @@ abstract class Block extends Position{ return "Block ". $this->name ." (".$this->id.":".$this->meta.")"; } - abstract function isBreakable(Item $item, Player $player); + public function isBreakable(Item $item, Player $player){ + return $this->hardness >= 0; + } abstract function onBreak(Item $item, Player $player); diff --git a/src/material/Item.php b/src/material/Item.php index 5ed4b2d9..ca202716 100755 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -157,6 +157,14 @@ class Item{ } } + public function canDestroySpecial($id, $meta){ + return false; + } + + public function getDestroySpeed($id, $meta){ + return 1.0; + } + public function isPickaxe(){ return false; } @@ -323,10 +331,6 @@ class Item{ return Item::DEF_DAMAGE; } - public function getDestroySpeed(Block $block, Player $player){ - return 1; - } - public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ return false; } diff --git a/src/material/Material.php b/src/material/Material.php index 674ce90b..5332b046 100644 --- a/src/material/Material.php +++ b/src/material/Material.php @@ -1,9 +1,84 @@ alwaysDestroyable = true; + $this->flammable = false; + $this->translucent = false; + $this->replaceable = false; + + $this->blocksLight = true; + $this->blocksMotion = true; + $this->isLiquid = false; + $this->isSolid = true; + } + + public function isSolidBlocking(){ + if($this->translucent) return false; + return $this->blocksMotion; + } + public function letsWaterThrough(){ + if($this->isLiquid) return false; + return !$this->isSolid; + } + + public static function init(){ + self::$air = new GasMaterial(); + self::$dirt = new Material(); + self::$wood = new Material(); + self::$wood->flammable = true; + self::$stone = new Material(); + self::$stone->alwaysDestroyable = false; + self::$metal = new Material(); + self::$metal->alwaysDestroyable = false; + self::$water = new LiquidMaterial(); + self::$lava = new LiquidMaterial(); + self::$leaves = new Material(); + self::$leaves->flammable = true; + self::$leaves->translucent = true; + self::$plant = new DecorationMaterial(); + self::$replaceable_plant = new DecorationMaterial(); + self::$replaceable_plant->replaceable = true; + self::$replaceable_plant->flammable = true; + self::$sponge = new Material(); + self::$cloth = new Material(); + self::$cloth->flammable = true; + self::$fire = new GasMaterial(); + self::$fire->replaceable = true; + self::$sand = new Material(); + self::$decoration = new DecorationMaterial(); + self::$glass = new Material(); + self::$glass->translucent = true; + self::$explosive = new Material(); + self::$explosive->flammable = true; + self::$explosive->translucent = true; + self::$coral = new Material(); + self::$ice = new Material(); + self::$ice->translucent = true; + self::$topSnow = new DecorationMaterial(); + self::$topSnow->translucent = true; + self::$topSnow->replaceable = true; + self::$topSnow->alwaysDestroyable = false; + self::$snow = new Material(); + self::$snow->alwaysDestroyable = false; + self::$cactus = new Material(); + self::$cactus->translucent = true; + self::$clay = new Material(); + self::$vegetable = new Material(); + self::$portal = new Material(); + self::$cake = new Material(); + self::$web = new Material(); + self::$web->alwaysDestroyable = false; + self::$web->blocksMotion = false; + } +} + diff --git a/src/material/StaticBlock.php b/src/material/StaticBlock.php index 15269ab5..73082ecd 100644 --- a/src/material/StaticBlock.php +++ b/src/material/StaticBlock.php @@ -17,8 +17,9 @@ class StaticBlock public static $hasPhysics = []; public static $isLiquid = []; public static $isFullBlock = []; - + public static $material = []; public static $hardness = []; + public static $destroyTime = []; public static $slipperiness = []; public static $boundingBoxes = []; public static $minXs = [], $minYs = [], $minZs = [], $maxXs = [], $maxYs = [], $maxZs = []; @@ -40,6 +41,8 @@ class StaticBlock self::$slipperiness[$b->getID()] = $b->slipperiness; self::$boundingBoxes[$b->getID()] = $b->boundingBox; self::$hardness[$b->getID()] = $b->getHardness(); + self::$destroyTime[$b->getID()] = $b->breakTime; + self::$material[$b->getID()] = $b->material; self::$prealloc[$b->getID()] = $b; $b::$blockID = $b->getID(); FireBlock::setFlammabilityAndCatchingChance($b->getID(), 0, 0); @@ -102,6 +105,10 @@ class StaticBlock FireBlock::setFlammabilityAndCatchingChance(SPONGE, 30, 60); } + public static function getMaterial($blockID){ + return self::$material[$blockID] ?? Material::$air; + } + public static function setBlockBounds($blockID, $minX, $minY, $minZ, $maxX, $maxY, $maxZ){ self::$maxXs[$blockID] = $maxX; self::$maxYs[$blockID] = $maxY; diff --git a/src/material/block/attachable/LadderBlock.php b/src/material/block/attachable/LadderBlock.php index 82ef14b3..d4ae8a6f 100644 --- a/src/material/block/attachable/LadderBlock.php +++ b/src/material/block/attachable/LadderBlock.php @@ -28,6 +28,8 @@ class LadderBlock extends TransparentBlock{ $this->isSolid = false; $this->isFullBlock = false; $this->hardness = 2; + $this->breakTime = 0.4; + $this->material = Material::$decoration; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ if($face === 0 || $face === 1){ diff --git a/src/material/block/attachable/SignPostBlock.php b/src/material/block/attachable/SignPostBlock.php index a635eccc..8a1db4e2 100644 --- a/src/material/block/attachable/SignPostBlock.php +++ b/src/material/block/attachable/SignPostBlock.php @@ -16,6 +16,8 @@ class SignPostBlock extends TransparentBlock{ $this->isSolid = false; $this->isFullBlock = false; $this->hardness = 5; + $this->breakTime = 1; + $this->material = Material::$wood; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/attachable/TorchBlock.php b/src/material/block/attachable/TorchBlock.php index 761ba9d7..87d7cc36 100644 --- a/src/material/block/attachable/TorchBlock.php +++ b/src/material/block/attachable/TorchBlock.php @@ -5,6 +5,8 @@ class TorchBlock extends FlowableBlock implements LightingBlock{ public function __construct($meta = 0){ parent::__construct(TORCH, $meta, "Torch"); $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$decoration; } public function getMaxLightValue(){ diff --git a/src/material/block/attachable/TrapdoorBlock.php b/src/material/block/attachable/TrapdoorBlock.php index 6e932bde..3af17929 100644 --- a/src/material/block/attachable/TrapdoorBlock.php +++ b/src/material/block/attachable/TrapdoorBlock.php @@ -11,6 +11,8 @@ class TrapdoorBlock extends TransparentBlock{ $this->isFullBlock = true; } $this->hardness = 15; + $this->breakTime = 3; + $this->material = Material::$wood; } public function canAttachTo(Block $target){ diff --git a/src/material/block/attachable/WallSignBlock.php b/src/material/block/attachable/WallSignBlock.php index 02ca1aa5..5fe7179d 100644 --- a/src/material/block/attachable/WallSignBlock.php +++ b/src/material/block/attachable/WallSignBlock.php @@ -9,6 +9,9 @@ class WallSignBlock extends SignPostBlock{ public function __construct($meta = 0){ TransparentBlock::__construct(WALL_SIGN, $meta, "Wall Sign"); $this->isSolid = false; + $this->breakTime = 1; + $this->hardness = 5; + $this->material = Material::$wood; } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ diff --git a/src/material/block/liquid/LavaBlock.php b/src/material/block/liquid/LavaBlock.php index 9329d736..3fbe9c65 100644 --- a/src/material/block/liquid/LavaBlock.php +++ b/src/material/block/liquid/LavaBlock.php @@ -5,7 +5,9 @@ class LavaBlock extends LiquidBlockDynamic implements LightingBlock{ public static $blockID = LAVA; public function __construct($meta = 0){ parent::__construct(LAVA, $meta, "Lava"); - $this->hardness = 500; + $this->hardness = 500; //0 in vanilla + $this->breakTime = -1; //in vanilla it is 0, but you cant interact with the block so it is not possible to destroy it + $this->material = Material::$lava; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/liquid/StillLavaBlock.php b/src/material/block/liquid/StillLavaBlock.php index 2a8e89cf..b4dff404 100644 --- a/src/material/block/liquid/StillLavaBlock.php +++ b/src/material/block/liquid/StillLavaBlock.php @@ -6,6 +6,8 @@ class StillLavaBlock extends LiquidBlockStatic{ public function __construct($meta = 0){ parent::__construct(STILL_LAVA, $meta, "Still Lava"); $this->hardness = 500; + $this->breakTime = -1; //in vanilla it is 100, but you cant interact with the block so it is not possible to destroy it + $this->material = Material::$lava; } public static function getTickDelay(){ diff --git a/src/material/block/liquid/StillWaterBlock.php b/src/material/block/liquid/StillWaterBlock.php index 632177a3..5072cd5b 100644 --- a/src/material/block/liquid/StillWaterBlock.php +++ b/src/material/block/liquid/StillWaterBlock.php @@ -12,6 +12,8 @@ class StillWaterBlock extends LiquidBlockStatic{ public function __construct($meta = 0){ LiquidBlock::__construct(STILL_WATER, $meta, "Still Water"); $this->hardness = 500; + $this->breakTime = -1; //in vanilla it is 100, but you cant interact with the block so it is not possible to destroy it + $this->material = Material::$water; } public static function getTickDelay(){ diff --git a/src/material/block/liquid/WaterBlock.php b/src/material/block/liquid/WaterBlock.php index c9e5c3e9..1b090e21 100644 --- a/src/material/block/liquid/WaterBlock.php +++ b/src/material/block/liquid/WaterBlock.php @@ -7,6 +7,8 @@ class WaterBlock extends LiquidBlockDynamic{ public function __construct($meta = 0){ parent::__construct(WATER, $meta, "Water"); $this->hardness = 500; + $this->breakTime = -1; //in vanilla it is 100, but you cant interact with the block so it is not possible to destroy it + $this->material = Material::$water; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/misc/AirBlock.php b/src/material/block/misc/AirBlock.php index 9d6545b9..07499700 100644 --- a/src/material/block/misc/AirBlock.php +++ b/src/material/block/misc/AirBlock.php @@ -15,6 +15,7 @@ class AirBlock extends TransparentBlock{ $this->isSolid = false; $this->isFullBlock = true; $this->hardness = 0; + $this->material = Material::$air; } diff --git a/src/material/block/misc/BedBlock.php b/src/material/block/misc/BedBlock.php index 2d9af20d..58fb6c2b 100644 --- a/src/material/block/misc/BedBlock.php +++ b/src/material/block/misc/BedBlock.php @@ -19,6 +19,8 @@ class BedBlock extends TransparentBlock{ $this->isActivable = true; $this->isFullBlock = false; $this->hardness = 1; + $this->breakTime = 0.2; + $this->material = Material::$cloth; } public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ diff --git a/src/material/block/misc/FireBlock.php b/src/material/block/misc/FireBlock.php index 8e3b9365..9e04dd86 100644 --- a/src/material/block/misc/FireBlock.php +++ b/src/material/block/misc/FireBlock.php @@ -11,6 +11,8 @@ class FireBlock extends FlowableBlock implements LightingBlock{ $this->breakable = false; $this->isFullBlock = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$fire; } public static function getAABB(Level $level, $x, $y, $z){ return null; diff --git a/src/material/block/misc/NetherReactorBlock.php b/src/material/block/misc/NetherReactorBlock.php index 8c1ff0d0..1d62a1ff 100644 --- a/src/material/block/misc/NetherReactorBlock.php +++ b/src/material/block/misc/NetherReactorBlock.php @@ -6,6 +6,9 @@ class NetherReactorBlock extends SolidBlock{ public function __construct($meta = 0){ parent::__construct(NETHER_REACTOR, $meta, "Nether Reactor"); $this->isActivable = true; + $this->hardness = 15; + $this->breakTime = 3; + $this->material = Material::$metal; } public function onActivate(Item $item, Player $player){ diff --git a/src/material/block/misc/TNTBlock.php b/src/material/block/misc/TNTBlock.php index 5fb3da3e..3afbb6ab 100644 --- a/src/material/block/misc/TNTBlock.php +++ b/src/material/block/misc/TNTBlock.php @@ -5,7 +5,9 @@ class TNTBlock extends SolidBlock{ public function __construct(){ parent::__construct(TNT, 0, "TNT"); $this->hardness = 0; + $this->breakTime = 0; $this->isActivable = true; + $this->material = Material::$explosive; } public function onActivate(Item $item, Player $player){ diff --git a/src/material/block/nonfull/CakeBlock.php b/src/material/block/nonfull/CakeBlock.php index f7eded78..fe276310 100644 --- a/src/material/block/nonfull/CakeBlock.php +++ b/src/material/block/nonfull/CakeBlock.php @@ -8,6 +8,8 @@ class CakeBlock extends TransparentBlock{ $this->isActivable = true; $this->meta = $meta & 0x07; $this->hardness = 2.5; + $this->breakTime = 0.5; + $this->material = Material::$cake; } public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ diff --git a/src/material/block/nonfull/CarpetBlock.php b/src/material/block/nonfull/CarpetBlock.php index 60b93a98..6128c357 100644 --- a/src/material/block/nonfull/CarpetBlock.php +++ b/src/material/block/nonfull/CarpetBlock.php @@ -23,9 +23,11 @@ class CarpetBlock extends FlowableBlock{ 15 => "Black Carpet", ); $this->name = $names[$this->meta]; - $this->hardness = 0; + $this->hardness = 0.5; + $this->breakTime = 0.1; $this->isFullBlock = false; $this->isSolid = true; + $this->material = Material::$cloth; } public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ return [static::getAABB($level, $x, $y, $z)]; diff --git a/src/material/block/nonfull/ChestBlock.php b/src/material/block/nonfull/ChestBlock.php index 344daff4..cdc68777 100644 --- a/src/material/block/nonfull/ChestBlock.php +++ b/src/material/block/nonfull/ChestBlock.php @@ -7,6 +7,8 @@ class ChestBlock extends TransparentBlock{ $this->isActivable = true; $this->isFullBlock = false; $this->hardness = 15; + $this->breakTime = 2.5; + $this->material = Material::$wood; } public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ return [new AxisAlignedBB($x + 0.025, $y, $z + 0.025, $x + 0.975, $y + 0.95, $z + 0.975)]; diff --git a/src/material/block/nonfull/CobwebBlock.php b/src/material/block/nonfull/CobwebBlock.php index 4b6a9226..133bceee 100644 --- a/src/material/block/nonfull/CobwebBlock.php +++ b/src/material/block/nonfull/CobwebBlock.php @@ -6,7 +6,9 @@ class CobwebBlock extends FlowableBlock{ parent::__construct(COBWEB, 0, "Cobweb"); $this->isSolid = true; $this->isFullBlock = false; - $this->hardness = 25; + $this->hardness = 30; + $this->breakTime = 4; + $this->material = Material::$web; } public static function getAABB(Level $level, $x, $y, $z){ diff --git a/src/material/block/nonfull/FarmlandBlock.php b/src/material/block/nonfull/FarmlandBlock.php index be09ba6c..b431bb01 100644 --- a/src/material/block/nonfull/FarmlandBlock.php +++ b/src/material/block/nonfull/FarmlandBlock.php @@ -5,6 +5,8 @@ class FarmlandBlock extends TransparentBlock{ public function __construct($meta = 0){ parent::__construct(FARMLAND, $meta, "Farmland"); $this->hardness = 3; + $this->breakTime = 0.6; + $this->material = Material::$dirt; } public function getDrops(Item $item, Player $player){ return array( diff --git a/src/material/block/nonfull/FenceBlock.php b/src/material/block/nonfull/FenceBlock.php index 98442208..2af3da8c 100644 --- a/src/material/block/nonfull/FenceBlock.php +++ b/src/material/block/nonfull/FenceBlock.php @@ -6,6 +6,8 @@ class FenceBlock extends TransparentBlock{ parent::__construct(FENCE, 0, "Fence"); $this->isFullBlock = false; $this->hardness = 15; + $this->breakTime = 2; + $this->material = Material::$wood; } public static function canConnectTo(Level $level, $x, $y, $z){ diff --git a/src/material/block/nonfull/FenceGateBlock.php b/src/material/block/nonfull/FenceGateBlock.php index be286bf9..977f346c 100644 --- a/src/material/block/nonfull/FenceGateBlock.php +++ b/src/material/block/nonfull/FenceGateBlock.php @@ -31,6 +31,8 @@ class FenceGateBlock extends TransparentBlock{ $this->isFullBlock = false; } $this->hardness = 15; + $this->breakTime = 2; + $this->material = Material::$wood; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $faces = array( diff --git a/src/material/block/nonfull/GlassPaneBlock.php b/src/material/block/nonfull/GlassPaneBlock.php index 0af71ac4..810be468 100644 --- a/src/material/block/nonfull/GlassPaneBlock.php +++ b/src/material/block/nonfull/GlassPaneBlock.php @@ -6,6 +6,9 @@ class GlassPaneBlock extends TransparentBlock{ parent::__construct(GLASS_PANE, 0, "Glass Pane"); $this->isFullBlock = false; $this->isSolid = false; + $this->breakTime = 0.3; + $this->hardness = 0.3*5; + $this->material = Material::$glass; } public static function updateShape(Level $level, $x, $y, $z){ $id = $level->level->getBlockID($x, $y, $z); diff --git a/src/material/block/nonfull/IronBarsBlock.php b/src/material/block/nonfull/IronBarsBlock.php index feeca1cc..3d15b857 100644 --- a/src/material/block/nonfull/IronBarsBlock.php +++ b/src/material/block/nonfull/IronBarsBlock.php @@ -6,6 +6,9 @@ class IronBarsBlock extends TransparentBlock{ parent::__construct(IRON_BARS, 0, "Iron Bars"); $this->isFullBlock = false; $this->isSolid = false; + $this->breakTime = 5; + $this->hardness = 30; + $this->material = Material::$metal; } public static function updateShape(Level $level, $x, $y, $z){ diff --git a/src/material/block/nonfull/IronDoorBlock.php b/src/material/block/nonfull/IronDoorBlock.php index 5ac59aae..26676986 100644 --- a/src/material/block/nonfull/IronDoorBlock.php +++ b/src/material/block/nonfull/IronDoorBlock.php @@ -6,6 +6,8 @@ class IronDoorBlock extends DoorBlock{ parent::__construct(IRON_DOOR_BLOCK, $meta, "Iron Door Block"); //$this->isActivable = true; $this->hardness = 25; + $this->breakTime = 5; + $this->material = Material::$metal; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/nonfull/PoweredRailBlock.php b/src/material/block/nonfull/PoweredRailBlock.php index 0fd8a32a..e7bb2b35 100644 --- a/src/material/block/nonfull/PoweredRailBlock.php +++ b/src/material/block/nonfull/PoweredRailBlock.php @@ -4,9 +4,11 @@ class PoweredRailBlock extends RailBaseBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(POWERED_RAIL, 0, "PoweredRailBlock"); - $this->hardness = 0.7; $this->isFullBlock = false; $this->isSolid = false; + $this->hardness = 3.5; + $this->breakTime = 0.7; + $this->material = Material::$decoration; } } \ No newline at end of file diff --git a/src/material/block/nonfull/RailBlock.php b/src/material/block/nonfull/RailBlock.php index 9d63e231..b6b18594 100644 --- a/src/material/block/nonfull/RailBlock.php +++ b/src/material/block/nonfull/RailBlock.php @@ -4,9 +4,11 @@ class RailBlock extends RailBaseBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(RAIL, $meta, "Rail"); - $this->hardness = 0.7; + $this->hardness = 0.7*5; + $this->breakTime = 0.7; $this->isFullBlock = false; $this->isSolid = false; + $this->material = Material::$decoration; } public function updateState(){ diff --git a/src/material/block/nonfull/SlabBlock.php b/src/material/block/nonfull/SlabBlock.php index 3319bb7b..da167514 100644 --- a/src/material/block/nonfull/SlabBlock.php +++ b/src/material/block/nonfull/SlabBlock.php @@ -22,6 +22,8 @@ class SlabBlock extends TransparentBlock{ $this->isFullBlock = false; } $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$stone; } public static function updateShape(Level $level, $x, $y, $z){ diff --git a/src/material/block/nonfull/SnowLayerBlock.php b/src/material/block/nonfull/SnowLayerBlock.php index 3e9961a3..9d03ff58 100644 --- a/src/material/block/nonfull/SnowLayerBlock.php +++ b/src/material/block/nonfull/SnowLayerBlock.php @@ -8,6 +8,8 @@ class SnowLayerBlock extends FlowableBlock{ $this->isSolid = false; $this->isFullBlock = false; $this->hardness = 0.5; + $this->breakTime = 0.1; + $this->material = Material::$topSnow; } public static function getAABB(Level $level, $x, $y, $z){ return null; diff --git a/src/material/block/nonfull/StoneWallBlock.php b/src/material/block/nonfull/StoneWallBlock.php index 730bc480..f70c5526 100644 --- a/src/material/block/nonfull/StoneWallBlock.php +++ b/src/material/block/nonfull/StoneWallBlock.php @@ -7,7 +7,9 @@ class StoneWallBlock extends TransparentBlock{ parent::__construct(STONE_WALL, $meta & 0x01, $meta === 1 ? "Mossy Cobblestone Wall" : "Cobblestone Wall"); $this->isFullBlock = false; $this->isSolid = false; - $this->hardness = 30; + $this->hardness = 50; + $this->breakTime = 10; + $this->material = Material::$stone; } public function getDrops(Item $item, Player $player){ if($item->isPickaxe()){ diff --git a/src/material/block/nonfull/WoodDoorBlock.php b/src/material/block/nonfull/WoodDoorBlock.php index 7109a6b6..91bbce49 100644 --- a/src/material/block/nonfull/WoodDoorBlock.php +++ b/src/material/block/nonfull/WoodDoorBlock.php @@ -6,6 +6,8 @@ class WoodDoorBlock extends DoorBlock{ parent::__construct(WOOD_DOOR_BLOCK, $meta, "Wood Door Block"); $this->isActivable = true; $this->hardness = 15; + $this->breakTime = 3; + $this->material = Material::$wood; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/nonfull/WoodSlabBlock.php b/src/material/block/nonfull/WoodSlabBlock.php index 776dc334..64ced90a 100644 --- a/src/material/block/nonfull/WoodSlabBlock.php +++ b/src/material/block/nonfull/WoodSlabBlock.php @@ -16,7 +16,9 @@ class WoodSlabBlock extends TransparentBlock{ }else{ $this->isFullBlock = false; } - $this->hardness = 15; + $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$wood; } public static function updateShape(Level $level, $x, $y, $z){ diff --git a/src/material/block/nonfull/stairs/BirchWoodStairsBlock.php b/src/material/block/nonfull/stairs/BirchWoodStairsBlock.php index 619208b7..21979c8f 100644 --- a/src/material/block/nonfull/stairs/BirchWoodStairsBlock.php +++ b/src/material/block/nonfull/stairs/BirchWoodStairsBlock.php @@ -4,6 +4,9 @@ class BirchWoodStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs"); + $this->hardness = 15; + $this->breakTime = 2; + $this->material = Material::$wood; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/nonfull/stairs/BrickStairsBlock.php b/src/material/block/nonfull/stairs/BrickStairsBlock.php index 133a5f0b..2d22e1fa 100644 --- a/src/material/block/nonfull/stairs/BrickStairsBlock.php +++ b/src/material/block/nonfull/stairs/BrickStairsBlock.php @@ -4,6 +4,9 @@ class BrickStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(BRICK_STAIRS, $meta, "Brick Stairs"); + $this->breakTime = 2; + $this->hardness = 30; + $this->material = Material::$stone; } } \ No newline at end of file diff --git a/src/material/block/nonfull/stairs/CobblestoneStairsBlock.php b/src/material/block/nonfull/stairs/CobblestoneStairsBlock.php index 54d1710a..80095c91 100644 --- a/src/material/block/nonfull/stairs/CobblestoneStairsBlock.php +++ b/src/material/block/nonfull/stairs/CobblestoneStairsBlock.php @@ -4,6 +4,9 @@ class CobblestoneStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs"); + $this->breakTime = 2; + $this->hardness = 30; + $this->material = Material::$stone; } } \ No newline at end of file diff --git a/src/material/block/nonfull/stairs/JungleWoodStairsBlock.php b/src/material/block/nonfull/stairs/JungleWoodStairsBlock.php index 76c4bc68..179948b1 100644 --- a/src/material/block/nonfull/stairs/JungleWoodStairsBlock.php +++ b/src/material/block/nonfull/stairs/JungleWoodStairsBlock.php @@ -4,6 +4,9 @@ class JungleWoodStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(JUNGLE_WOOD_STAIRS, $meta, "Jungle Wood Stairs"); + $this->hardness = 15; + $this->breakTime = 2; + $this->material = Material::$wood; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/nonfull/stairs/NetherBricksStairsBlock.php b/src/material/block/nonfull/stairs/NetherBricksStairsBlock.php index 0b984590..520506ad 100644 --- a/src/material/block/nonfull/stairs/NetherBricksStairsBlock.php +++ b/src/material/block/nonfull/stairs/NetherBricksStairsBlock.php @@ -4,6 +4,9 @@ class NetherBricksStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(NETHER_BRICKS_STAIRS, $meta, "Nether Bricks Stairs"); + $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$stone; } } \ No newline at end of file diff --git a/src/material/block/nonfull/stairs/QuartzStairsBlock.php b/src/material/block/nonfull/stairs/QuartzStairsBlock.php index 062b60d0..136ded10 100644 --- a/src/material/block/nonfull/stairs/QuartzStairsBlock.php +++ b/src/material/block/nonfull/stairs/QuartzStairsBlock.php @@ -4,6 +4,9 @@ class QuartzStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(QUARTZ_STAIRS, $meta, "Quartz Stairs"); + $this->breakTime = 0.8; + $this->hardness = 4; + $this->material = Material::$stone; } } \ No newline at end of file diff --git a/src/material/block/nonfull/stairs/SandstoneStairsBlock.php b/src/material/block/nonfull/stairs/SandstoneStairsBlock.php index 8512e628..7b374f2b 100644 --- a/src/material/block/nonfull/stairs/SandstoneStairsBlock.php +++ b/src/material/block/nonfull/stairs/SandstoneStairsBlock.php @@ -4,6 +4,9 @@ class SandstoneStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(SANDSTONE_STAIRS, $meta, "Sandstone Stairs"); + $this->hardness = 0.8*5; + $this->breakTime = 0.8; + $this->material = Material::$stone; } } \ No newline at end of file diff --git a/src/material/block/nonfull/stairs/SpruceWoodStairsBlock.php b/src/material/block/nonfull/stairs/SpruceWoodStairsBlock.php index f001a888..98f65fb4 100644 --- a/src/material/block/nonfull/stairs/SpruceWoodStairsBlock.php +++ b/src/material/block/nonfull/stairs/SpruceWoodStairsBlock.php @@ -4,6 +4,9 @@ class SpruceWoodStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(SPRUCE_WOOD_STAIRS, $meta, "Spruce Wood Stairs"); + $this->hardness = 15; + $this->breakTime = 2; + $this->material = Material::$wood; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/nonfull/stairs/StoneBrickStairsBlock.php b/src/material/block/nonfull/stairs/StoneBrickStairsBlock.php index b43efbb7..40575ca3 100644 --- a/src/material/block/nonfull/stairs/StoneBrickStairsBlock.php +++ b/src/material/block/nonfull/stairs/StoneBrickStairsBlock.php @@ -4,6 +4,9 @@ class StoneBrickStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(STONE_BRICK_STAIRS, $meta, "Stone Brick Stairs"); + $this->hardness = 30; + $this->breakTime = 1.5; + $this->material = Material::$stone; } } \ No newline at end of file diff --git a/src/material/block/nonfull/stairs/WoodStairsBlock.php b/src/material/block/nonfull/stairs/WoodStairsBlock.php index e8b5d35d..e507e102 100644 --- a/src/material/block/nonfull/stairs/WoodStairsBlock.php +++ b/src/material/block/nonfull/stairs/WoodStairsBlock.php @@ -4,6 +4,8 @@ class WoodStairsBlock extends StairBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(WOOD_STAIRS, $meta, "Wood Stairs"); + $this->breakTime = 2; + $this->material = Material::$wood; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/ore/CoalOreBlock.php b/src/material/block/ore/CoalOreBlock.php index 12e5c262..1831be50 100644 --- a/src/material/block/ore/CoalOreBlock.php +++ b/src/material/block/ore/CoalOreBlock.php @@ -5,6 +5,8 @@ class CoalOreBlock extends SolidBlock{ public function __construct(){ parent::__construct(COAL_ORE, 0, "Coal Ore"); $this->hardness = 15; + $this->breakTime = 3.0; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/ore/DiamondOreBlock.php b/src/material/block/ore/DiamondOreBlock.php index dec08e78..42d73d60 100644 --- a/src/material/block/ore/DiamondOreBlock.php +++ b/src/material/block/ore/DiamondOreBlock.php @@ -5,6 +5,8 @@ class DiamondOreBlock extends SolidBlock{ public function __construct(){ parent::__construct(DIAMOND_ORE, 0, "Diamond Ore"); $this->hardness = 15; + $this->breakTime = 3; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/ore/GlowingRedstoneOreBlock.php b/src/material/block/ore/GlowingRedstoneOreBlock.php index 33dd8e0c..6a415480 100644 --- a/src/material/block/ore/GlowingRedstoneOreBlock.php +++ b/src/material/block/ore/GlowingRedstoneOreBlock.php @@ -5,6 +5,8 @@ class GlowingRedstoneOreBlock extends SolidBlock implements LightingBlock{ public function __construct(){ parent::__construct(GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore"); $this->hardness = 15; + $this->breakTime = 3; + $this->material = Material::$stone; } public static function onRandomTick(Level $level, $x, $y, $z){ diff --git a/src/material/block/ore/GoldOreBlock.php b/src/material/block/ore/GoldOreBlock.php index c835dbc1..f494bc4b 100644 --- a/src/material/block/ore/GoldOreBlock.php +++ b/src/material/block/ore/GoldOreBlock.php @@ -5,6 +5,8 @@ class GoldOreBlock extends SolidBlock{ public function __construct(){ parent::__construct(GOLD_ORE, 0, "Gold Ore"); $this->hardness = 15; + $this->breakTime = 3.0; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/ore/IronOreBlock.php b/src/material/block/ore/IronOreBlock.php index d8d001ff..693ca0ca 100644 --- a/src/material/block/ore/IronOreBlock.php +++ b/src/material/block/ore/IronOreBlock.php @@ -5,6 +5,8 @@ class IronOreBlock extends SolidBlock{ public function __construct(){ parent::__construct(IRON_ORE, 0, "Iron Ore"); $this->hardness = 15; + $this->breakTime = 3.0; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/ore/LapisOreBlock.php b/src/material/block/ore/LapisOreBlock.php index ecb3e83f..10c61e8a 100644 --- a/src/material/block/ore/LapisOreBlock.php +++ b/src/material/block/ore/LapisOreBlock.php @@ -5,6 +5,8 @@ class LapisOreBlock extends SolidBlock{ public function __construct(){ parent::__construct(LAPIS_ORE, 0, "Lapis Ore"); $this->hardness = 15; + $this->breakTime = 3.0; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/ore/RedstoneOreBlock.php b/src/material/block/ore/RedstoneOreBlock.php index 471f87ae..962651a5 100644 --- a/src/material/block/ore/RedstoneOreBlock.php +++ b/src/material/block/ore/RedstoneOreBlock.php @@ -5,6 +5,8 @@ class RedstoneOreBlock extends SolidBlock{ public function __construct(){ parent::__construct(REDSTONE_ORE, 0, "Redstone Ore"); $this->hardness = 15; + $this->breakTime = 3; + $this->material = Material::$stone; } public static function interact(Level $level, $x, $y, $z, Player $player){ diff --git a/src/material/block/plant/BeetrootBlock.php b/src/material/block/plant/BeetrootBlock.php index 88a22d4d..05d2c646 100644 --- a/src/material/block/plant/BeetrootBlock.php +++ b/src/material/block/plant/BeetrootBlock.php @@ -6,6 +6,8 @@ class BeetrootBlock extends FlowableBlock{ parent::__construct(BEETROOT_BLOCK, $meta, "Beetroot Block"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/plant/BrownMushroomBlock.php b/src/material/block/plant/BrownMushroomBlock.php index 495d8a73..eb2edf11 100644 --- a/src/material/block/plant/BrownMushroomBlock.php +++ b/src/material/block/plant/BrownMushroomBlock.php @@ -5,6 +5,8 @@ class BrownMushroomBlock extends FlowableBlock{ public function __construct(){ parent::__construct(BROWN_MUSHROOM, 0, "Brown Mushroom"); $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ diff --git a/src/material/block/plant/CactusBlock.php b/src/material/block/plant/CactusBlock.php index 4dd97196..b218d8b9 100644 --- a/src/material/block/plant/CactusBlock.php +++ b/src/material/block/plant/CactusBlock.php @@ -6,6 +6,8 @@ class CactusBlock extends TransparentBlock{ parent::__construct(CACTUS, $meta, "Cactus"); $this->isFullBlock = false; $this->hardness = 2; + $this->breakTime = 0.4; + $this->material = Material::$cactus; } public static function onEntityCollidedWithBlock(Level $level, $x, $y, $z, Entity $entity){ diff --git a/src/material/block/plant/CarrotBlock.php b/src/material/block/plant/CarrotBlock.php index 36c3e931..98717892 100644 --- a/src/material/block/plant/CarrotBlock.php +++ b/src/material/block/plant/CarrotBlock.php @@ -6,6 +6,8 @@ class CarrotBlock extends FlowableBlock{ parent::__construct(CARROT_BLOCK, $meta, "Carrot Block"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/plant/CyanFlowerBlock.php b/src/material/block/plant/CyanFlowerBlock.php index 16c3c97c..c48704e0 100644 --- a/src/material/block/plant/CyanFlowerBlock.php +++ b/src/material/block/plant/CyanFlowerBlock.php @@ -6,6 +6,8 @@ class CyanFlowerBlock extends FlowableBlock{ parent::__construct(CYAN_FLOWER, 0, "Cyan Flower"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public static function getAABB(Level $level, $x, $y, $z){ diff --git a/src/material/block/plant/DandelionBlock.php b/src/material/block/plant/DandelionBlock.php index 9c61d1bd..bc4d56f2 100644 --- a/src/material/block/plant/DandelionBlock.php +++ b/src/material/block/plant/DandelionBlock.php @@ -6,6 +6,8 @@ class DandelionBlock extends FlowableBlock{ parent::__construct(DANDELION, 0, "Dandelion"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public static function getAABB(Level $level, $x, $y, $z){ return null; diff --git a/src/material/block/plant/DeadBushBlock.php b/src/material/block/plant/DeadBushBlock.php index 4f7d49b7..f1f51e38 100644 --- a/src/material/block/plant/DeadBushBlock.php +++ b/src/material/block/plant/DeadBushBlock.php @@ -6,6 +6,8 @@ class DeadBushBlock extends FlowableBlock{ parent::__construct(DEAD_BUSH, 0, "Dead Bush"); //$this->isReplaceable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$replaceable_plant; } public static function getAABB(Level $level, $x, $y, $z){ diff --git a/src/material/block/plant/MelonStemBlock.php b/src/material/block/plant/MelonStemBlock.php index 2022f819..10500032 100644 --- a/src/material/block/plant/MelonStemBlock.php +++ b/src/material/block/plant/MelonStemBlock.php @@ -6,6 +6,8 @@ class MelonStemBlock extends FlowableBlock{ parent::__construct(MELON_STEM, $meta, "Melon Stem"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); diff --git a/src/material/block/plant/PotatoBlock.php b/src/material/block/plant/PotatoBlock.php index 54ec8cec..d8f86f38 100644 --- a/src/material/block/plant/PotatoBlock.php +++ b/src/material/block/plant/PotatoBlock.php @@ -6,6 +6,8 @@ class PotatoBlock extends FlowableBlock{ parent::__construct(POTATO_BLOCK, $meta, "Potato Block"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/plant/PumpkinStemBlock.php b/src/material/block/plant/PumpkinStemBlock.php index a40f9f5f..ac34ed7d 100644 --- a/src/material/block/plant/PumpkinStemBlock.php +++ b/src/material/block/plant/PumpkinStemBlock.php @@ -6,6 +6,8 @@ class PumpkinStemBlock extends FlowableBlock{ parent::__construct(PUMPKIN_STEM, $meta, "Pumpkin Stem"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); diff --git a/src/material/block/plant/RedMushroomBlock.php b/src/material/block/plant/RedMushroomBlock.php index 29bdc225..a3507380 100644 --- a/src/material/block/plant/RedMushroomBlock.php +++ b/src/material/block/plant/RedMushroomBlock.php @@ -5,6 +5,8 @@ class RedMushroomBlock extends FlowableBlock{ public function __construct(){ parent::__construct(RED_MUSHROOM, 0, "Red Mushroom"); $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ diff --git a/src/material/block/plant/SaplingBlock.php b/src/material/block/plant/SaplingBlock.php index 86cc8048..bd5635d0 100644 --- a/src/material/block/plant/SaplingBlock.php +++ b/src/material/block/plant/SaplingBlock.php @@ -19,6 +19,8 @@ class SaplingBlock extends FlowableBlock{ ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public static function getAABB(Level $level, $x, $y, $z){ return null; diff --git a/src/material/block/plant/SugarcaneBlock.php b/src/material/block/plant/SugarcaneBlock.php index f17fd596..279952e2 100644 --- a/src/material/block/plant/SugarcaneBlock.php +++ b/src/material/block/plant/SugarcaneBlock.php @@ -6,6 +6,8 @@ class SugarcaneBlock extends FlowableBlock{ parent::__construct(SUGARCANE_BLOCK, $meta, "Sugarcane"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/plant/TallGrassBlock.php b/src/material/block/plant/TallGrassBlock.php index df8ce39f..02f8b4bd 100644 --- a/src/material/block/plant/TallGrassBlock.php +++ b/src/material/block/plant/TallGrassBlock.php @@ -12,6 +12,8 @@ class TallGrassBlock extends FlowableBlock{ ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$replaceable_plant; } public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ diff --git a/src/material/block/plant/WheatBlock.php b/src/material/block/plant/WheatBlock.php index 176a2065..97f3d39f 100644 --- a/src/material/block/plant/WheatBlock.php +++ b/src/material/block/plant/WheatBlock.php @@ -6,6 +6,8 @@ class WheatBlock extends FlowableBlock{ parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block"); $this->isActivable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$plant; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/solid/BedrockBlock.php b/src/material/block/solid/BedrockBlock.php index 8974deae..4799553b 100644 --- a/src/material/block/solid/BedrockBlock.php +++ b/src/material/block/solid/BedrockBlock.php @@ -6,6 +6,8 @@ class BedrockBlock extends SolidBlock{ parent::__construct(BEDROCK, 0, "Bedrock"); $this->breakable = false; $this->hardness = 18000000; + $this->breakTime = -1; + $this->material = Material::$stone; } public function isBreakable(Item $item, Player $player){ diff --git a/src/material/block/solid/BookshelfBlock.php b/src/material/block/solid/BookshelfBlock.php index 8f19b6fe..80955d9e 100644 --- a/src/material/block/solid/BookshelfBlock.php +++ b/src/material/block/solid/BookshelfBlock.php @@ -5,6 +5,8 @@ class BookshelfBlock extends SolidBlock{ public function __construct(){ parent::__construct(BOOKSHELF, 0, "Bookshelf"); $this->hardness = 7.5; + $this->breakTime = 1.5; + $this->material = Material::$wood; } } \ No newline at end of file diff --git a/src/material/block/solid/BricksBlock.php b/src/material/block/solid/BricksBlock.php index 97f448b2..cea18904 100644 --- a/src/material/block/solid/BricksBlock.php +++ b/src/material/block/solid/BricksBlock.php @@ -5,6 +5,8 @@ class BricksBlock extends SolidBlock{ public function __construct(){ parent::__construct(BRICKS_BLOCK, 0, "Bricks"); $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/BurningFurnaceBlock.php b/src/material/block/solid/BurningFurnaceBlock.php index 0adb007c..50944933 100644 --- a/src/material/block/solid/BurningFurnaceBlock.php +++ b/src/material/block/solid/BurningFurnaceBlock.php @@ -6,6 +6,8 @@ class BurningFurnaceBlock extends SolidBlock implements LightingBlock{ parent::__construct(BURNING_FURNACE, $meta, "Burning Furnace"); $this->isActivable = true; $this->hardness = 17.5; + $this->breakTime = 3.5; + $this->material = Material::$stone; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/solid/ClayBlock.php b/src/material/block/solid/ClayBlock.php index 3ca8b2a4..e1c88681 100644 --- a/src/material/block/solid/ClayBlock.php +++ b/src/material/block/solid/ClayBlock.php @@ -5,6 +5,8 @@ class ClayBlock extends SolidBlock{ public function __construct(){ parent::__construct(CLAY_BLOCK, 0, "Clay Block"); $this->hardness = 3; + $this->breakTime = 0.6; + $this->material = Material::$clay; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/solid/CoalBlock.php b/src/material/block/solid/CoalBlock.php index cf7a252e..6c7a11e2 100644 --- a/src/material/block/solid/CoalBlock.php +++ b/src/material/block/solid/CoalBlock.php @@ -5,6 +5,8 @@ class CoalBlock extends SolidBlock{ public function __construct(){ parent::__construct(COAL_BLOCK, 0, "Coal Block"); $this->hardness = 30; + $this->breakTime = 5; + $this->material = Material::$metal; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/CobblestoneBlock.php b/src/material/block/solid/CobblestoneBlock.php index 895953d1..96bc7172 100644 --- a/src/material/block/solid/CobblestoneBlock.php +++ b/src/material/block/solid/CobblestoneBlock.php @@ -5,6 +5,8 @@ class CobblestoneBlock extends SolidBlock{ public function __construct(){ parent::__construct(COBBLESTONE, 0, "Cobblestone"); $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/DiamondBlock.php b/src/material/block/solid/DiamondBlock.php index 2ffeed39..9fc92a18 100644 --- a/src/material/block/solid/DiamondBlock.php +++ b/src/material/block/solid/DiamondBlock.php @@ -5,6 +5,8 @@ class DiamondBlock extends SolidBlock{ public function __construct(){ parent::__construct(DIAMOND_BLOCK, 0, "Diamond Block"); $this->hardness = 30; + $this->breakTime = 5; + $this->material = Material::$metal; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/DirtBlock.php b/src/material/block/solid/DirtBlock.php index 46131b49..fef766f0 100644 --- a/src/material/block/solid/DirtBlock.php +++ b/src/material/block/solid/DirtBlock.php @@ -6,6 +6,8 @@ class DirtBlock extends SolidBlock{ parent::__construct(DIRT, 0, "Dirt"); $this->isActivable = true; $this->hardness = 2.5; + $this->breakTime = 0.5; + $this->material = Material::$dirt; } public function onActivate(Item $item, Player $player){ diff --git a/src/material/block/solid/DoubleSlabBlock.php b/src/material/block/solid/DoubleSlabBlock.php index 4b6f28db..c455099d 100755 --- a/src/material/block/solid/DoubleSlabBlock.php +++ b/src/material/block/solid/DoubleSlabBlock.php @@ -16,6 +16,8 @@ class DoubleSlabBlock extends SolidBlock{ ); $this->name = "Double " . $names[$this->meta & 0x07] . " Slab"; $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/DoubleWoodSlabBlock.php b/src/material/block/solid/DoubleWoodSlabBlock.php index 74316ede..62aa3c40 100644 --- a/src/material/block/solid/DoubleWoodSlabBlock.php +++ b/src/material/block/solid/DoubleWoodSlabBlock.php @@ -11,7 +11,9 @@ class DoubleWoodSlabBlock extends SolidBlock{ 3 => "Jungle", ); $this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab"; - $this->hardness = 15; + $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$wood; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/FurnaceBlock.php b/src/material/block/solid/FurnaceBlock.php index 06f2db28..3f8253e2 100644 --- a/src/material/block/solid/FurnaceBlock.php +++ b/src/material/block/solid/FurnaceBlock.php @@ -12,5 +12,6 @@ class FurnaceBlock extends BurningFurnaceBlock{ $this->id = FURNACE; $this->name = "Furnace"; $this->isActivable = true; + $this->material = Material::$stone; } } \ No newline at end of file diff --git a/src/material/block/solid/GlassBlock.php b/src/material/block/solid/GlassBlock.php index a6149c59..f3c50569 100644 --- a/src/material/block/solid/GlassBlock.php +++ b/src/material/block/solid/GlassBlock.php @@ -5,6 +5,8 @@ class GlassBlock extends TransparentBlock{ public function __construct(){ parent::__construct(GLASS, 0, "Glass"); $this->hardness = 1.5; + $this->breakTime = 0.3; + $this->material = Material::$glass; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/solid/GlowingObsidianBlock.php b/src/material/block/solid/GlowingObsidianBlock.php index ea88b779..cefcb5c5 100644 --- a/src/material/block/solid/GlowingObsidianBlock.php +++ b/src/material/block/solid/GlowingObsidianBlock.php @@ -4,6 +4,9 @@ class GlowingObsidianBlock extends SolidBlock implements LightingBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(GLOWING_OBSIDIAN, $meta, "Glowing Obsidian"); + $this->hardness = 6000; + $this->breakTime = 10; + $this->material = Material::$stone; } public function getMaxLightValue(){ diff --git a/src/material/block/solid/GlowstoneBlock.php b/src/material/block/solid/GlowstoneBlock.php index 177cbb3f..f746e6c4 100644 --- a/src/material/block/solid/GlowstoneBlock.php +++ b/src/material/block/solid/GlowstoneBlock.php @@ -5,6 +5,8 @@ class GlowstoneBlock extends TransparentBlock implements LightingBlock{ public function __construct(){ parent::__construct(GLOWSTONE_BLOCK, 0, "Glowstone"); $this->hardness = 1.5; + $this->breakTime = 0.3; + $this->material = Material::$glass; } public function getMaxLightValue(){ diff --git a/src/material/block/solid/GoldBlock.php b/src/material/block/solid/GoldBlock.php index 80006170..6c623e93 100644 --- a/src/material/block/solid/GoldBlock.php +++ b/src/material/block/solid/GoldBlock.php @@ -5,6 +5,8 @@ class GoldBlock extends SolidBlock{ public function __construct(){ parent::__construct(GOLD_BLOCK, 0, "Gold Block"); $this->hardness = 30; + $this->breakTime = 3; + $this->material = Material::$metal; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/GrassBlock.php b/src/material/block/solid/GrassBlock.php index c598b134..10945978 100644 --- a/src/material/block/solid/GrassBlock.php +++ b/src/material/block/solid/GrassBlock.php @@ -6,6 +6,8 @@ class GrassBlock extends SolidBlock{ parent::__construct(GRASS, 0, "Grass"); $this->isActivable = true; $this->hardness = 3; + $this->breakTime = 0.6; + $this->material = Material::$dirt; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/solid/GravelBlock.php b/src/material/block/solid/GravelBlock.php index f35adb53..4842e512 100644 --- a/src/material/block/solid/GravelBlock.php +++ b/src/material/block/solid/GravelBlock.php @@ -5,6 +5,8 @@ class GravelBlock extends FallableBlock{ public function __construct(){ parent::__construct(GRAVEL, 0, "Gravel"); $this->hardness = 3; + $this->breakTime = 0.6; + $this->material = Material::$sand; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/solid/HayBaleBlock.php b/src/material/block/solid/HayBaleBlock.php index 869eebe5..eb748749 100644 --- a/src/material/block/solid/HayBaleBlock.php +++ b/src/material/block/solid/HayBaleBlock.php @@ -4,7 +4,9 @@ class HayBaleBlock extends SolidBlock{ public static $blockID; public function __construct($meta = 0){ parent::__construct(HAY_BALE, $meta, "Hay Bale"); - $this->hardness = 10; + $this->hardness = 2.5; + $this->breakTime = 0.5; + $this->material = Material::$dirt; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/solid/IceBlock.php b/src/material/block/solid/IceBlock.php index e5e7860d..81d6f82f 100644 --- a/src/material/block/solid/IceBlock.php +++ b/src/material/block/solid/IceBlock.php @@ -5,7 +5,9 @@ class IceBlock extends TransparentBlock{ public function __construct(){ parent::__construct(ICE, 0, "Ice"); $this->hardness = 2.5; + $this->breakTime = 0.5; $this->slipperiness = 0.98; + $this->material = Material::$ice; } public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ diff --git a/src/material/block/solid/InfoUpdate2Block.php b/src/material/block/solid/InfoUpdate2Block.php index 0497b861..0bc5cafd 100755 --- a/src/material/block/solid/InfoUpdate2Block.php +++ b/src/material/block/solid/InfoUpdate2Block.php @@ -5,7 +5,9 @@ class InfoUpdate2Block extends SolidBlock{ public function __construct(){ parent::__construct(INFO_UPDATE2, 0, "tile.info_update2.name<"); $this->breakable = true; - $this->hardness = 0; + $this->hardness = 5; + $this->breakTime = 1; + $this->material = Material::$dirt; } } \ No newline at end of file diff --git a/src/material/block/solid/InfoUpdateBlock.php b/src/material/block/solid/InfoUpdateBlock.php index 8b088190..cb7f2b8c 100755 --- a/src/material/block/solid/InfoUpdateBlock.php +++ b/src/material/block/solid/InfoUpdateBlock.php @@ -5,7 +5,9 @@ class InfoUpdateBlock extends SolidBlock{ public function __construct(){ parent::__construct(INFO_UPDATE, 0, "tile.info_update.name<"); $this->breakable = true; - $this->hardness = 0; + $this->hardness = 5; + $this->breakTime = 1; + $this->material = Material::$dirt; } } \ No newline at end of file diff --git a/src/material/block/solid/InvisibleBedrockBlock.php b/src/material/block/solid/InvisibleBedrockBlock.php index dede980e..02724952 100755 --- a/src/material/block/solid/InvisibleBedrockBlock.php +++ b/src/material/block/solid/InvisibleBedrockBlock.php @@ -5,7 +5,9 @@ class InvisibleBedrockBlock extends SolidBlock{ public function __construct(){ parent::__construct(INVISIBLE_BEDROCK, 0, ".name<"); $this->breakable = false; - $this->hardness = 3600000; + $this->hardness = 18000000; + $this->breakTime = -1; + $this->material = Material::$stone; } public function isBreakable(Item $item, Player $player){ diff --git a/src/material/block/solid/IronBlock.php b/src/material/block/solid/IronBlock.php index 504b94a1..2d14ffc4 100644 --- a/src/material/block/solid/IronBlock.php +++ b/src/material/block/solid/IronBlock.php @@ -5,6 +5,8 @@ class IronBlock extends SolidBlock{ public function __construct(){ parent::__construct(IRON_BLOCK, 0, "Iron Block"); $this->hardness = 30; + $this->breakTime = 5; + $this->material = Material::$metal; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/LapisBlock.php b/src/material/block/solid/LapisBlock.php index 1d4c4dc6..21fe55cb 100644 --- a/src/material/block/solid/LapisBlock.php +++ b/src/material/block/solid/LapisBlock.php @@ -5,6 +5,8 @@ class LapisBlock extends SolidBlock{ public function __construct(){ parent::__construct(LAPIS_BLOCK, 0, "Lapis Block"); $this->hardness = 15; + $this->breakTime = 3.0; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/LeavesBlock.php b/src/material/block/solid/LeavesBlock.php index 8a8c5dc3..1f6e2480 100644 --- a/src/material/block/solid/LeavesBlock.php +++ b/src/material/block/solid/LeavesBlock.php @@ -15,6 +15,8 @@ class LeavesBlock extends TransparentBlock{ ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 1; + $this->breakTime = 0.2; + $this->material = Material::$leaves; } public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ diff --git a/src/material/block/solid/LitPumpkinBlock.php b/src/material/block/solid/LitPumpkinBlock.php index 6775794a..642caf8d 100644 --- a/src/material/block/solid/LitPumpkinBlock.php +++ b/src/material/block/solid/LitPumpkinBlock.php @@ -13,6 +13,8 @@ class LitPumpkinBlock extends SolidBlock implements LightingBlock{ public function __construct($meta = 0){ parent::__construct(LIT_PUMPKIN, $meta, "Jack o'Lantern"); $this->hardness = 5; + $this->breakTime = 1.0; + $this->material = Material::$vegetable; } public function getMaxLightValue(){ diff --git a/src/material/block/solid/MelonBlock.php b/src/material/block/solid/MelonBlock.php index 4b46e393..690b43c2 100644 --- a/src/material/block/solid/MelonBlock.php +++ b/src/material/block/solid/MelonBlock.php @@ -5,6 +5,8 @@ class MelonBlock extends TransparentBlock{ public function __construct(){ parent::__construct(MELON_BLOCK, 0, "Melon Block"); $this->hardness = 5; + $this->breakTime = 1; + $this->material = Material::$vegetable; } public function getDrops(Item $item, Player $player){ return array( diff --git a/src/material/block/solid/MossStoneBlock.php b/src/material/block/solid/MossStoneBlock.php index 495de40d..181ee302 100644 --- a/src/material/block/solid/MossStoneBlock.php +++ b/src/material/block/solid/MossStoneBlock.php @@ -5,6 +5,8 @@ class MossStoneBlock extends SolidBlock{ public function __construct(){ parent::__construct(MOSS_STONE, 0, "Moss Stone"); $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/NetherBricksBlock.php b/src/material/block/solid/NetherBricksBlock.php index bf1c7947..f58002d7 100644 --- a/src/material/block/solid/NetherBricksBlock.php +++ b/src/material/block/solid/NetherBricksBlock.php @@ -5,6 +5,8 @@ class NetherBricksBlock extends SolidBlock{ public function __construct(){ parent::__construct(NETHER_BRICKS, 0, "Nether Bricks"); $this->hardness = 30; + $this->breakTime = 2; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/NetherrackBlock.php b/src/material/block/solid/NetherrackBlock.php index 4700a083..203e7b4f 100644 --- a/src/material/block/solid/NetherrackBlock.php +++ b/src/material/block/solid/NetherrackBlock.php @@ -5,6 +5,8 @@ class NetherrackBlock extends SolidBlock{ public function __construct(){ parent::__construct(NETHERRACK, 0, "Netherrack"); $this->hardness = 2; + $this->breakTime = 0.4; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/ObsidianBlock.php b/src/material/block/solid/ObsidianBlock.php index dc0ff733..466201ab 100644 --- a/src/material/block/solid/ObsidianBlock.php +++ b/src/material/block/solid/ObsidianBlock.php @@ -4,7 +4,9 @@ class ObsidianBlock extends SolidBlock{ public static $blockID; public function __construct(){ parent::__construct(OBSIDIAN, 0, "Obsidian"); - $this->hardness = 6000; + $this->hardness = 6000; + $this->breakTime = 10; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/PlanksBlock.php b/src/material/block/solid/PlanksBlock.php index ed0ba041..c4cc531e 100644 --- a/src/material/block/solid/PlanksBlock.php +++ b/src/material/block/solid/PlanksBlock.php @@ -12,6 +12,8 @@ class PlanksBlock extends SolidBlock{ ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 15; + $this->breakTime = 2; + $this->material = Material::$wood; } } \ No newline at end of file diff --git a/src/material/block/solid/PumpkinBlock.php b/src/material/block/solid/PumpkinBlock.php index 84aff6b3..92002b14 100644 --- a/src/material/block/solid/PumpkinBlock.php +++ b/src/material/block/solid/PumpkinBlock.php @@ -5,6 +5,8 @@ class PumpkinBlock extends SolidBlock{ public function __construct($meta = 0){ parent::__construct(PUMPKIN, $meta, "Pumpkin"); $this->hardness = 5; + $this->breakTime = 1; + $this->material = Material::$vegetable; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/solid/QuartzBlock.php b/src/material/block/solid/QuartzBlock.php index 1c7bcfb7..3640f18b 100644 --- a/src/material/block/solid/QuartzBlock.php +++ b/src/material/block/solid/QuartzBlock.php @@ -11,6 +11,9 @@ class QuartzBlock extends SolidBlock{ 3 => "Quartz Pillar", ); $this->name = $names[$this->meta & 0x03]; + $this->breakTime = 0.8; + $this->hardness = 4; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/Reserved6Block.php b/src/material/block/solid/Reserved6Block.php index 1a9d6bd6..3c86f0a0 100644 --- a/src/material/block/solid/Reserved6Block.php +++ b/src/material/block/solid/Reserved6Block.php @@ -6,6 +6,8 @@ class Reserved6Block extends SolidBlock{ parent::__construct(RESERVED6, 0, ".name<"); $this->breakable = true; $this->hardness = 0; + $this->breakTime = 0; + $this->material = Material::$dirt; } } \ No newline at end of file diff --git a/src/material/block/solid/SandBlock.php b/src/material/block/solid/SandBlock.php index fa41be00..4c9ee6d1 100644 --- a/src/material/block/solid/SandBlock.php +++ b/src/material/block/solid/SandBlock.php @@ -5,6 +5,8 @@ class SandBlock extends FallableBlock{ public function __construct(){ parent::__construct(SAND, 0, "Sand"); $this->hardness = 2.5; + $this->breakTime = 0.5; + $this->material = Material::$sand; } } \ No newline at end of file diff --git a/src/material/block/solid/SandstoneBlock.php b/src/material/block/solid/SandstoneBlock.php index c6533998..1a0d4bab 100644 --- a/src/material/block/solid/SandstoneBlock.php +++ b/src/material/block/solid/SandstoneBlock.php @@ -11,6 +11,8 @@ class SandstoneBlock extends SolidBlock{ ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 4; + $this->breakTime = 0.8; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/SnowBlock.php b/src/material/block/solid/SnowBlock.php index 2e024c8f..d41d2148 100644 --- a/src/material/block/solid/SnowBlock.php +++ b/src/material/block/solid/SnowBlock.php @@ -5,6 +5,8 @@ class SnowBlock extends SolidBlock{ public function __construct(){ parent::__construct(SNOW_BLOCK, 0, "Snow Block"); $this->hardness = 1; + $this->breakTime = 0.2; + $this->material = Material::$snow; } public function getDrops(Item $item, Player $player){ diff --git a/src/material/block/solid/SpongeBlock.php b/src/material/block/solid/SpongeBlock.php index 39b4c237..58702087 100644 --- a/src/material/block/solid/SpongeBlock.php +++ b/src/material/block/solid/SpongeBlock.php @@ -5,6 +5,8 @@ class SpongeBlock extends SolidBlock{ public function __construct(){ parent::__construct(SPONGE, 0, "Sponge"); $this->hardness = 3; + $this->breakTime = 0.6; + $this->material = Material::$dirt; } } diff --git a/src/material/block/solid/StoneBlock.php b/src/material/block/solid/StoneBlock.php index 51504b66..55ee212c 100644 --- a/src/material/block/solid/StoneBlock.php +++ b/src/material/block/solid/StoneBlock.php @@ -5,6 +5,8 @@ class StoneBlock extends SolidBlock{ public function __construct(){ parent::__construct(STONE, 0, "Stone"); $this->hardness = 30; + $this->breakTime = 1.5; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/StoneBricksBlock.php b/src/material/block/solid/StoneBricksBlock.php index 58299703..1b856076 100644 --- a/src/material/block/solid/StoneBricksBlock.php +++ b/src/material/block/solid/StoneBricksBlock.php @@ -12,6 +12,8 @@ class StoneBricksBlock extends SolidBlock{ ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 30; + $this->breakTime = 1.5; + $this->material = Material::$stone; } public function getBreakTime(Item $item, Player $player){ diff --git a/src/material/block/solid/StonecutterBlock.php b/src/material/block/solid/StonecutterBlock.php index 110747d1..fc307d70 100644 --- a/src/material/block/solid/StonecutterBlock.php +++ b/src/material/block/solid/StonecutterBlock.php @@ -5,6 +5,9 @@ class StonecutterBlock extends SolidBlock{ public function __construct($meta = 0){ parent::__construct(STONECUTTER, $meta, "Stonecutter"); $this->isActivable = true; + $this->breakTime = 2.5; + $this->hardness = 2.5*5; + $this->material = Material::$stone; } public function onActivate(Item $item, Player $player){ diff --git a/src/material/block/solid/WoodBlock.php b/src/material/block/solid/WoodBlock.php index e9711141..04a26316 100644 --- a/src/material/block/solid/WoodBlock.php +++ b/src/material/block/solid/WoodBlock.php @@ -17,6 +17,8 @@ class WoodBlock extends SolidBlock{ ); $this->name = $names[$this->meta & 0x03]; $this->hardness = 10; + $this->breakTime = 2.0; + $this->material = Material::$wood; } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ diff --git a/src/material/block/solid/WoolBlock.php b/src/material/block/solid/WoolBlock.php index 8c574f65..52b91735 100644 --- a/src/material/block/solid/WoolBlock.php +++ b/src/material/block/solid/WoolBlock.php @@ -27,6 +27,8 @@ class WoolBlock extends SolidBlock{ $this->name = self::$names[$this->meta] ?? "Illegal Wool"; $this->hardness = 4; + $this->breakTime = 0.8; + $this->material = Material::$cloth; } } \ No newline at end of file diff --git a/src/material/block/solid/WorkbenchBlock.php b/src/material/block/solid/WorkbenchBlock.php index 080ac13c..5f80c000 100644 --- a/src/material/block/solid/WorkbenchBlock.php +++ b/src/material/block/solid/WorkbenchBlock.php @@ -5,7 +5,9 @@ class WorkbenchBlock extends SolidBlock{ public function __construct($meta = 0){ parent::__construct(WORKBENCH, $meta, "Crafting Table"); $this->isActivable = true; - $this->hardness = 15; + $this->hardness = 12.5; + $this->breakTime = 2.5; + $this->material = Material::$wood; } public function onActivate(Item $item, Player $player){ diff --git a/src/material/item/armor/ChainBootsItem.php b/src/material/item/armor/ChainBootsItem.php index 73083238..64064b4e 100644 --- a/src/material/item/armor/ChainBootsItem.php +++ b/src/material/item/armor/ChainBootsItem.php @@ -7,7 +7,7 @@ class ChainBootsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::CHAIN; + return ArmorMaterial::CHAIN; } public function getBaseDurability(){ diff --git a/src/material/item/armor/ChainChestplateItem.php b/src/material/item/armor/ChainChestplateItem.php index ae28d0c5..ceca50d2 100644 --- a/src/material/item/armor/ChainChestplateItem.php +++ b/src/material/item/armor/ChainChestplateItem.php @@ -7,7 +7,7 @@ class ChainChestplateItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::CHAIN; + return ArmorMaterial::CHAIN; } public function getBaseDurability(){ diff --git a/src/material/item/armor/ChainHelmetItem.php b/src/material/item/armor/ChainHelmetItem.php index df7c83d9..4b13c654 100644 --- a/src/material/item/armor/ChainHelmetItem.php +++ b/src/material/item/armor/ChainHelmetItem.php @@ -7,7 +7,7 @@ class ChainHelmetItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::CHAIN; + return ArmorMaterial::CHAIN; } public function getBaseDurability(){ diff --git a/src/material/item/armor/ChainLeggingsItem.php b/src/material/item/armor/ChainLeggingsItem.php index 9d1800b1..4ca503f5 100644 --- a/src/material/item/armor/ChainLeggingsItem.php +++ b/src/material/item/armor/ChainLeggingsItem.php @@ -7,7 +7,7 @@ class ChainLeggingsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::CHAIN; + return ArmorMaterial::CHAIN; } public function getBaseDurability(){ diff --git a/src/material/item/armor/DiamondBootsItem.php b/src/material/item/armor/DiamondBootsItem.php index 4591f9d8..3a34c7a2 100644 --- a/src/material/item/armor/DiamondBootsItem.php +++ b/src/material/item/armor/DiamondBootsItem.php @@ -7,7 +7,7 @@ class DiamondBootsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::DIAMOND; + return ArmorMaterial::DIAMOND; } public function getBaseDurability(){ diff --git a/src/material/item/armor/DiamondChestplateItem.php b/src/material/item/armor/DiamondChestplateItem.php index fad4edce..ce3ccc10 100644 --- a/src/material/item/armor/DiamondChestplateItem.php +++ b/src/material/item/armor/DiamondChestplateItem.php @@ -7,7 +7,7 @@ class DiamondChestplateItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::DIAMOND; + return ArmorMaterial::DIAMOND; } public function getBaseDurability(){ diff --git a/src/material/item/armor/DiamondHelmetItem.php b/src/material/item/armor/DiamondHelmetItem.php index b0e53cbc..2ba99542 100644 --- a/src/material/item/armor/DiamondHelmetItem.php +++ b/src/material/item/armor/DiamondHelmetItem.php @@ -7,7 +7,7 @@ class DiamondHelmetItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::DIAMOND; + return ArmorMaterial::DIAMOND; } public function getBaseDurability(){ diff --git a/src/material/item/armor/DiamondLeggingsItem.php b/src/material/item/armor/DiamondLeggingsItem.php index ef2e005d..59ea5993 100644 --- a/src/material/item/armor/DiamondLeggingsItem.php +++ b/src/material/item/armor/DiamondLeggingsItem.php @@ -7,7 +7,7 @@ class DiamondLeggingsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::DIAMOND; + return ArmorMaterial::DIAMOND; } public function getBaseDurability(){ diff --git a/src/material/item/armor/GoldenBootsItem.php b/src/material/item/armor/GoldenBootsItem.php index 1ac0f9a4..a31a7b72 100644 --- a/src/material/item/armor/GoldenBootsItem.php +++ b/src/material/item/armor/GoldenBootsItem.php @@ -7,7 +7,7 @@ class GoldenBootsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::GOLD; + return ArmorMaterial::GOLD; } public function getBaseDurability(){ diff --git a/src/material/item/armor/GoldenChestplateItem.php b/src/material/item/armor/GoldenChestplateItem.php index 739617b6..957dfd36 100644 --- a/src/material/item/armor/GoldenChestplateItem.php +++ b/src/material/item/armor/GoldenChestplateItem.php @@ -7,7 +7,7 @@ class GoldenChestplateItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::GOLD; + return ArmorMaterial::GOLD; } public function getBaseDurability(){ diff --git a/src/material/item/armor/GoldenHelmetItem.php b/src/material/item/armor/GoldenHelmetItem.php index c7ee4711..62339bd5 100644 --- a/src/material/item/armor/GoldenHelmetItem.php +++ b/src/material/item/armor/GoldenHelmetItem.php @@ -7,7 +7,7 @@ class GoldenHelmetItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::GOLD; + return ArmorMaterial::GOLD; } public function getBaseDurability(){ diff --git a/src/material/item/armor/GoldenLeggingsItem.php b/src/material/item/armor/GoldenLeggingsItem.php index ee9dd964..28841697 100644 --- a/src/material/item/armor/GoldenLeggingsItem.php +++ b/src/material/item/armor/GoldenLeggingsItem.php @@ -7,7 +7,7 @@ class GoldenLeggingsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::GOLD; + return ArmorMaterial::GOLD; } public function getBaseDurability(){ diff --git a/src/material/item/armor/IronBootsItem.php b/src/material/item/armor/IronBootsItem.php index 7f548bb9..07c01d24 100644 --- a/src/material/item/armor/IronBootsItem.php +++ b/src/material/item/armor/IronBootsItem.php @@ -7,7 +7,7 @@ class IronBootsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::IRON; + return ArmorMaterial::IRON; } public function getBaseDurability(){ diff --git a/src/material/item/armor/IronChestplateItem.php b/src/material/item/armor/IronChestplateItem.php index 05ca1086..499811da 100644 --- a/src/material/item/armor/IronChestplateItem.php +++ b/src/material/item/armor/IronChestplateItem.php @@ -7,7 +7,7 @@ class IronChestplateItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::IRON; + return ArmorMaterial::IRON; } public function getBaseDurability(){ diff --git a/src/material/item/armor/IronHelmetItem.php b/src/material/item/armor/IronHelmetItem.php index 70c85f5e..fc3602c0 100644 --- a/src/material/item/armor/IronHelmetItem.php +++ b/src/material/item/armor/IronHelmetItem.php @@ -7,7 +7,7 @@ class IronHelmetItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::IRON; + return ArmorMaterial::IRON; } public function getBaseDurability(){ diff --git a/src/material/item/armor/IronLeggingsItem.php b/src/material/item/armor/IronLeggingsItem.php index f646899d..8b33465c 100644 --- a/src/material/item/armor/IronLeggingsItem.php +++ b/src/material/item/armor/IronLeggingsItem.php @@ -7,7 +7,7 @@ class IronLeggingsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::IRON; + return ArmorMaterial::IRON; } public function getBaseDurability(){ diff --git a/src/material/item/armor/LeatherBootsItem.php b/src/material/item/armor/LeatherBootsItem.php index 6ec78a24..f18988d5 100644 --- a/src/material/item/armor/LeatherBootsItem.php +++ b/src/material/item/armor/LeatherBootsItem.php @@ -7,7 +7,7 @@ class LeatherBootsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::LEATHER; + return ArmorMaterial::LEATHER; } public function getBaseDurability(){ diff --git a/src/material/item/armor/LeatherCapItem.php b/src/material/item/armor/LeatherCapItem.php index 9a146839..2790bae1 100755 --- a/src/material/item/armor/LeatherCapItem.php +++ b/src/material/item/armor/LeatherCapItem.php @@ -7,7 +7,7 @@ class LeatherCapItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::LEATHER; + return ArmorMaterial::LEATHER; } public function getBaseDurability(){ diff --git a/src/material/item/armor/LeatherPantsItem.php b/src/material/item/armor/LeatherPantsItem.php index 4fc3bc74..d7ebfaf3 100644 --- a/src/material/item/armor/LeatherPantsItem.php +++ b/src/material/item/armor/LeatherPantsItem.php @@ -7,7 +7,7 @@ class LeatherPantsItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::LEATHER; + return ArmorMaterial::LEATHER; } public function getBaseDurability(){ diff --git a/src/material/item/armor/LeatherTunicItem.php b/src/material/item/armor/LeatherTunicItem.php index ceaa939a..fe63643d 100644 --- a/src/material/item/armor/LeatherTunicItem.php +++ b/src/material/item/armor/LeatherTunicItem.php @@ -7,7 +7,7 @@ class LeatherTunicItem extends ArmorItem{ } public function getMaterialDurability(){ - return Material::LEATHER; + return ArmorMaterial::LEATHER; } public function getBaseDurability(){ diff --git a/src/material/item/base/ItemAxe.php b/src/material/item/base/ItemAxe.php index 5efc1d5b..469bb551 100644 --- a/src/material/item/base/ItemAxe.php +++ b/src/material/item/base/ItemAxe.php @@ -16,5 +16,12 @@ abstract class ItemAxe extends ItemTool default => false, }; } + public function getDestroySpeed($id, $meta){ + $effMult = ItemTool::TIER_EFFICIENCY_MULTIPLIER[$this->getLevel()] ?? ItemTool::TIER_EFFICIENCY_MULTIPLIER[0]; + + $mat = StaticBlock::getMaterial($id); + if($mat == Material::$wood) return $effMult; + return parent::getDestroySpeed($id, $meta); + } } diff --git a/src/material/item/base/ItemPickaxe.php b/src/material/item/base/ItemPickaxe.php index 91666c54..9f731f9c 100644 --- a/src/material/item/base/ItemPickaxe.php +++ b/src/material/item/base/ItemPickaxe.php @@ -21,5 +21,24 @@ abstract class ItemPickaxe extends ItemTool default => false, }; } + + public function canDestroySpecial($id, $meta){ + $level = ItemTool::TIER_MINING_LEVEL[$this->getLevel()] ?? 0; + $mat = StaticBlock::getMaterial($id); + if($id == OBSIDIAN || $id == GLOWING_OBSIDIAN) return $level == 3; + if($id == DIAMOND_BLOCK || $id == DIAMOND_ORE || $id == GOLD_BLOCK || $id == GOLD_ORE || $id == REDSTONE_ORE || $id == GLOWING_REDSTONE_ORE) return $level > 1; + if($id == IRON_BLOCK || $id == IRON_ORE || $id == LAPIS_BLOCK || $id == LAPIS_ORE) return $level > 0; + if($mat == Material::$stone) return true; + return $mat == Material::$metal; + + } + + public function getDestroySpeed($id, $meta){ + $effMult = ItemTool::TIER_EFFICIENCY_MULTIPLIER[$this->getLevel()] ?? ItemTool::TIER_EFFICIENCY_MULTIPLIER[0]; + + $mat = StaticBlock::getMaterial($id); + if($mat == Material::$metal || $mat == Material::$stone) return $effMult; + return parent::getDestroySpeed($id, $meta); + } } diff --git a/src/material/item/base/ItemShovel.php b/src/material/item/base/ItemShovel.php index 20b61eba..fce7cba3 100644 --- a/src/material/item/base/ItemShovel.php +++ b/src/material/item/base/ItemShovel.php @@ -16,5 +16,15 @@ class ItemShovel extends ItemTool default => false, }; } + + public function canDestroySpecial($id, $meta){ + return $id == SNOW_LAYER || $id == SNOW_BLOCK; + } + public function getDestroySpeed($id, $meta){ + $effMult = ItemTool::TIER_EFFICIENCY_MULTIPLIER[$this->getLevel()] ?? ItemTool::TIER_EFFICIENCY_MULTIPLIER[0]; + + if($id == GRASS || $id == DIRT || $id == SAND || $id == GRAVEL || $id == SNOW_LAYER || $id == SNOW || $id == CLAY || $id == FARMLAND) return $effMult; + return parent::getDestroySpeed($id, $meta); + } } diff --git a/src/material/item/base/ItemSword.php b/src/material/item/base/ItemSword.php index 14bd259a..90679e37 100644 --- a/src/material/item/base/ItemSword.php +++ b/src/material/item/base/ItemSword.php @@ -18,6 +18,13 @@ abstract class ItemSword extends ItemTool }; } + public function canDestroySpecial($id, $meta){ + return $id == COBWEB; + } + public function getDestroySpeed($id, $meta){ + if($id == COBWEB) return 15; + return 1.5; //in 0.8.1 it is faster than other items + } public function hurtEnemy(Entity $target, Player $attacker){ $this->hurtAndBreak(1, $attacker); } diff --git a/src/material/item/base/ItemTool.php b/src/material/item/base/ItemTool.php index 061cc065..af4be2ce 100644 --- a/src/material/item/base/ItemTool.php +++ b/src/material/item/base/ItemTool.php @@ -8,6 +8,21 @@ abstract class ItemTool extends Item const IRON_LEVEL = 4; const DIAMOND_LEVEL = 5; + public const TIER_MINING_LEVEL = [ + 1 => 0, //wooden + 2 => 0, //golden + 3 => 1, //stone + 4 => 2, //iron + 5 => 3, //diamond + ]; + public const TIER_EFFICIENCY_MULTIPLIER = [ + 1 => 2.0, //wooden + 2 => 12.0, //golden + 3 => 4.0, //stone + 4 => 6.0, //iron + 5 => 8.0, //diamond + ]; + public function isTool(){ return true; } diff --git a/src/material/item/tool/ShearsItem.php b/src/material/item/tool/ShearsItem.php index db14e68c..1cc66972 100755 --- a/src/material/item/tool/ShearsItem.php +++ b/src/material/item/tool/ShearsItem.php @@ -12,4 +12,13 @@ class ShearsItem extends ItemTool{ } return parent::mineBlock($block, $player); } + + public function canDestroySpecial($id, $meta){ + return $id == COBWEB; + } + public function getDestroySpeed($id, $meta){ + if($id == COBWEB || $id == LEAVES) return 15; + if($id == WOOL) return 5; + return parent::getDestroySpeed($id, $meta); + } } \ No newline at end of file