diff --git a/src/pocketmine/block/AcaciaWoodStairs.php b/src/pocketmine/block/AcaciaWoodStairs.php index 0df975661..de34f9993 100644 --- a/src/pocketmine/block/AcaciaWoodStairs.php +++ b/src/pocketmine/block/AcaciaWoodStairs.php @@ -24,8 +24,15 @@ namespace pocketmine\block; use pocketmine\item\Item; class AcaciaWoodStairs extends Stair{ + + protected $id = self::ACACIA_WOOD_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::ACACIA_WOOD_STAIRS, $meta, "Acacia Wood Stairs"); + $this->meta = $meta; + } + + public function getName(){ + return "Acacia Wood Stairs"; } public function getDrops(Item $item){ diff --git a/src/pocketmine/block/Air.php b/src/pocketmine/block/Air.php index 6ba70d319..16840484f 100644 --- a/src/pocketmine/block/Air.php +++ b/src/pocketmine/block/Air.php @@ -20,30 +20,45 @@ */ namespace pocketmine\block; +use pocketmine\item\Item; /** * Air block */ class Air extends Transparent{ - public $isActivable = false; - public $breakable = false; - public $isFlowable = true; - public $isTransparent = true; - public $isReplaceable = true; - public $isPlaceable = false; - public $hasPhysics = false; - public $isSolid = false; - public $isFullBlock = true; + protected $id = self::AIR; protected $meta = 0; - protected $name = "Air"; - protected $hardness = 0; public function __construct(){ } + public function getName(){ + return "Air"; + } + + public function isBreakable(Item $item){ + return false; + } + + public function canBeFlowedInto(){ + return true; + } + + public function canBeReplaced(){ + return true; + } + + public function canBePlaced(){ + return false; + } + + public function isSolid(){ + return false; + } + public function getBoundingBox(){ return null; } diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index 99269e7c9..a996d837f 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -28,13 +28,25 @@ use pocketmine\network\protocol\ChatPacket; use pocketmine\Player; class Bed extends Transparent{ - public function __construct($type = 0){ - parent::__construct(self::BED_BLOCK, $type, "Bed Block"); - $this->isActivable = true; - $this->isFullBlock = false; - $this->hardness = 1; + + protected $id = self::BED_BLOCK; + + public function __construct($meta = 0){ + $this->meta = $meta; } + public function canBeActivated(){ + return true; + } + + public function getHardness(){ + return 1; + } + + public function getName(){ + return "Bed Block"; + } + protected function recalculateBoundingBox(){ return new AxisAlignedBB( $this->x, diff --git a/src/pocketmine/block/Bedrock.php b/src/pocketmine/block/Bedrock.php index 5ef5aa996..00ac97b4e 100644 --- a/src/pocketmine/block/Bedrock.php +++ b/src/pocketmine/block/Bedrock.php @@ -24,12 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Bedrock extends Solid{ + + protected $id = self::BEDROCK; + public function __construct(){ - parent::__construct(self::BEDROCK, 0, "Bedrock"); - $this->breakable = false; - $this->hardness = 18000000; + } + public function getName(){ + return "Bedrock"; + } + + public function getHardness(){ + return 18000000; + } + public function isBreakable(Item $item){ return false; } diff --git a/src/pocketmine/block/Beetroot.php b/src/pocketmine/block/Beetroot.php index e154e35b6..41c5fae43 100644 --- a/src/pocketmine/block/Beetroot.php +++ b/src/pocketmine/block/Beetroot.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class Beetroot extends Crops{ + + protected $id = self::BEETROOT_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::BEETROOT_BLOCK, $meta, "Beetroot Block"); + $this->meta = $meta; } + public function getName(){ + return "Beetroot Block"; + } + public function getDrops(Item $item){ $drops = []; if($this->meta >= 0x07){ diff --git a/src/pocketmine/block/BirchWoodStairs.php b/src/pocketmine/block/BirchWoodStairs.php index 885e6142c..bd37fa235 100644 --- a/src/pocketmine/block/BirchWoodStairs.php +++ b/src/pocketmine/block/BirchWoodStairs.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class BirchWoodStairs extends Stair{ + + protected $id = self::BIRCH_WOOD_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Birch Wood Stairs"; + } + public function getDrops(Item $item){ return [ [$this->id, 0, 1], diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index ee86407a0..c2cc34e06 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -180,7 +180,7 @@ class Block extends Position implements Metadatable{ const NETHER_BRICKS_STAIRS = 114; - const END_PORTAL = 120; + const END_PORTAL_FRAME = 120; const END_STONE = 121; const SANDSTONE_STAIRS = 128; @@ -536,30 +536,40 @@ class Block extends Position implements Metadatable{ public static $solid = null; /** @var \SplFixedArray */ public static $transparent = null; + protected $id; - protected $meta; - protected $name = "Unknown"; - protected $breakTime = 0.20; - protected $hardness = 10; - public $hasEntityCollision = false; - public $isActivable = false; - public $breakable = true; - public $isFlowable = false; - public $isSolid = true; - public $isTransparent = false; - public $isReplaceable = false; - public $isPlaceable = true; - public $hasPhysics = false; - public $isFullBlock = true; - public $lightLevel = 0; - public $x = 0; - public $y = 0; - public $z = 0; - public $frictionFactor = 0.6; + protected $meta = 0; /** @var AxisAlignedBB */ protected $boundingBox = null; + /** + * Backwards-compatibility with old way to define block properties + * + * @deprecated + * + * @param string $key + * + * @return mixed + */ + public function __get($key){ + static $map = [ + "breakTime" => "getBreakTime", + "hardness" => "getHardness", + "lightLevel" => "getLightLevel", + "frictionFactor" => "getFrictionFactor", + "name" => "getName", + "isPlaceable" => "canBePlaced", + "isReplaceable" => "canBeReplaced", + "isTransparent" => "isTransparent", + "isSolid" => "isSolid", + "isFlowable" => "canBeFlowedInto", + "isActivable" => "canBeActivated", + "hasEntityCollision" => "hasEntityCollision" + ]; + return isset($map[$key]) ? $this->{$map[$key]}() : null; + } + public static function init(){ if(self::$list === null){ self::$list = new \SplFixedArray(256); @@ -567,136 +577,136 @@ class Block extends Position implements Metadatable{ self::$lightFilter = new \SplFixedArray(256); self::$solid = new \SplFixedArray(256); self::$transparent = new \SplFixedArray(256); - self::$list[self::AIR] = Air::class;; - self::$list[self::STONE] = Stone::class;; - self::$list[self::GRASS] = Grass::class;; - self::$list[self::DIRT] = Dirt::class;; - self::$list[self::COBBLESTONE] = Cobblestone::class;; - self::$list[self::PLANKS] = Planks::class;; - self::$list[self::SAPLING] = Sapling::class;; - self::$list[self::BEDROCK] = Bedrock::class;; - self::$list[self::WATER] = Water::class;; - self::$list[self::STILL_WATER] = StillWater::class;; - self::$list[self::LAVA] = Lava::class;; - self::$list[self::STILL_LAVA] = StillLava::class;; - self::$list[self::SAND] = Sand::class;; - self::$list[self::GRAVEL] = Gravel::class;; - self::$list[self::GOLD_ORE] = GoldOre::class;; - self::$list[self::IRON_ORE] = IronOre::class;; - self::$list[self::COAL_ORE] = CoalOre::class;; - self::$list[self::WOOD] = Wood::class;; - self::$list[self::LEAVES] = Leaves::class;; - self::$list[self::SPONGE] = Sponge::class;; - self::$list[self::GLASS] = Glass::class;; - self::$list[self::LAPIS_ORE] = LapisOre::class;; - self::$list[self::LAPIS_BLOCK] = Lapis::class;; - self::$list[self::SANDSTONE] = Sandstone::class;; - self::$list[self::BED_BLOCK] = Bed::class;; - self::$list[self::COBWEB] = Cobweb::class;; - self::$list[self::TALL_GRASS] = TallGrass::class;; - self::$list[self::DEAD_BUSH] = DeadBush::class;; - self::$list[self::WOOL] = Wool::class;; - self::$list[self::DANDELION] = Dandelion::class;; - self::$list[self::POPPY] = CyanFlower::class;; - self::$list[self::BROWN_MUSHROOM] = BrownMushroom::class;; - self::$list[self::RED_MUSHROOM] = RedMushroom::class;; - self::$list[self::GOLD_BLOCK] = Gold::class;; - self::$list[self::IRON_BLOCK] = Iron::class;; - self::$list[self::DOUBLE_SLAB] = DoubleSlab::class;; - self::$list[self::SLAB] = Slab::class;; - self::$list[self::BRICKS_BLOCK] = Bricks::class;; - self::$list[self::TNT] = TNT::class;; - self::$list[self::BOOKSHELF] = Bookshelf::class;; - self::$list[self::MOSS_STONE] = MossStone::class;; - self::$list[self::OBSIDIAN] = Obsidian::class;; - self::$list[self::TORCH] = Torch::class;; - self::$list[self::FIRE] = Fire::class;; - self::$list[self::MONSTER_SPAWNER] = MonsterSpawner::class;; - self::$list[self::WOOD_STAIRS] = WoodStairs::class;; - self::$list[self::CHEST] = Chest::class;; + self::$list[self::AIR] = Air::class; + self::$list[self::STONE] = Stone::class; + self::$list[self::GRASS] = Grass::class; + self::$list[self::DIRT] = Dirt::class; + self::$list[self::COBBLESTONE] = Cobblestone::class; + self::$list[self::PLANKS] = Planks::class; + self::$list[self::SAPLING] = Sapling::class; + self::$list[self::BEDROCK] = Bedrock::class; + self::$list[self::WATER] = Water::class; + self::$list[self::STILL_WATER] = StillWater::class; + self::$list[self::LAVA] = Lava::class; + self::$list[self::STILL_LAVA] = StillLava::class; + self::$list[self::SAND] = Sand::class; + self::$list[self::GRAVEL] = Gravel::class; + self::$list[self::GOLD_ORE] = GoldOre::class; + self::$list[self::IRON_ORE] = IronOre::class; + self::$list[self::COAL_ORE] = CoalOre::class; + self::$list[self::WOOD] = Wood::class; + self::$list[self::LEAVES] = Leaves::class; + self::$list[self::SPONGE] = Sponge::class; + self::$list[self::GLASS] = Glass::class; + self::$list[self::LAPIS_ORE] = LapisOre::class; + self::$list[self::LAPIS_BLOCK] = Lapis::class; + self::$list[self::SANDSTONE] = Sandstone::class; + self::$list[self::BED_BLOCK] = Bed::class; + self::$list[self::COBWEB] = Cobweb::class; + self::$list[self::TALL_GRASS] = TallGrass::class; + self::$list[self::DEAD_BUSH] = DeadBush::class; + self::$list[self::WOOL] = Wool::class; + self::$list[self::DANDELION] = Dandelion::class; + self::$list[self::POPPY] = Poppy::class; + self::$list[self::BROWN_MUSHROOM] = BrownMushroom::class; + self::$list[self::RED_MUSHROOM] = RedMushroom::class; + self::$list[self::GOLD_BLOCK] = Gold::class; + self::$list[self::IRON_BLOCK] = Iron::class; + self::$list[self::DOUBLE_SLAB] = DoubleSlab::class; + self::$list[self::SLAB] = Slab::class; + self::$list[self::BRICKS_BLOCK] = Bricks::class; + self::$list[self::TNT] = TNT::class; + self::$list[self::BOOKSHELF] = Bookshelf::class; + self::$list[self::MOSS_STONE] = MossStone::class; + self::$list[self::OBSIDIAN] = Obsidian::class; + self::$list[self::TORCH] = Torch::class; + self::$list[self::FIRE] = Fire::class; + self::$list[self::MONSTER_SPAWNER] = MonsterSpawner::class; + self::$list[self::WOOD_STAIRS] = WoodStairs::class; + self::$list[self::CHEST] = Chest::class; - self::$list[self::DIAMOND_ORE] = DiamondOre::class;; - self::$list[self::DIAMOND_BLOCK] = Diamond::class;; - self::$list[self::WORKBENCH] = Workbench::class;; - self::$list[self::WHEAT_BLOCK] = Wheat::class;; - self::$list[self::FARMLAND] = Farmland::class;; - self::$list[self::FURNACE] = Furnace::class;; - self::$list[self::BURNING_FURNACE] = BurningFurnace::class;; - self::$list[self::SIGN_POST] = SignPost::class;; - self::$list[self::WOOD_DOOR_BLOCK] = WoodDoor::class;; - self::$list[self::LADDER] = Ladder::class;; + self::$list[self::DIAMOND_ORE] = DiamondOre::class; + self::$list[self::DIAMOND_BLOCK] = Diamond::class; + self::$list[self::WORKBENCH] = Workbench::class; + self::$list[self::WHEAT_BLOCK] = Wheat::class; + self::$list[self::FARMLAND] = Farmland::class; + self::$list[self::FURNACE] = Furnace::class; + self::$list[self::BURNING_FURNACE] = BurningFurnace::class; + self::$list[self::SIGN_POST] = SignPost::class; + self::$list[self::WOOD_DOOR_BLOCK] = WoodDoor::class; + self::$list[self::LADDER] = Ladder::class; - self::$list[self::COBBLESTONE_STAIRS] = CobblestoneStairs::class;; - self::$list[self::WALL_SIGN] = WallSign::class;; + self::$list[self::COBBLESTONE_STAIRS] = CobblestoneStairs::class; + self::$list[self::WALL_SIGN] = WallSign::class; - self::$list[self::IRON_DOOR_BLOCK] = IronDoor::class;; - self::$list[self::REDSTONE_ORE] = RedstoneOre::class;; - self::$list[self::GLOWING_REDSTONE_ORE] = GlowingRedstoneOre::class;; + self::$list[self::IRON_DOOR_BLOCK] = IronDoor::class; + self::$list[self::REDSTONE_ORE] = RedstoneOre::class; + self::$list[self::GLOWING_REDSTONE_ORE] = GlowingRedstoneOre::class; - self::$list[self::SNOW_LAYER] = SnowLayer::class;; - self::$list[self::ICE] = Ice::class;; - self::$list[self::SNOW_BLOCK] = Snow::class;; - self::$list[self::CACTUS] = Cactus::class;; - self::$list[self::CLAY_BLOCK] = Clay::class;; - self::$list[self::SUGARCANE_BLOCK] = Sugarcane::class;; + self::$list[self::SNOW_LAYER] = SnowLayer::class; + self::$list[self::ICE] = Ice::class; + self::$list[self::SNOW_BLOCK] = Snow::class; + self::$list[self::CACTUS] = Cactus::class; + self::$list[self::CLAY_BLOCK] = Clay::class; + self::$list[self::SUGARCANE_BLOCK] = Sugarcane::class; - self::$list[self::FENCE] = Fence::class;; - self::$list[self::PUMPKIN] = Pumpkin::class;; - self::$list[self::NETHERRACK] = Netherrack::class;; - self::$list[self::SOUL_SAND] = SoulSand::class;; - self::$list[self::GLOWSTONE_BLOCK] = Glowstone::class;; + self::$list[self::FENCE] = Fence::class; + self::$list[self::PUMPKIN] = Pumpkin::class; + self::$list[self::NETHERRACK] = Netherrack::class; + self::$list[self::SOUL_SAND] = SoulSand::class; + self::$list[self::GLOWSTONE_BLOCK] = Glowstone::class; - self::$list[self::LIT_PUMPKIN] = LitPumpkin::class;; - self::$list[self::CAKE_BLOCK] = Cake::class;; + self::$list[self::LIT_PUMPKIN] = LitPumpkin::class; + self::$list[self::CAKE_BLOCK] = Cake::class; - self::$list[self::TRAPDOOR] = Trapdoor::class;; + self::$list[self::TRAPDOOR] = Trapdoor::class; - self::$list[self::STONE_BRICKS] = StoneBricks::class;; + self::$list[self::STONE_BRICKS] = StoneBricks::class; - self::$list[self::IRON_BARS] = IronBars::class;; - self::$list[self::GLASS_PANE] = GlassPane::class;; - self::$list[self::MELON_BLOCK] = Melon::class;; - self::$list[self::PUMPKIN_STEM] = PumpkinStem::class;; - self::$list[self::MELON_STEM] = MelonStem::class;; - self::$list[self::VINE] = Vine::class;; - self::$list[self::FENCE_GATE] = FenceGate::class;; - self::$list[self::BRICK_STAIRS] = BrickStairs::class;; - self::$list[self::STONE_BRICK_STAIRS] = StoneBrickStairs::class;; + self::$list[self::IRON_BARS] = IronBars::class; + self::$list[self::GLASS_PANE] = GlassPane::class; + self::$list[self::MELON_BLOCK] = Melon::class; + self::$list[self::PUMPKIN_STEM] = PumpkinStem::class; + self::$list[self::MELON_STEM] = MelonStem::class; + self::$list[self::VINE] = Vine::class; + self::$list[self::FENCE_GATE] = FenceGate::class; + self::$list[self::BRICK_STAIRS] = BrickStairs::class; + self::$list[self::STONE_BRICK_STAIRS] = StoneBrickStairs::class; - self::$list[self::MYCELIUM] = Mycelium::class;; - self::$list[self::NETHER_BRICKS] = NetherBrick::class;; + self::$list[self::MYCELIUM] = Mycelium::class; + self::$list[self::NETHER_BRICKS] = NetherBrick::class; - self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class;; + self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class; - self::$list[self::END_PORTAL] = EndPortal::class;; - self::$list[self::END_STONE] = EndStone::class;; - self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class;; - self::$list[self::EMERALD_ORE] = EmeraldOre::class;; + self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class; + self::$list[self::END_STONE] = EndStone::class; + self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class; + self::$list[self::EMERALD_ORE] = EmeraldOre::class; - self::$list[self::EMERALD_BLOCK] = Emerald::class;; - self::$list[self::SPRUCE_WOOD_STAIRS] = SpruceWoodStairs::class;; - self::$list[self::BIRCH_WOOD_STAIRS] = BirchWoodStairs::class;; - self::$list[self::JUNGLE_WOOD_STAIRS] = JungleWoodStairs::class;; - self::$list[self::STONE_WALL] = StoneWall::class;; + self::$list[self::EMERALD_BLOCK] = Emerald::class; + self::$list[self::SPRUCE_WOOD_STAIRS] = SpruceWoodStairs::class; + self::$list[self::BIRCH_WOOD_STAIRS] = BirchWoodStairs::class; + self::$list[self::JUNGLE_WOOD_STAIRS] = JungleWoodStairs::class; + self::$list[self::STONE_WALL] = StoneWall::class; - self::$list[self::CARROT_BLOCK] = Carrot::class;; - self::$list[self::POTATO_BLOCK] = Potato::class;; + self::$list[self::CARROT_BLOCK] = Carrot::class; + self::$list[self::POTATO_BLOCK] = Potato::class; - self::$list[self::QUARTZ_BLOCK] = Quartz::class;; - self::$list[self::QUARTZ_STAIRS] = QuartzStairs::class;; - self::$list[self::DOUBLE_WOOD_SLAB] = DoubleWoodSlab::class;; - self::$list[self::WOOD_SLAB] = WoodSlab::class;; - self::$list[self::STAINED_CLAY] = StainedClay::class;; + self::$list[self::QUARTZ_BLOCK] = Quartz::class; + self::$list[self::QUARTZ_STAIRS] = QuartzStairs::class; + self::$list[self::DOUBLE_WOOD_SLAB] = DoubleWoodSlab::class; + self::$list[self::WOOD_SLAB] = WoodSlab::class; + self::$list[self::STAINED_CLAY] = StainedClay::class; - self::$list[self::LEAVES2] = Leaves2::class;; - self::$list[self::WOOD2] = Wood2::class;; - self::$list[self::ACACIA_WOOD_STAIRS] = AcaciaWoodStairs::class;; - self::$list[self::DARK_OAK_WOOD_STAIRS] = DarkOakWoodStairs::class;; + self::$list[self::LEAVES2] = Leaves2::class; + self::$list[self::WOOD2] = Wood2::class; + self::$list[self::ACACIA_WOOD_STAIRS] = AcaciaWoodStairs::class; + self::$list[self::DARK_OAK_WOOD_STAIRS] = DarkOakWoodStairs::class; - self::$list[self::HAY_BALE] = HayBale::class;; - self::$list[self::CARPET] = Carpet::class;; - self::$list[self::HARDENED_CLAY] = HardenedClay::class;; - self::$list[self::COAL_BLOCK] = Coal::class;; + self::$list[self::HAY_BALE] = HayBale::class; + self::$list[self::CARPET] = Carpet::class; + self::$list[self::HARDENED_CLAY] = HardenedClay::class; + self::$list[self::COAL_BLOCK] = Coal::class; self::$list[self::FENCE_GATE_SPRUCE] = FenceGateSpruce::class; self::$list[self::FENCE_GATE_BIRCH] = FenceGateBirch::class; @@ -719,12 +729,12 @@ class Block extends Position implements Metadatable{ if($class !== null){ /** @var Block $block */ $block = new $class(); - self::$solid[$id] = (bool) $block->isSolid; - self::$transparent[$id] = (bool) $block->isTransparent; - self::$light[$id] = (int) $block->lightLevel; + self::$solid[$id] = $block->isSolid(); + self::$transparent[$id] = $block->isTransparent(); + self::$light[$id] = $block->getLightLevel(); - if($block->isSolid){ - if($block->isTransparent){ + if($block->isSolid()){ + if($block->isTransparent()){ if($block instanceof Liquid or $block instanceof Ice){ self::$lightFilter[$id] = 2; }else{ @@ -775,12 +785,10 @@ class Block extends Position implements Metadatable{ /** * @param int $id * @param int $meta - * @param string $name */ - public function __construct($id, $meta = 0, $name = "Unknown"){ + public function __construct($id, $meta = 0){ $this->id = (int) $id; $this->meta = (int) $meta; - $this->name = $name; } /** @@ -809,7 +817,7 @@ class Block extends Position implements Metadatable{ * @return bool */ public function isBreakable(Item $item){ - return $this->breakable; + return true; } /** @@ -843,21 +851,86 @@ class Block extends Position implements Metadatable{ * @return bool */ public function onActivate(Item $item, Player $player = null){ - return $this->isActivable; + return false; } /** * @return int */ - final public function getHardness(){ - return $this->hardness; + public function getHardness(){ + return 10; + } + + /** + * @return float + */ + public function getFrictionFactor(){ + return 0.6; + } + + /** + * @return int 0-15 + */ + public function getLightLevel(){ + return 0; + } + + /** + * AKA: Block->isPlaceable + * + * @return bool + */ + public function canBePlaced(){ + return true; + } + + /** + * AKA: Block->isReplaceable + * + * @return bool + */ + public function canBeReplaced(){ + return false; + } + + /** + * @return bool + */ + public function isTransparent(){ + return false; + } + + public function isSolid(){ + return true; + } + + /** + * AKA: Block->isFlowable + * + * @return bool + */ + public function canBeFlowedInto(){ + return false; + } + + /** + * AKA: Block->isActivable + * + * @return bool + */ + public function canBeActivated(){ + return false; + } + + public function hasEntityCollision(){ + return false; } /** * @return string */ - final public function getName(){ - return $this->name; + public function getName(){ + return "Unknown"; } /** @@ -922,7 +995,7 @@ class Block extends Position implements Metadatable{ * @return float */ public function getBreakTime(Item $item){ - return $this->breakTime; + return 0.20; } /** @@ -945,8 +1018,8 @@ class Block extends Position implements Metadatable{ /** * @return string */ - final public function __toString(){ - return "Block " . $this->name . " (" . $this->id . ":" . $this->meta . ")"; + public function __toString(){ + return "Block[" . $this->getName() . "] (" . $this->id . ":" . $this->meta . ")"; } /** diff --git a/src/pocketmine/block/Bookshelf.php b/src/pocketmine/block/Bookshelf.php index 6cabe255e..dd0f97278 100644 --- a/src/pocketmine/block/Bookshelf.php +++ b/src/pocketmine/block/Bookshelf.php @@ -23,9 +23,19 @@ namespace pocketmine\block; class Bookshelf extends Solid{ + + protected $id = self::BOOKSHELF; + public function __construct(){ - parent::__construct(self::BOOKSHELF, 0, "Bookshelf"); - $this->hardness = 7.5; + } + public function getName(){ + return "Bookshelf"; + } + + public function getHardness(){ + return 7.5; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/BrickStairs.php b/src/pocketmine/block/BrickStairs.php index ec63c17f9..3b2ae72cb 100644 --- a/src/pocketmine/block/BrickStairs.php +++ b/src/pocketmine/block/BrickStairs.php @@ -23,8 +23,15 @@ namespace pocketmine\block; class BrickStairs extends Stair{ + + protected $id = self::BRICK_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::BRICK_STAIRS, $meta, "Brick Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Brick Stairs"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/Bricks.php b/src/pocketmine/block/Bricks.php index bd61f37f3..f95e2c4a6 100644 --- a/src/pocketmine/block/Bricks.php +++ b/src/pocketmine/block/Bricks.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Bricks extends Solid{ + + protected $id = self::BRICKS_BLOCK; + public function __construct(){ - parent::__construct(self::BRICKS_BLOCK, 0, "Bricks"); - $this->hardness = 30; + } + public function getHardness(){ + return 30; + } + + public function getName(){ + return "Bricks"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/BrownMushroom.php b/src/pocketmine/block/BrownMushroom.php index addc2294a..85b09a05b 100644 --- a/src/pocketmine/block/BrownMushroom.php +++ b/src/pocketmine/block/BrownMushroom.php @@ -27,13 +27,20 @@ use pocketmine\Player; class BrownMushroom extends Flowable{ - public $lightLevel = 1; + protected $id = self::BROWN_MUSHROOM; - public function __construct(){ - parent::__construct(self::BROWN_MUSHROOM, 0, "Brown Mushroom"); - $this->hardness = 0; + public function __construct($meta = 0){ + $this->meta = $meta; } + public function getName(){ + return "Brown Mushroom"; + } + + public function getLightLevel(){ + return 1; + } + public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index 90b9450fd..8bff00704 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -33,14 +33,28 @@ use pocketmine\tile\Tile; class BurningFurnace extends Solid{ - public $lightLevel = 13; + protected $id = self::BURNING_FURNACE; public function __construct($meta = 0){ - parent::__construct(self::BURNING_FURNACE, $meta, "Burning Furnace"); - $this->isActivable = true; - $this->hardness = 17.5; + $this->meta = $meta; } + public function getName(){ + return "Burning Furnace"; + } + + public function canBeActivated(){ + return true; + } + + public function getHardness(){ + return 17.5; + } + + public function getLightLevel(){ + return 13; + } + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ $faces = [ 0 => 4, diff --git a/src/pocketmine/block/Cactus.php b/src/pocketmine/block/Cactus.php index 54ade3d0e..0702a735f 100644 --- a/src/pocketmine/block/Cactus.php +++ b/src/pocketmine/block/Cactus.php @@ -34,14 +34,24 @@ use pocketmine\Server; class Cactus extends Transparent{ - public $hasEntityCollision = true; + protected $id = self::CACTUS; public function __construct($meta = 0){ - parent::__construct(self::CACTUS, $meta, "Cactus"); - $this->isFullBlock = false; - $this->hardness = 2; + $this->meta = $meta; } + public function getHardness(){ + return 2; + } + + public function hasEntityCollision(){ + return true; + } + + public function getName(){ + return "Cactus"; + } + protected function recalculateBoundingBox(){ return new AxisAlignedBB( diff --git a/src/pocketmine/block/Cake.php b/src/pocketmine/block/Cake.php index bee2711aa..ed60ab55e 100644 --- a/src/pocketmine/block/Cake.php +++ b/src/pocketmine/block/Cake.php @@ -29,14 +29,25 @@ use pocketmine\Player; use pocketmine\Server; class Cake extends Transparent{ + + protected $id = self::CAKE_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::CAKE_BLOCK, 0, "Cake Block"); - $this->isFullBlock = false; - $this->isActivable = true; - $this->meta = $meta & 0x07; - $this->hardness = 2.5; + $this->meta = $meta & 0x07; } + public function canBeActivated(){ + return true; + } + + public function getHardness(){ + return 2.5; + } + + public function getName(){ + return "Cake Block"; + } + protected function recalculateBoundingBox(){ $f = (1 + $this->getDamage() * 2) / 16; diff --git a/src/pocketmine/block/Carpet.php b/src/pocketmine/block/Carpet.php index 4a07706a5..0d799cbb4 100644 --- a/src/pocketmine/block/Carpet.php +++ b/src/pocketmine/block/Carpet.php @@ -27,32 +27,39 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\Player; class Carpet extends Flowable{ + + protected $id = self::CARPET; + public function __construct($meta = 0){ - parent::__construct(self::CARPET, $meta, "Carpet"); - $names = [ - 0 => "White Carpet", - 1 => "Orange Carpet", - 2 => "Magenta Carpet", - 3 => "Light Blue Carpet", - 4 => "Yellow Carpet", - 5 => "Lime Carpet", - 6 => "Pink Carpet", - 7 => "Gray Carpet", - 8 => "Light Gray Carpet", - 9 => "Cyan Carpet", - 10 => "Purple Carpet", - 11 => "Blue Carpet", - 12 => "Brown Carpet", - 13 => "Green Carpet", - 14 => "Red Carpet", - 15 => "Black Carpet", - ]; - $this->name = $names[$this->meta]; - $this->hardness = 0; - $this->isFullBlock = false; - $this->isSolid = true; + $this->meta = $meta; } + public function isSolid(){ + return true; + } + + public function getName(){ + static $names = [ + 0 => "White Carpet", + 1 => "Orange Carpet", + 2 => "Magenta Carpet", + 3 => "Light Blue Carpet", + 4 => "Yellow Carpet", + 5 => "Lime Carpet", + 6 => "Pink Carpet", + 7 => "Gray Carpet", + 8 => "Light Gray Carpet", + 9 => "Cyan Carpet", + 10 => "Purple Carpet", + 11 => "Blue Carpet", + 12 => "Brown Carpet", + 13 => "Green Carpet", + 14 => "Red Carpet", + 15 => "Black Carpet", + ]; + return $names[$this->meta]; + } + protected function recalculateBoundingBox(){ return new AxisAlignedBB( diff --git a/src/pocketmine/block/Carrot.php b/src/pocketmine/block/Carrot.php index a8fd22353..b1ca5f2b7 100644 --- a/src/pocketmine/block/Carrot.php +++ b/src/pocketmine/block/Carrot.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class Carrot extends Crops{ + + protected $id = self::CARROT_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::CARROT_BLOCK, $meta, "Carrot Block"); + $this->meta = $meta; } + public function getName(){ + return "Carrot Block"; + } + public function getDrops(Item $item){ $drops = []; if($this->meta >= 0x07){ diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index ae8d27876..1bc24bc7a 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -34,16 +34,25 @@ use pocketmine\tile\Tile; class Chest extends Transparent{ - const SLOTS = 27; + protected $id = self::CHEST; public function __construct($meta = 0){ - parent::__construct(self::CHEST, $meta, "Chest"); - $this->isActivable = true; - $this->hardness = 15; + $this->meta = $meta; } - protected function recalculateBoundingBox(){ + public function canBeActivated(){ + return true; + } + public function getHardness(){ + return 15; + } + + public function getName(){ + return "Chest"; + } + + protected function recalculateBoundingBox(){ return new AxisAlignedBB( $this->x + 0.0625, $this->y, diff --git a/src/pocketmine/block/Clay.php b/src/pocketmine/block/Clay.php index 8e61c95ff..fdc27e00b 100644 --- a/src/pocketmine/block/Clay.php +++ b/src/pocketmine/block/Clay.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Clay extends Solid{ + + protected $id = self::CLAY_BLOCK; + public function __construct(){ - parent::__construct(self::CLAY_BLOCK, 0, "Clay Block"); - $this->hardness = 3; + } + public function getHardness(){ + return 3; + } + + public function getName(){ + return "Clay Block"; + } + public function getDrops(Item $item){ return [ [Item::CLAY, 0, 4], diff --git a/src/pocketmine/block/Coal.php b/src/pocketmine/block/Coal.php index ab25433ba..b72576ca4 100644 --- a/src/pocketmine/block/Coal.php +++ b/src/pocketmine/block/Coal.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Coal extends Solid{ + + protected $id = self::COAL_BLOCK; + public function __construct(){ - parent::__construct(self::COAL_BLOCK, 0, "Coal Block"); - $this->hardness = 30; + } + public function getHardness(){ + return 30; + } + + public function getName(){ + return "Coal Block"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/CoalOre.php b/src/pocketmine/block/CoalOre.php index 35baf4fc1..7b07afee9 100644 --- a/src/pocketmine/block/CoalOre.php +++ b/src/pocketmine/block/CoalOre.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class CoalOre extends Solid{ + + protected $id = self::COAL_ORE; + public function __construct(){ - parent::__construct(self::COAL_ORE, 0, "Coal Ore"); - $this->hardness = 15; + } + public function getHardness(){ + return 15; + } + + public function getName(){ + return "Coal Ore"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/Cobblestone.php b/src/pocketmine/block/Cobblestone.php index 53f6ec566..a318ea3c5 100644 --- a/src/pocketmine/block/Cobblestone.php +++ b/src/pocketmine/block/Cobblestone.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Cobblestone extends Solid{ + + protected $id = self::COBBLESTONE; + public function __construct(){ - parent::__construct(self::COBBLESTONE, 0, "Cobblestone"); - $this->hardness = 30; + } + public function getName(){ + return "Cobblestone"; + } + + public function getHardness(){ + return 30; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/CobblestoneStairs.php b/src/pocketmine/block/CobblestoneStairs.php index f63780ac3..155786434 100644 --- a/src/pocketmine/block/CobblestoneStairs.php +++ b/src/pocketmine/block/CobblestoneStairs.php @@ -23,8 +23,15 @@ namespace pocketmine\block; class CobblestoneStairs extends Stair{ + + protected $id = self::COBBLESTONE_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Cobblestone Stairs"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/Cobweb.php b/src/pocketmine/block/Cobweb.php index 96c711525..0dbc7cc7f 100644 --- a/src/pocketmine/block/Cobweb.php +++ b/src/pocketmine/block/Cobweb.php @@ -26,20 +26,30 @@ use pocketmine\item\Item; class Cobweb extends Flowable{ - public $hasEntityCollision = true; + protected $id = self::COBWEB; public function __construct(){ - parent::__construct(self::COBWEB, 0, "Cobweb"); - $this->isSolid = true; - $this->isFullBlock = false; - $this->hardness = 25; + } + public function hasEntityCollision(){ + return true; + } + + public function getName(){ + return "Cobweb"; + } + + public function getHardness(){ + return 25; + } + public function onEntityCollide(Entity $entity){ $entity->fallDistance = 0; } public function getDrops(Item $item){ + //TODO: correct drops return []; } } \ No newline at end of file diff --git a/src/pocketmine/block/Crops.php b/src/pocketmine/block/Crops.php index f7241c186..7a52ff751 100644 --- a/src/pocketmine/block/Crops.php +++ b/src/pocketmine/block/Crops.php @@ -29,13 +29,9 @@ use pocketmine\Server; abstract class Crops extends Flowable{ - public $isActivable = true; - public $hardness = 0; - - - public function getBoundingBox(){ - return null; - } + public function canBeActivated(){ + return true; + } public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ $down = $this->getSide(0); diff --git a/src/pocketmine/block/Dandelion.php b/src/pocketmine/block/Dandelion.php index 4dd1ead8c..052e15ac4 100644 --- a/src/pocketmine/block/Dandelion.php +++ b/src/pocketmine/block/Dandelion.php @@ -26,14 +26,16 @@ use pocketmine\level\Level; use pocketmine\Player; class Dandelion extends Flowable{ + + protected $id = self::DANDELION; + public function __construct(){ - parent::__construct(self::DANDELION, 0, "Dandelion"); - $this->hardness = 0; + } - public function getBoundingBox(){ - return null; - } + public function getName(){ + return "Dandelion"; + } public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ @@ -49,7 +51,7 @@ class Dandelion extends Flowable{ public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->isTransparent === true){ + if($this->getSide(0)->isTransparent() === true){ $this->getLevel()->useBreakOn($this); return Level::BLOCK_UPDATE_NORMAL; diff --git a/src/pocketmine/block/DarkOakWoodStairs.php b/src/pocketmine/block/DarkOakWoodStairs.php index 28d14c12d..03ca2859b 100644 --- a/src/pocketmine/block/DarkOakWoodStairs.php +++ b/src/pocketmine/block/DarkOakWoodStairs.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class DarkOakWoodStairs extends Stair{ + + protected $id = self::DARK_OAK_WOOD_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::DARK_OAK_WOOD_STAIRS, $meta, "Dark Oak Wood Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Dark Oak Wood Stairs"; + } + public function getDrops(Item $item){ return [ [$this->id, 0, 1], diff --git a/src/pocketmine/block/DeadBush.php b/src/pocketmine/block/DeadBush.php index 6bf63019a..0080d58c8 100644 --- a/src/pocketmine/block/DeadBush.php +++ b/src/pocketmine/block/DeadBush.php @@ -24,21 +24,22 @@ namespace pocketmine\block; use pocketmine\level\Level; class DeadBush extends Flowable{ - public function __construct(){ - parent::__construct(self::DEAD_BUSH, 0, "Dead Bush"); - //$this->isReplaceable = true; - $this->hardness = 0; + + protected $id = self::DEAD_BUSH; + + public function __construct($meta = 0){ + $this->meta = $meta; } - public function getBoundingBox(){ - return null; - } + public function getName(){ + return "Dead Bush"; + } public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ - if($this->getSide(0)->isTransparent === true){ //Replace with common break method - $this->getLevel()->setBlock($this, new Air(), false, false, true); + if($this->getSide(0)->isTransparent() === true){ + $this->getLevel()->useBreakOn($this); return Level::BLOCK_UPDATE_NORMAL; } diff --git a/src/pocketmine/block/Diamond.php b/src/pocketmine/block/Diamond.php index a80a05543..6c544ea93 100644 --- a/src/pocketmine/block/Diamond.php +++ b/src/pocketmine/block/Diamond.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Diamond extends Solid{ + + protected $id = self::DIAMOND_BLOCK; + public function __construct(){ - parent::__construct(self::DIAMOND_BLOCK, 0, "Diamond Block"); - $this->hardness = 30; + } + public function getHardness(){ + return 30; + } + + public function getName(){ + return "Diamond Block"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/DiamondOre.php b/src/pocketmine/block/DiamondOre.php index 2eab1db2d..fe8766aa7 100644 --- a/src/pocketmine/block/DiamondOre.php +++ b/src/pocketmine/block/DiamondOre.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class DiamondOre extends Solid{ + + protected $id = self::DIAMOND_ORE; + public function __construct(){ - parent::__construct(self::DIAMOND_ORE, 0, "Diamond Ore"); - $this->hardness = 15; + } + public function getHardness(){ + return 15; + } + + public function getName(){ + return "Diamond Ore"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/Dirt.php b/src/pocketmine/block/Dirt.php index 45e4b81b7..ce90f253b 100644 --- a/src/pocketmine/block/Dirt.php +++ b/src/pocketmine/block/Dirt.php @@ -26,16 +26,24 @@ use pocketmine\Player; class Dirt extends Solid{ - public $isActivable = true; - protected $hardness = 2.5; protected $id = self::DIRT; - protected $meta = 0; - protected $name = "Dirt"; public function __construct(){ } + public function canBeActivated(){ + return true; + } + + public function getHardness(){ + return 2.5; + } + + public function getName(){ + return "Dirt"; + } + public function onActivate(Item $item, Player $player = null){ if($item->isHoe()){ $item->useOn($this); diff --git a/src/pocketmine/block/Door.php b/src/pocketmine/block/Door.php index 770264c47..0c263ad6e 100644 --- a/src/pocketmine/block/Door.php +++ b/src/pocketmine/block/Door.php @@ -30,10 +30,14 @@ use pocketmine\Server; abstract class Door extends Transparent{ - public function __construct($id, $meta = 0, $name = "Unknown"){ - parent::__construct($id, $meta, $name); - $this->isSolid = false; - } + + public function canBeActivated(){ + return true; + } + + public function isSolid(){ + return false; + } private function getFullDamage(){ $damage = $this->getDamage(); diff --git a/src/pocketmine/block/DoubleSlab.php b/src/pocketmine/block/DoubleSlab.php index 038f0f5bc..8ca344234 100644 --- a/src/pocketmine/block/DoubleSlab.php +++ b/src/pocketmine/block/DoubleSlab.php @@ -24,22 +24,31 @@ namespace pocketmine\block; use pocketmine\item\Item; class DoubleSlab extends Solid{ + + protected $id = self::DOUBLE_SLAB; + public function __construct($meta = 0){ - parent::__construct(self::DOUBLE_SLAB, $meta, "Double Slab"); - $names = [ - 0 => "Stone", - 1 => "Sandstone", - 2 => "Wooden", - 3 => "Cobblestone", - 4 => "Brick", - 5 => "Stone Brick", - 6 => "Quartz", - 7 => "", - ]; - $this->name = "Double " . $names[$this->meta & 0x07] . " Slab"; - $this->hardness = 30; + $this->meta = $meta; } + public function getHardness(){ + return 30; + } + + public function getName(){ + static $names = [ + 0 => "Stone", + 1 => "Sandstone", + 2 => "Wooden", + 3 => "Cobblestone", + 4 => "Brick", + 5 => "Stone Brick", + 6 => "Quartz", + 7 => "", + ]; + return "Double " . $names[$this->meta & 0x07] . " Slab"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/DoubleWoodSlab.php b/src/pocketmine/block/DoubleWoodSlab.php index deeea59f2..ea193705a 100644 --- a/src/pocketmine/block/DoubleWoodSlab.php +++ b/src/pocketmine/block/DoubleWoodSlab.php @@ -24,20 +24,31 @@ namespace pocketmine\block; use pocketmine\item\Item; class DoubleWoodSlab extends Solid{ + + protected $id = self::DOUBLE_WOOD_SLAB; + public function __construct($meta = 0){ - parent::__construct(self::DOUBLE_WOOD_SLAB, $meta, "Double Wooden Slab"); - $names = [ - 0 => "Oak", - 1 => "Spruce", - 2 => "Birch", - 3 => "Jungle", - 4 => "Acacia", - 5 => "Dark Oak", - ]; - $this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab"; - $this->hardness = 15; + $this->meta = $meta; } + public function getHardness(){ + return 15; + } + + public function getName(){ + static $names = [ + 0 => "Oak", + 1 => "Spruce", + 2 => "Birch", + 3 => "Jungle", + 4 => "Acacia", + 5 => "Dark Oak", + 6 => "", + 7 => "" + ]; + return "Double " . $names[$this->meta & 0x07] . " Wooden Slab"; + } + public function getBreakTime(Item $item){ switch($item->isAxe()){ case 5: diff --git a/src/pocketmine/block/Emerald.php b/src/pocketmine/block/Emerald.php index 916cdda8d..4ffbf3e2d 100644 --- a/src/pocketmine/block/Emerald.php +++ b/src/pocketmine/block/Emerald.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Emerald extends Solid{ + + protected $id = self::EMERALD_BLOCK; + public function __construct(){ - parent::__construct(self::EMERALD_BLOCK, 0, "Emerald Block"); - $this->hardness = 30; + } + public function getHardness(){ + return 30; + } + + public function getName(){ + return "Emerald Block"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/EmeraldOre.php b/src/pocketmine/block/EmeraldOre.php index 859804a5b..11c753fcb 100644 --- a/src/pocketmine/block/EmeraldOre.php +++ b/src/pocketmine/block/EmeraldOre.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class EmeraldOre extends Solid{ + + protected $id = self::EMERALD_ORE; + public function __construct(){ - parent::__construct(self::EMERALD_ORE, 0, "Emerald Ore"); - $this->hardness = 15; + } + public function getName(){ + return "Emerald Ore"; + } + + public function getHardness(){ + return 15; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/EndPortal.php b/src/pocketmine/block/EndPortalFrame.php similarity index 71% rename from src/pocketmine/block/EndPortal.php rename to src/pocketmine/block/EndPortalFrame.php index be2772865..8ab3f0671 100644 --- a/src/pocketmine/block/EndPortal.php +++ b/src/pocketmine/block/EndPortalFrame.php @@ -21,17 +21,33 @@ namespace pocketmine\block; +use pocketmine\item\Item; use pocketmine\math\AxisAlignedBB; -class EndPortal extends Solid{ +class EndPortalFrame extends Solid{ - public $lightLevel = 1; + protected $id = self::END_PORTAL_FRAME; public function __construct($meta = 0){ - parent::__construct(self::END_PORTAL, $meta, "End Portal"); - $this->hardness = 18000000; + $this->meta = $meta; } + public function getLightLevel(){ + return 1; + } + + public function getName(){ + return "End Portal Frame"; + } + + public function getHardness(){ + return 18000000; + } + + public function isBreakable(Item $item){ + return false; + } + protected function recalculateBoundingBox(){ return new AxisAlignedBB( diff --git a/src/pocketmine/block/EndStone.php b/src/pocketmine/block/EndStone.php index 42d887702..1f0ee4ece 100644 --- a/src/pocketmine/block/EndStone.php +++ b/src/pocketmine/block/EndStone.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class EndStone extends Solid{ + + protected $id = self::END_STONE; + public function __construct(){ - parent::__construct(self::END_STONE, 0, "End Stone"); - $this->hardness = 45; + } + public function getName(){ + return "End Stone"; + } + + public function getHardness(){ + return 45; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/Fallable.php b/src/pocketmine/block/Fallable.php index 01711fe10..59d184b15 100644 --- a/src/pocketmine/block/Fallable.php +++ b/src/pocketmine/block/Fallable.php @@ -34,8 +34,6 @@ use pocketmine\Player; abstract class Fallable extends Solid{ - public $hasPhysics = true; - public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ $ret = $this->getLevel()->setBlock($this, $this, true, true); @@ -43,7 +41,7 @@ abstract class Fallable extends Solid{ } public function onUpdate($type){ - if($this->hasPhysics === true and $type === Level::BLOCK_UPDATE_NORMAL){ + if($type === Level::BLOCK_UPDATE_NORMAL){ $down = $this->getSide(0); if($down->getID() === self::AIR or ($down instanceof Liquid)){ $fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [ diff --git a/src/pocketmine/block/Farmland.php b/src/pocketmine/block/Farmland.php index 674681b59..0a4e9dbd9 100644 --- a/src/pocketmine/block/Farmland.php +++ b/src/pocketmine/block/Farmland.php @@ -25,13 +25,22 @@ use pocketmine\item\Item; use pocketmine\math\AxisAlignedBB; class Farmland extends Solid{ + + protected $id = self::FARMLAND; + public function __construct($meta = 0){ - parent::__construct(self::FARMLAND, $meta, "Farmland"); - $this->hardness = 3; + $this->meta = $meta; } - protected function recalculateBoundingBox(){ + public function getName(){ + return "Farmland"; + } + public function getHardness(){ + return 3; + } + + protected function recalculateBoundingBox(){ return new AxisAlignedBB( $this->x, $this->y, diff --git a/src/pocketmine/block/Fence.php b/src/pocketmine/block/Fence.php index 6a59263e6..0c46deec5 100644 --- a/src/pocketmine/block/Fence.php +++ b/src/pocketmine/block/Fence.php @@ -24,12 +24,21 @@ namespace pocketmine\block; use pocketmine\math\AxisAlignedBB; class Fence extends Transparent{ + + protected $id = self::FENCE; + public function __construct(){ - parent::__construct(self::FENCE, 0, "Oak Fence"); - $this->isFullBlock = false; - $this->hardness = 15; + } + public function getHardness(){ + return 15; + } + + public function getName(){ + return "Oak Fence"; + } + protected function recalculateBoundingBox(){ $flag = $this->canConnect($this->getSide(2)); diff --git a/src/pocketmine/block/FenceAcacia.php b/src/pocketmine/block/FenceAcacia.php index 0cc20e71f..947b9c466 100644 --- a/src/pocketmine/block/FenceAcacia.php +++ b/src/pocketmine/block/FenceAcacia.php @@ -22,9 +22,10 @@ namespace pocketmine\block; class FenceAcacia extends Fence{ - public function __construct(){ - Transparent::__construct(self::FENCE_ACACIA, 0, "Acacia Fence"); - $this->isFullBlock = false; - $this->hardness = 15; - } + + protected $id = self::FENCE_ACACIA; + + public function getName(){ + return "Acacia Fence"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceBirch.php b/src/pocketmine/block/FenceBirch.php index 8b7b3cda4..d257689bd 100644 --- a/src/pocketmine/block/FenceBirch.php +++ b/src/pocketmine/block/FenceBirch.php @@ -22,9 +22,10 @@ namespace pocketmine\block; class FenceBirch extends Fence{ - public function __construct(){ - Transparent::__construct(self::FENCE_BIRCH, 0, "Birch Fence"); - $this->isFullBlock = false; - $this->hardness = 15; - } + + protected $id = self::FENCE_BIRCH; + + public function getName(){ + return "Birch Fence"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceDarkOak.php b/src/pocketmine/block/FenceDarkOak.php index a3a7542c9..c8a436839 100644 --- a/src/pocketmine/block/FenceDarkOak.php +++ b/src/pocketmine/block/FenceDarkOak.php @@ -22,9 +22,10 @@ namespace pocketmine\block; class FenceDarkOak extends Fence{ - public function __construct(){ - Transparent::__construct(self::FENCE_DARK_OAK, 0, "Dark Oak Fence"); - $this->isFullBlock = false; - $this->hardness = 15; - } + + protected $id = self::FENCE_DARK_OAK; + + public function getName(){ + return "Dark Oak Fence"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceGate.php b/src/pocketmine/block/FenceGate.php index 0835c5a5d..6e89d1825 100644 --- a/src/pocketmine/block/FenceGate.php +++ b/src/pocketmine/block/FenceGate.php @@ -26,17 +26,25 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\Player; class FenceGate extends Transparent{ + + protected $id = self::FENCE_GATE; + public function __construct($meta = 0){ - parent::__construct(self::FENCE_GATE, $meta, "Oak Fence Gate"); - $this->isActivable = true; - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 15; + $this->meta = $meta; } + public function getName(){ + return "Oak Fence Gate"; + } + + public function getHardness(){ + return 15; + } + + public function canBeActivated(){ + return true; + } + protected function recalculateBoundingBox(){ @@ -93,11 +101,6 @@ class FenceGate extends Transparent{ 3 => 2, ]; $this->meta = ($faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03) | ((~$this->meta) & 0x04); - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } $this->getLevel()->setBlock($this, $this, true); return true; diff --git a/src/pocketmine/block/FenceGateAcacia.php b/src/pocketmine/block/FenceGateAcacia.php index af68a9f6a..e84c6a4f2 100644 --- a/src/pocketmine/block/FenceGateAcacia.php +++ b/src/pocketmine/block/FenceGateAcacia.php @@ -23,14 +23,10 @@ namespace pocketmine\block; class FenceGateAcacia extends FenceGate{ - public function __construct($meta = 0){ - Transparent::__construct(self::FENCE_GATE_ACACIA, $meta, "Acacia Fence Gate"); - $this->isActivable = true; - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 15; - } + + protected $id = self::FENCE_GATE_ACACIA; + + public function getName(){ + return "Acacia Fence Gate"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceGateBirch.php b/src/pocketmine/block/FenceGateBirch.php index b549dd1cd..f44638c6f 100644 --- a/src/pocketmine/block/FenceGateBirch.php +++ b/src/pocketmine/block/FenceGateBirch.php @@ -23,14 +23,10 @@ namespace pocketmine\block; class FenceGateBirch extends FenceGate{ - public function __construct($meta = 0){ - Transparent::__construct(self::FENCE_GATE_BIRCH, $meta, "Birch Fence Gate"); - $this->isActivable = true; - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 15; - } + + protected $id = self::FENCE_GATE_BIRCH; + + public function getName(){ + return "Birch Fence Gate"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceGateDarkOak.php b/src/pocketmine/block/FenceGateDarkOak.php index 810501025..7f76c8685 100644 --- a/src/pocketmine/block/FenceGateDarkOak.php +++ b/src/pocketmine/block/FenceGateDarkOak.php @@ -23,14 +23,10 @@ namespace pocketmine\block; class FenceGateDarkOak extends FenceGate{ - public function __construct($meta = 0){ - Transparent::__construct(self::FENCE_GATE_DARK_OAK, $meta, "Dark Oak Fence Gate"); - $this->isActivable = true; - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 15; - } + + protected $id = self::FENCE_GATE_DARK_OAK; + + public function getName(){ + return "Dark Oak Fence Gate"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceGateJungle.php b/src/pocketmine/block/FenceGateJungle.php index 87f66d576..16774e1d8 100644 --- a/src/pocketmine/block/FenceGateJungle.php +++ b/src/pocketmine/block/FenceGateJungle.php @@ -23,14 +23,10 @@ namespace pocketmine\block; class FenceGateJungle extends FenceGate{ - public function __construct($meta = 0){ - Transparent::__construct(self::FENCE_GATE_JUNGLE, $meta, "Jungle Fence Gate"); - $this->isActivable = true; - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 15; - } + + protected $id = self::FENCE_GATE_JUNGLE; + + public function getName(){ + return "Jungle Fence Gate"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceGateSpruce.php b/src/pocketmine/block/FenceGateSpruce.php index cc12ec6e3..bc42f504b 100644 --- a/src/pocketmine/block/FenceGateSpruce.php +++ b/src/pocketmine/block/FenceGateSpruce.php @@ -23,14 +23,10 @@ namespace pocketmine\block; class FenceGateSpruce extends FenceGate{ - public function __construct($meta = 0){ - Transparent::__construct(self::FENCE_GATE_SPRUCE, $meta, "Spruce Fence Gate"); - $this->isActivable = true; - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 15; - } + + protected $id = self::FENCE_GATE_SPRUCE; + + public function getName(){ + return "Spruce Fence Gate"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceJungle.php b/src/pocketmine/block/FenceJungle.php index 4c44d5810..cafd4f07b 100644 --- a/src/pocketmine/block/FenceJungle.php +++ b/src/pocketmine/block/FenceJungle.php @@ -22,9 +22,10 @@ namespace pocketmine\block; class FenceJungle extends Fence{ - public function __construct(){ - Transparent::__construct(self::FENCE_JUNGLE, 0, "Jungle Fence"); - $this->isFullBlock = false; - $this->hardness = 15; - } + + protected $id = self::FENCE_JUNGLE; + + public function getName(){ + return "Jungle Fence"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/FenceSpruce.php b/src/pocketmine/block/FenceSpruce.php index 6052f8d4b..b4628f575 100644 --- a/src/pocketmine/block/FenceSpruce.php +++ b/src/pocketmine/block/FenceSpruce.php @@ -22,9 +22,10 @@ namespace pocketmine\block; class FenceSpruce extends Fence{ - public function __construct(){ - Transparent::__construct(self::FENCE_SPRUCE, 0, "Spruce Fence"); - $this->isFullBlock = false; - $this->hardness = 15; - } + + protected $id = self::FENCE_SPRUCE; + + public function getName(){ + return "Spruce Fence"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/Fire.php b/src/pocketmine/block/Fire.php index 90289cb8d..74644b156 100644 --- a/src/pocketmine/block/Fire.php +++ b/src/pocketmine/block/Fire.php @@ -31,20 +31,31 @@ use pocketmine\Server; class Fire extends Flowable{ - public $hasEntityCollision = true; - public $lightLevel = 15; + protected $id = self::FIRE; public function __construct($meta = 0){ - parent::__construct(self::FIRE, $meta, "Fire"); - $this->isReplaceable = true; - $this->breakable = false; - $this->isFullBlock = true; - $this->hardness = 0; + $this->meta = $meta; } - public function getBoundingBox(){ - return null; - } + public function hasEntityCollision(){ + return true; + } + + public function getName(){ + return "Fire Block"; + } + + public function getLightLevel(){ + return 15; + } + + public function isBreakable(Item $item){ + return false; + } + + public function canBeReplaced(){ + return true; + } public function onEntityCollide(Entity $entity){ $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1); diff --git a/src/pocketmine/block/Flowable.php b/src/pocketmine/block/Flowable.php index 65449c3af..0dfdb4d71 100644 --- a/src/pocketmine/block/Flowable.php +++ b/src/pocketmine/block/Flowable.php @@ -24,8 +24,19 @@ namespace pocketmine\block; abstract class Flowable extends Transparent{ - public $isFlowable = true; - public $isFullBlock = false; - public $isSolid = false; + public function canBeFlowedInto(){ + return true; + } + public function isSolid(){ + return false; + } + + public function getBoundingBox(){ + return null; + } + + public function getHardness(){ + return 0; + } } \ No newline at end of file diff --git a/src/pocketmine/block/Furnace.php b/src/pocketmine/block/Furnace.php index 29bd2b69d..93e5465bb 100644 --- a/src/pocketmine/block/Furnace.php +++ b/src/pocketmine/block/Furnace.php @@ -23,10 +23,10 @@ namespace pocketmine\block; class Furnace extends BurningFurnace{ - public function __construct($meta = 0){ - parent::__construct($meta); - $this->id = self::FURNACE; - $this->name = "Furnace"; - $this->isActivable = true; - } + + protected $id = self::FURNACE; + + public function getName(){ + return "Furnace"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/Glass.php b/src/pocketmine/block/Glass.php index 9f58a214b..e86252e57 100644 --- a/src/pocketmine/block/Glass.php +++ b/src/pocketmine/block/Glass.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Glass extends Transparent{ - public function __construct(){ - parent::__construct(self::GLASS, 0, "Glass"); - $this->hardness = 1.5; + + protected $id = self::GLASS; + + public function __construct(){ + } + public function getName(){ + return "Glass"; + } + + public function getHardness(){ + return 1.5; + } + public function getDrops(Item $item){ return []; } diff --git a/src/pocketmine/block/GlassPane.php b/src/pocketmine/block/GlassPane.php index 40a9b4f7e..bccec447c 100644 --- a/src/pocketmine/block/GlassPane.php +++ b/src/pocketmine/block/GlassPane.php @@ -23,8 +23,19 @@ namespace pocketmine\block; class GlassPane extends Thin{ - public function __construct(){ - parent::__construct(self::GLASS_PANE, 0, "Glass Pane"); - } + + protected $id = self::GLASS_PANE; + + public function __construct(){ + + } + + public function getName(){ + return "Glass Pane"; + } + + public function getHardness(){ + return 1.5; + } } \ No newline at end of file diff --git a/src/pocketmine/block/GlowingObsidian.php b/src/pocketmine/block/GlowingObsidian.php index 9367432eb..1af01ca3c 100644 --- a/src/pocketmine/block/GlowingObsidian.php +++ b/src/pocketmine/block/GlowingObsidian.php @@ -24,10 +24,18 @@ namespace pocketmine\block; class GlowingObsidian extends Solid{ - public $lightLevel = 12; + protected $id = self::GLOWING_OBSIDIAN; public function __construct($meta = 0){ - parent::__construct(self::GLOWING_OBSIDIAN, $meta, "Glowing Obsidian"); + $this->meta = $meta; } + public function getName(){ + return "Glowing Obsidian"; + } + + public function getLightLevel(){ + return 12; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/GlowingRedstoneOre.php b/src/pocketmine/block/GlowingRedstoneOre.php index cc647e4d2..933957c1f 100644 --- a/src/pocketmine/block/GlowingRedstoneOre.php +++ b/src/pocketmine/block/GlowingRedstoneOre.php @@ -26,13 +26,24 @@ use pocketmine\level\Level; class GlowingRedstoneOre extends Solid{ - public $lightLevel = 9; + protected $id = self::GLOWING_REDSTONE_ORE; public function __construct(){ - parent::__construct(self::GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore"); - $this->hardness = 15; + } + public function getHardness(){ + return 15; + } + + public function getName(){ + return "Glowing Redstone Ore"; + } + + public function getLightLevel(){ + return 9; + } + public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM){ $this->getLevel()->setBlock($this, Block::get(Item::REDSTONE_ORE, $this->meta), false, false, true); diff --git a/src/pocketmine/block/Glowstone.php b/src/pocketmine/block/Glowstone.php index 0e55098c6..c81b52cab 100644 --- a/src/pocketmine/block/Glowstone.php +++ b/src/pocketmine/block/Glowstone.php @@ -25,13 +25,24 @@ use pocketmine\item\Item; class Glowstone extends Transparent{ - public $lightLevel = 15; + protected $id = self::GLOWSTONE_BLOCK; public function __construct(){ - parent::__construct(self::GLOWSTONE_BLOCK, 0, "Glowstone"); - $this->hardness = 1.5; + } + public function getName(){ + return "Glowstone"; + } + + public function getHardness(){ + return 1.5; + } + + public function getLightLevel(){ + return 15; + } + public function getDrops(Item $item){ return [ [Item::GLOWSTONE_DUST, 0, mt_rand(2, 4)], diff --git a/src/pocketmine/block/Gold.php b/src/pocketmine/block/Gold.php index e2089d88a..e3b4e2be4 100644 --- a/src/pocketmine/block/Gold.php +++ b/src/pocketmine/block/Gold.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Gold extends Solid{ + + protected $id = self::GOLD_BLOCK; + public function __construct(){ - parent::__construct(self::GOLD_BLOCK, 0, "Gold Block"); - $this->hardness = 30; + } + public function getName(){ + return "Gold Block"; + } + + public function getHardness(){ + return 30; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/GoldOre.php b/src/pocketmine/block/GoldOre.php index 137213140..370b1acf3 100644 --- a/src/pocketmine/block/GoldOre.php +++ b/src/pocketmine/block/GoldOre.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class GoldOre extends Solid{ + + protected $id = self::GOLD_ORE; + public function __construct(){ - parent::__construct(self::GOLD_ORE, 0, "Gold Ore"); - $this->hardness = 15; + } + public function getName(){ + return "Gold Ore"; + } + + public function getHardness(){ + return 15; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/Grass.php b/src/pocketmine/block/Grass.php index 4777e4ebf..46fbc1728 100644 --- a/src/pocketmine/block/Grass.php +++ b/src/pocketmine/block/Grass.php @@ -32,16 +32,24 @@ use pocketmine\utils\Random; class Grass extends Solid{ - public $isActivable = true; - protected $hardness = 3; protected $id = self::GRASS; - protected $meta = 0; - protected $name = "Grass"; public function __construct(){ } + public function canBeActivated(){ + return true; + } + + public function getName(){ + return "Grass"; + } + + public function getHardness(){ + return 3; + } + public function getDrops(Item $item){ return [ [Item::DIRT, 0, 1], diff --git a/src/pocketmine/block/Gravel.php b/src/pocketmine/block/Gravel.php index 1cbe9c1a2..ebd8987b6 100644 --- a/src/pocketmine/block/Gravel.php +++ b/src/pocketmine/block/Gravel.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Gravel extends Fallable{ + + protected $id = self::GRAVEL; + public function __construct(){ - parent::__construct(self::GRAVEL, 0, "Gravel"); - $this->hardness = 3; + } + public function getName(){ + return "Gravel"; + } + + public function getHardness(){ + return 3; + } + public function getDrops(Item $item){ if(mt_rand(1, 10) === 1){ return [ diff --git a/src/pocketmine/block/HardenedClay.php b/src/pocketmine/block/HardenedClay.php index 947ed8324..11cc36270 100644 --- a/src/pocketmine/block/HardenedClay.php +++ b/src/pocketmine/block/HardenedClay.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class HardenedClay extends Solid{ + + protected $id = self::HARDENED_CLAY; + public function __construct(){ - parent::__construct(self::HARDENED_CLAY, 0, "Hardened Clay"); - $this->hardness = 30; + } + public function getName(){ + return "Hardened Clay"; + } + + public function getHardness(){ + return 30; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/HayBale.php b/src/pocketmine/block/HayBale.php index ef38673ef..4f235c1f2 100644 --- a/src/pocketmine/block/HayBale.php +++ b/src/pocketmine/block/HayBale.php @@ -25,11 +25,21 @@ use pocketmine\item\Item; use pocketmine\Player; class HayBale extends Solid{ + + protected $id = self::HAY_BALE; + public function __construct($meta = 0){ - parent::__construct(self::HAY_BALE, $meta, "Hay Bale"); - $this->hardness = 10; + $this->meta = $meta; } + public function getName(){ + return "Hay Bale"; + } + + public function getHardness(){ + return 10; + } + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ $faces = [ 0 => 0, diff --git a/src/pocketmine/block/Ice.php b/src/pocketmine/block/Ice.php index 8b0c8eed1..8312ed49f 100644 --- a/src/pocketmine/block/Ice.php +++ b/src/pocketmine/block/Ice.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Ice extends Transparent{ + + protected $id = self::ICE; + public function __construct(){ - parent::__construct(self::ICE, 0, "Ice"); - $this->hardness = 2.5; + } + public function getName(){ + return "Ice"; + } + + public function getHardness(){ + return 2.5; + } + public function onBreak(Item $item){ $this->getLevel()->setBlock($this, new Water(), true); diff --git a/src/pocketmine/block/Iron.php b/src/pocketmine/block/Iron.php index d507ac7c6..38f7a6147 100644 --- a/src/pocketmine/block/Iron.php +++ b/src/pocketmine/block/Iron.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Iron extends Solid{ + + protected $id = self::IRON_BLOCK; + public function __construct(){ - parent::__construct(self::IRON_BLOCK, 0, "Iron Block"); - $this->hardness = 30; + } + public function getName(){ + return "Iron Block"; + } + + public function getHardness(){ + return 30; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/IronBars.php b/src/pocketmine/block/IronBars.php index a4440b7ee..937121230 100644 --- a/src/pocketmine/block/IronBars.php +++ b/src/pocketmine/block/IronBars.php @@ -23,8 +23,15 @@ namespace pocketmine\block; class IronBars extends Thin{ + + protected $id = self::IRON_BARS; + public function __construct(){ - parent::__construct(self::IRON_BARS, 0, "Iron Bars"); + } + public function getName(){ + return "Iron Bars"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/IronDoor.php b/src/pocketmine/block/IronDoor.php index 45e91bb06..4735b1ed5 100644 --- a/src/pocketmine/block/IronDoor.php +++ b/src/pocketmine/block/IronDoor.php @@ -24,12 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class IronDoor extends Door{ + + protected $id = self::IRON_DOOR_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::IRON_DOOR_BLOCK, $meta, "Iron Door Block"); - //$this->isActivable = true; - $this->hardness = 25; + $this->meta = $meta; } + public function getName(){ + return "Iron Door Block"; + } + + public function getHardness(){ + return 25; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/IronOre.php b/src/pocketmine/block/IronOre.php index a4a52a227..373254035 100644 --- a/src/pocketmine/block/IronOre.php +++ b/src/pocketmine/block/IronOre.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class IronOre extends Solid{ + + protected $id = self::IRON_ORE; + public function __construct(){ - parent::__construct(self::IRON_ORE, 0, "Iron Ore"); - $this->hardness = 15; + } + public function getName(){ + return "Iron Ore"; + } + + public function getHardness(){ + return 15; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/JungleWoodStairs.php b/src/pocketmine/block/JungleWoodStairs.php index 9bc3bdeeb..275d4d5b7 100644 --- a/src/pocketmine/block/JungleWoodStairs.php +++ b/src/pocketmine/block/JungleWoodStairs.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class JungleWoodStairs extends Stair{ + + protected $id = self::JUNGLE_WOOD_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::JUNGLE_WOOD_STAIRS, $meta, "Jungle Wood Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Jungle Wood Stairs"; + } + public function getDrops(Item $item){ return [ [$this->id, 0, 1], diff --git a/src/pocketmine/block/Ladder.php b/src/pocketmine/block/Ladder.php index 64c10fb33..d4452ff7d 100644 --- a/src/pocketmine/block/Ladder.php +++ b/src/pocketmine/block/Ladder.php @@ -29,15 +29,28 @@ use pocketmine\Player; class Ladder extends Transparent{ - public $hasEntityCollision = true; + protected $id = self::LADDER; public function __construct($meta = 0){ - parent::__construct(self::LADDER, $meta, "Ladder"); - $this->isSolid = false; - $this->isFullBlock = false; - $this->hardness = 2; + $this->meta = $meta; } + public function getName(){ + return "Ladder"; + } + + public function hasEntityCollision(){ + return true; + } + + public function isSolid(){ + return false; + } + + public function getHardness(){ + return 2; + } + public function onEntityCollide(Entity $entity){ $entity->fallDistance = 0; $entity->onGround = true; diff --git a/src/pocketmine/block/Lapis.php b/src/pocketmine/block/Lapis.php index b2db19713..e5a1fbecd 100644 --- a/src/pocketmine/block/Lapis.php +++ b/src/pocketmine/block/Lapis.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Lapis extends Solid{ + + protected $id = self::LAPIS_BLOCK; + public function __construct(){ - parent::__construct(self::LAPIS_BLOCK, 0, "Lapis Block"); - $this->hardness = 15; + } + public function getName(){ + return "Lapis Block"; + } + + public function getHardness(){ + return 15; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/LapisOre.php b/src/pocketmine/block/LapisOre.php index eee6d45ad..3513d609a 100644 --- a/src/pocketmine/block/LapisOre.php +++ b/src/pocketmine/block/LapisOre.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class LapisOre extends Solid{ + + protected $id = self::LAPIS_ORE; + public function __construct(){ - parent::__construct(self::LAPIS_ORE, 0, "Lapis Ore"); - $this->hardness = 15; + } + public function getHardness(){ + return 15; + } + + public function getName(){ + return "Lapis Ore"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ diff --git a/src/pocketmine/block/Lava.php b/src/pocketmine/block/Lava.php index 8aaeab408..33b442bac 100644 --- a/src/pocketmine/block/Lava.php +++ b/src/pocketmine/block/Lava.php @@ -31,13 +31,24 @@ use pocketmine\Server; class Lava extends Liquid{ - public $lightLevel = 15; + protected $id = self::LAVA; public function __construct($meta = 0){ - parent::__construct(self::LAVA, $meta, "Lava"); - $this->hardness = 0; + $this->meta = $meta; } + public function getLightLevel(){ + return 15; + } + + public function getName(){ + return "Lava"; + } + + public function getHardness(){ + return 0; + } + public function onEntityCollide(Entity $entity){ $entity->fallDistance *= 0.5; $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4); diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index 45f28e72c..cb3f16fa8 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -35,18 +35,26 @@ class Leaves extends Transparent{ const ACACIA = 0; const DARK_OAK = 1; + protected $id = self::LEAVES; + public function __construct($meta = 0){ - parent::__construct(self::LEAVES, $meta, "Leaves"); - $names = [ - self::OAK => "Oak Leaves", - self::SPRUCE => "Spruce Leaves", - self::BIRCH => "Birch Leaves", - self::JUNGLE => "Jungle Leaves", - ]; - $this->name = $names[$this->meta & 0x03]; - $this->hardness = 1; + $this->meta = $meta; } + public function getHardness(){ + return 1; + } + + public function getName(){ + static $names = [ + self::OAK => "Oak Leaves", + self::SPRUCE => "Spruce Leaves", + self::BIRCH => "Birch Leaves", + self::JUNGLE => "Jungle Leaves", + ]; + return $names[$this->meta & 0x03]; + } + private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){ ++$check; $index = $pos->x . "." . $pos->y . "." . $pos->z; diff --git a/src/pocketmine/block/Leaves2.php b/src/pocketmine/block/Leaves2.php index 8c9083dd2..d74f9858d 100644 --- a/src/pocketmine/block/Leaves2.php +++ b/src/pocketmine/block/Leaves2.php @@ -29,16 +29,20 @@ use pocketmine\Server; class Leaves2 extends Leaves{ + protected $id = self::LEAVES2; + public function __construct($meta = 0){ - Transparent::__construct(self::LEAVES, $meta, "Leaves"); - $names = [ - self::ACACIA => "Acacia Leaves", - self::DARK_OAK => "Dark Oak Leaves", - ]; - $this->name = $names[$this->meta & 0x03]; - $this->hardness = 1; + $this->meta = $meta; } + public function getName(){ + static $names = [ + self::ACACIA => "Acacia Leaves", + self::DARK_OAK => "Dark Oak Leaves", + ]; + return $names[$this->meta & 0x01]; + } + private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){ ++$check; $index = $pos->x . "." . $pos->y . "." . $pos->z; diff --git a/src/pocketmine/block/Liquid.php b/src/pocketmine/block/Liquid.php index 0a82c1280..493e1ee92 100644 --- a/src/pocketmine/block/Liquid.php +++ b/src/pocketmine/block/Liquid.php @@ -28,12 +28,22 @@ use pocketmine\level\Level; use pocketmine\math\Vector3; abstract class Liquid extends Transparent{ - public $hasEntityCollision = true; - public $breakable = false; - public $isReplaceable = true; - public $isSolid = false; - public $isFullBlock = true; + public function hasEntityCollision(){ + return true; + } + + public function isBreakable(Item $item){ + return false; + } + + public function canBeReplaced(){ + return true; + } + + public function isSolid(){ + return false; + } public $adjacentSources = 0; public $isOptimalFlowDirection = [0, 0, 0, 0]; @@ -102,7 +112,7 @@ abstract class Liquid extends Transparent{ $blockDecay = $this->getEffectiveFlowDecay($sideBlock); if($blockDecay < 0){ - if(!$sideBlock->isFlowable){ + if(!$sideBlock->canBeFlowedInto()){ continue; } @@ -123,21 +133,21 @@ abstract class Liquid extends Transparent{ if($this->getDamage() >= 8){ $falling = false; - if(!$this->getLevel()->getBlock($this->add(0, 0, -1))->isFlowable){ + if(!$this->getLevel()->getBlock($this->add(0, 0, -1))->canBeFlowedInto()){ $falling = true; - }elseif(!$this->getLevel()->getBlock($this->add(0, 0, 1))->isFlowable){ + }elseif(!$this->getLevel()->getBlock($this->add(0, 0, 1))->canBeFlowedInto()){ $falling = true; - }elseif(!$this->getLevel()->getBlock($this->add(-1, 0, 0))->isFlowable){ + }elseif(!$this->getLevel()->getBlock($this->add(-1, 0, 0))->canBeFlowedInto()){ $falling = true; - }elseif(!$this->getLevel()->getBlock($this->add(1, 0, 0))->isFlowable){ + }elseif(!$this->getLevel()->getBlock($this->add(1, 0, 0))->canBeFlowedInto()){ $falling = true; - }elseif(!$this->getLevel()->getBlock($this->add(0, 1, -1))->isFlowable){ + }elseif(!$this->getLevel()->getBlock($this->add(0, 1, -1))->canBeFlowedInto()){ $falling = true; - }elseif(!$this->getLevel()->getBlock($this->add(0, 1, 1))->isFlowable){ + }elseif(!$this->getLevel()->getBlock($this->add(0, 1, 1))->canBeFlowedInto()){ $falling = true; - }elseif(!$this->getLevel()->getBlock($this->add(-1, 1, 0))->isFlowable){ + }elseif(!$this->getLevel()->getBlock($this->add(-1, 1, 0))->canBeFlowedInto()){ $falling = true; - }elseif(!$this->getLevel()->getBlock($this->add(1, 1, 0))->isFlowable){ + }elseif(!$this->getLevel()->getBlock($this->add(1, 1, 0))->canBeFlowedInto()){ $falling = true; } @@ -230,7 +240,7 @@ abstract class Liquid extends Transparent{ $bottomBlock = $this->getSide(0); - if($bottomBlock->isFlowable or $bottomBlock instanceof Liquid){ + if($bottomBlock->canBeFlowedInto() or $bottomBlock instanceof Liquid){ if($this instanceof Lava and $bottomBlock instanceof Water){ $this->getLevel()->setBlock($bottomBlock, Block::get(Item::STONE), true); return; @@ -243,7 +253,7 @@ abstract class Liquid extends Transparent{ $this->getLevel()->setBlock($bottomBlock, Block::get($this->id, $decay + 8), true); $this->getLevel()->scheduleUpdate($bottomBlock, $this->tickRate()); } - }elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->isFlowable)){ + }elseif($decay >= 0 and ($decay === 0 or !$bottomBlock->canBeFlowedInto())){ $flags = $this->getOptimalFlowDirections(); $l = $decay + $multiplier; @@ -280,7 +290,7 @@ abstract class Liquid extends Transparent{ } private function flowIntoBlock(Block $block, $newFlowDecay){ - if($block->isFlowable){ + if($block->canBeFlowedInto()){ if($block->getID() > 0){ $this->getLevel()->useBreakOn($block); } @@ -315,11 +325,11 @@ abstract class Liquid extends Transparent{ } $blockSide = $this->getLevel()->getBlock(new Vector3($x, $y, $z)); - if(!$blockSide->isFlowable and !($blockSide instanceof Liquid)){ + if(!$blockSide->canBeFlowedInto() and !($blockSide instanceof Liquid)){ continue; }elseif($blockSide instanceof Liquid and $blockSide->getDamage() === 0){ continue; - }elseif($blockSide->getSide(0)->isFlowable){ + }elseif($blockSide->getSide(0)->canBeFlowedInto()){ return $accumulatedCost; } @@ -357,11 +367,11 @@ abstract class Liquid extends Transparent{ } $block = $this->getLevel()->getBlock(new Vector3($x, $y, $z)); - if(!$block->isFlowable and !($block instanceof Liquid)){ + if(!$block->canBeFlowedInto() and !($block instanceof Liquid)){ continue; }elseif($block instanceof Liquid and $block->getDamage() === 0){ continue; - }elseif($block->getSide(0)->isFlowable){ + }elseif($block->getSide(0)->canBeFlowedInto()){ $this->flowCost[$j] = 0; }else{ $this->flowCost[$j] = $this->calculateFlowCost($block, 1, $j); diff --git a/src/pocketmine/block/LitPumpkin.php b/src/pocketmine/block/LitPumpkin.php index 29fcf0890..43764ad47 100644 --- a/src/pocketmine/block/LitPumpkin.php +++ b/src/pocketmine/block/LitPumpkin.php @@ -26,11 +26,22 @@ use pocketmine\Player; class LitPumpkin extends Solid{ - public $lightLevel = 15; + protected $id = self::LIT_PUMPKIN; - public function __construct(){ - parent::__construct(self::LIT_PUMPKIN, "Jack o'Lantern"); - $this->hardness = 5; + public function getLightLevel(){ + return 15; + } + + public function getHardness(){ + return 5; + } + + public function getName(){ + return "Jack o'Lantern"; + } + + public function __construct($meta = 0){ + $this->meta = $meta; } public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ diff --git a/src/pocketmine/block/Melon.php b/src/pocketmine/block/Melon.php index 1a661ee7e..4155adf2a 100644 --- a/src/pocketmine/block/Melon.php +++ b/src/pocketmine/block/Melon.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Melon extends Transparent{ + + protected $id = self::MELON_BLOCK; + public function __construct(){ - parent::__construct(self::MELON_BLOCK, 0, "Melon Block"); - $this->hardness = 5; + } + public function getName(){ + return "Melon Block"; + } + + public function getHardness(){ + return 5; + } + public function getDrops(Item $item){ return [ [Item::MELON_SLICE, 0, mt_rand(3, 7)], diff --git a/src/pocketmine/block/MelonStem.php b/src/pocketmine/block/MelonStem.php index 3e69c11e0..2c715e600 100644 --- a/src/pocketmine/block/MelonStem.php +++ b/src/pocketmine/block/MelonStem.php @@ -27,8 +27,15 @@ use pocketmine\level\Level; use pocketmine\Server; class MelonStem extends Crops{ + + protected $id = self::MELON_STEM; + + public function getName(){ + return "Melon Stem"; + } + public function __construct($meta = 0){ - parent::__construct(self::MELON_STEM, $meta, "Melon Stem"); + $this->meta = $meta; } public function onUpdate($type){ diff --git a/src/pocketmine/block/MonsterSpawner.php b/src/pocketmine/block/MonsterSpawner.php index 54dc91b25..27db243ed 100644 --- a/src/pocketmine/block/MonsterSpawner.php +++ b/src/pocketmine/block/MonsterSpawner.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class MonsterSpawner extends Solid{ - public function __construct(){ - parent::__construct(self::MONSTER_SPAWNER, 0, "Monster Spawner"); - $this->hardness = 25; + + protected $id = self::MONSTER_SPAWNER; + + public function __construct($meta = 0){ + $this->meta = $meta; } + public function getHardness(){ + return 25; + } + + public function getName(){ + return "Monster Spawner"; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/MossStone.php b/src/pocketmine/block/MossStone.php index ea33095d0..5d0e201f9 100644 --- a/src/pocketmine/block/MossStone.php +++ b/src/pocketmine/block/MossStone.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class MossStone extends Solid{ + + protected $id = self::MOSS_STONE; + public function __construct($meta = 0){ - parent::__construct(self::MOSS_STONE, $meta, "Moss Stone"); - $this->hardness = 30; + $this->meta = $meta; } + public function getName(){ + return "Moss Stone"; + } + + public function getHardness(){ + return 30; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ diff --git a/src/pocketmine/block/Mycelium.php b/src/pocketmine/block/Mycelium.php index 70ee23e4a..272ace086 100644 --- a/src/pocketmine/block/Mycelium.php +++ b/src/pocketmine/block/Mycelium.php @@ -28,11 +28,21 @@ use pocketmine\math\Vector3; use pocketmine\Server; class Mycelium extends Solid{ + + protected $id = self::MYCELIUM; + public function __construct(){ - parent::__construct(self::MYCELIUM, 0, "Mycelium"); - $this->hardness = 2.5; + } + public function getName(){ + return "Mycelium"; + } + + public function getHardness() { + return 2.5; + } + public function getDrops(Item $item){ return [ [Item::DIRT, 0, 1], diff --git a/src/pocketmine/block/NetherBrick.php b/src/pocketmine/block/NetherBrick.php index 8c8e0995d..f0c8bc76b 100644 --- a/src/pocketmine/block/NetherBrick.php +++ b/src/pocketmine/block/NetherBrick.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class NetherBrick extends Solid{ + + protected $id = self::NETHER_BRICKS; + public function __construct(){ - parent::__construct(self::NETHER_BRICKS, 0, "Nether Bricks"); - $this->hardness = 30; + } + public function getName(){ + return "Nether Bricks"; + } + + public function getHardness(){ + return 30; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ diff --git a/src/pocketmine/block/NetherBrickStairs.php b/src/pocketmine/block/NetherBrickStairs.php index b9f4955cd..de8462806 100644 --- a/src/pocketmine/block/NetherBrickStairs.php +++ b/src/pocketmine/block/NetherBrickStairs.php @@ -23,8 +23,15 @@ namespace pocketmine\block; class NetherBrickStairs extends Stair{ + + protected $id = self::NETHER_BRICKS_STAIRS; + + public function getName(){ + return "Nether Bricks Stairs"; + } + public function __construct($meta = 0){ - parent::__construct(self::NETHER_BRICKS_STAIRS, $meta, "Nether Bricks Stairs"); + $this->meta = $meta; } } \ No newline at end of file diff --git a/src/pocketmine/block/NetherReactor.php b/src/pocketmine/block/NetherReactor.php index 58fe72591..0fb8dedfb 100644 --- a/src/pocketmine/block/NetherReactor.php +++ b/src/pocketmine/block/NetherReactor.php @@ -23,9 +23,19 @@ namespace pocketmine\block; class NetherReactor extends Solid{ + + protected $id = self::NETHER_REACTOR; + public function __construct($meta = 0){ - parent::__construct(self::NETHER_REACTOR, $meta, "Nether Reactor"); - $this->isActivable = true; + $this->meta = $meta; } + public function getName(){ + return "Nether Reactor"; + } + + public function canBeActivated(){ + return true; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/Netherrack.php b/src/pocketmine/block/Netherrack.php index d15c89523..530c039c5 100644 --- a/src/pocketmine/block/Netherrack.php +++ b/src/pocketmine/block/Netherrack.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Netherrack extends Solid{ + + protected $id = self::NETHERRACK; + public function __construct(){ - parent::__construct(self::NETHERRACK, 0, "Netherrack"); - $this->hardness = 2; + } + public function getName(){ + return "Netherrack"; + } + + public function getHardness(){ + return 2; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ diff --git a/src/pocketmine/block/Obsidian.php b/src/pocketmine/block/Obsidian.php index 9adb00215..be6b2a7b5 100644 --- a/src/pocketmine/block/Obsidian.php +++ b/src/pocketmine/block/Obsidian.php @@ -24,11 +24,21 @@ namespace pocketmine\block; use pocketmine\item\Item; class Obsidian extends Solid{ + + protected $id = self::OBSIDIAN; + public function __construct(){ - parent::__construct(self::OBSIDIAN, 0, "Obsidian"); - $this->hardness = 6000; + } + public function getName(){ + return "Obsidian"; + } + + public function getHardness(){ + return 6000; + } + public function getBreakTime(Item $item){ if($item->isPickaxe() >= 5){ diff --git a/src/pocketmine/block/Planks.php b/src/pocketmine/block/Planks.php index 8a1003359..3326189a3 100644 --- a/src/pocketmine/block/Planks.php +++ b/src/pocketmine/block/Planks.php @@ -30,18 +30,28 @@ class Planks extends Solid{ const ACACIA = 4; const DARK_OAK = 5; + protected $id = self::WOODEN_PLANKS; + public function __construct($meta = 0){ - parent::__construct(self::PLANKS, $meta, "Wood Planks"); - $names = [ - self::OAK => "Oak Wood Planks", - self::SPRUCE => "Spruce Wood Planks", - self::BIRCH => "Birch Wood Planks", - self::JUNGLE => "Jungle Wood Planks", - self::ACACIA => "Acacia Wood Planks", - self::DARK_OAK => "Jungle Wood Planks", - ]; - $this->name = $names[$this->meta & 0x07]; - $this->hardness = 15; + $this->meta = $meta; } + public function getHardness(){ + return 15; + } + + public function getName(){ + static $names = [ + self::OAK => "Oak Wood Planks", + self::SPRUCE => "Spruce Wood Planks", + self::BIRCH => "Birch Wood Planks", + self::JUNGLE => "Jungle Wood Planks", + self::ACACIA => "Acacia Wood Planks", + self::DARK_OAK => "Jungle Wood Planks", + "", + "" + ]; + return $names[$this->meta & 0x07]; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/Podzol.php b/src/pocketmine/block/Podzol.php index eb2ee7027..85ddb7b0e 100644 --- a/src/pocketmine/block/Podzol.php +++ b/src/pocketmine/block/Podzol.php @@ -22,8 +22,18 @@ namespace pocketmine\block; class Podzol extends Solid{ + + protected $id = self::PODZOL; + public function __construct(){ - parent::__construct(self::PODZOL, 0, "Podzol"); - $this->hardness = 2.5; + } + + public function getName(){ + return "Podzol"; + } + + public function getHardness(){ + return 2.5; + } } \ No newline at end of file diff --git a/src/pocketmine/block/CyanFlower.php b/src/pocketmine/block/Poppy.php similarity index 87% rename from src/pocketmine/block/CyanFlower.php rename to src/pocketmine/block/Poppy.php index e854b5a4c..ce8d903a0 100644 --- a/src/pocketmine/block/CyanFlower.php +++ b/src/pocketmine/block/Poppy.php @@ -25,15 +25,17 @@ use pocketmine\item\Item; use pocketmine\level\Level; use pocketmine\Player; -class CyanFlower extends Flowable{ - public function __construct(){ - parent::__construct(self::POPPY, 0, "Cyan Flower"); - $this->hardness = 0; +class Poppy extends Flowable{ + + protected $id = self::POPPY; + + public function __construct($meta = 0){ + $this->meta = $meta; } - public function getBoundingBox(){ - return null; - } + public function getName(){ + return "Poppy"; + } public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ diff --git a/src/pocketmine/block/Potato.php b/src/pocketmine/block/Potato.php index 5c003da56..9d6fe9651 100644 --- a/src/pocketmine/block/Potato.php +++ b/src/pocketmine/block/Potato.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class Potato extends Crops{ + + protected $id = self::POTATO_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::POTATO_BLOCK, $meta, "Potato Block"); + $this->meta = $meta; } + public function getName(){ + return "Potato Block"; + } + public function getDrops(Item $item){ $drops = []; if($this->meta >= 0x07){ diff --git a/src/pocketmine/block/Pumpkin.php b/src/pocketmine/block/Pumpkin.php index ca2ad84cd..f751a5a5b 100644 --- a/src/pocketmine/block/Pumpkin.php +++ b/src/pocketmine/block/Pumpkin.php @@ -25,11 +25,21 @@ use pocketmine\item\Item; use pocketmine\Player; class Pumpkin extends Solid{ + + protected $id = self::PUMPKIN; + public function __construct(){ - parent::__construct(self::PUMPKIN, "Pumpkin"); - $this->hardness = 5; + } + public function getHardness(){ + return 5; + } + + public function getName(){ + return "Pumpkin"; + } + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ if($player instanceof Player){ $this->meta = ((int) $player->getDirection() + 5) % 4; diff --git a/src/pocketmine/block/PumpkinStem.php b/src/pocketmine/block/PumpkinStem.php index 7123e7201..81683be99 100644 --- a/src/pocketmine/block/PumpkinStem.php +++ b/src/pocketmine/block/PumpkinStem.php @@ -27,10 +27,17 @@ use pocketmine\level\Level; use pocketmine\Server; class PumpkinStem extends Crops{ + + protected $id = self::PUMPKIN_STEM; + public function __construct($meta = 0){ - parent::__construct(self::PUMPKIN_STEM, $meta, "Pumpkin Stem"); + $this->meta = $meta; } + public function getName(){ + return "Pumpkin Stem"; + } + public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent === true){ diff --git a/src/pocketmine/block/Quartz.php b/src/pocketmine/block/Quartz.php index d60376f7d..161f01ec5 100644 --- a/src/pocketmine/block/Quartz.php +++ b/src/pocketmine/block/Quartz.php @@ -24,17 +24,23 @@ namespace pocketmine\block; use pocketmine\item\Item; class Quartz extends Solid{ + + protected $id = self::QUARTZ_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::QUARTZ_BLOCK, $meta, "Quartz Block"); - $names = [ - 0 => "Quartz Block", - 1 => "Chiseled Quartz Block", - 2 => "Quartz Pillar", - 3 => "Quartz Pillar", - ]; - $this->name = $names[$this->meta & 0x03]; + $this->meta = $meta; } + public function getName(){ + static $names = [ + 0 => "Quartz Block", + 1 => "Chiseled Quartz Block", + 2 => "Quartz Pillar", + 3 => "Quartz Pillar", + ]; + return $names[$this->meta & 0x03]; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ diff --git a/src/pocketmine/block/QuartzStairs.php b/src/pocketmine/block/QuartzStairs.php index 7fa1f37ed..f55f08901 100644 --- a/src/pocketmine/block/QuartzStairs.php +++ b/src/pocketmine/block/QuartzStairs.php @@ -23,8 +23,15 @@ namespace pocketmine\block; class QuartzStairs extends Stair{ + + protected $id = self::QUARTZ_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::QUARTZ_STAIRS, $meta, "Quartz Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Quartz Stairs"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/RedMushroom.php b/src/pocketmine/block/RedMushroom.php index 60cdcd4b7..2b61c37fc 100644 --- a/src/pocketmine/block/RedMushroom.php +++ b/src/pocketmine/block/RedMushroom.php @@ -26,14 +26,16 @@ use pocketmine\level\Level; use pocketmine\Player; class RedMushroom extends Flowable{ + + protected $id = self::RED_MUSHROOM; + public function __construct(){ - parent::__construct(self::RED_MUSHROOM, 0, "Red Mushroom"); - $this->hardness = 0; + } - public function getBoundingBox(){ - return null; - } + public function getName(){ + return "Red Mushroom"; + } public function onUpdate($type){ diff --git a/src/pocketmine/block/RedstoneOre.php b/src/pocketmine/block/RedstoneOre.php index 3954e9e50..df074ffe8 100644 --- a/src/pocketmine/block/RedstoneOre.php +++ b/src/pocketmine/block/RedstoneOre.php @@ -25,11 +25,21 @@ use pocketmine\item\Item; use pocketmine\level\Level; class RedstoneOre extends Solid{ + + protected $id = self::REDSTONE_ORE; + public function __construct(){ - parent::__construct(self::REDSTONE_ORE, 0, "Redstone Ore"); - $this->hardness = 15; + } + public function getName(){ + return "Redstone Ore"; + } + + public function getHardness(){ + return 15; + } + public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL or $type === Level::BLOCK_UPDATE_TOUCH){ $this->getLevel()->setBlock($this, Block::get(Item::GLOWING_REDSTONE_ORE, $this->meta), false, false, true); diff --git a/src/pocketmine/block/Sand.php b/src/pocketmine/block/Sand.php index c6a5406ae..0e95db31c 100644 --- a/src/pocketmine/block/Sand.php +++ b/src/pocketmine/block/Sand.php @@ -23,12 +23,23 @@ namespace pocketmine\block; class Sand extends Fallable{ + + protected $id = self::SAND; + public function __construct($meta = 0){ - parent::__construct(self::SAND, $meta & 0x01, "Sand"); - if($this->meta === 0x01){ - $this->name = "Red sand"; - } - $this->hardness = 2.5; + $this->meta = $meta & 0x01; } + public function getHardness(){ + return 2.5; + } + + public function getName(){ + if($this->meta === 0x01){ + return "Red Sand"; + } + + return "Sand"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/Sandstone.php b/src/pocketmine/block/Sandstone.php index fa046ff7e..6f6ad9033 100644 --- a/src/pocketmine/block/Sandstone.php +++ b/src/pocketmine/block/Sandstone.php @@ -24,17 +24,27 @@ namespace pocketmine\block; use pocketmine\item\Item; class Sandstone extends Solid{ + + protected $id = self::SANDSTONE; + public function __construct($meta = 0){ - parent::__construct(self::SANDSTONE, $meta, "Sandstone"); - $names = [ - 0 => "Sandstone", - 1 => "Chiseled Sandstone", - 2 => "Smooth Sandstone", - ]; - $this->name = $names[$this->meta & 0x03]; - $this->hardness = 4; + $this->meta = $meta; } + public function getHardness(){ + return 4; + } + + public function getName(){ + static $names = [ + 0 => "Sandstone", + 1 => "Chiseled Sandstone", + 2 => "Smooth Sandstone", + 3 => "", + ]; + return $names[$this->meta & 0x03]; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ diff --git a/src/pocketmine/block/SandstoneStairs.php b/src/pocketmine/block/SandstoneStairs.php index a8496a0f6..d63f1fe62 100644 --- a/src/pocketmine/block/SandstoneStairs.php +++ b/src/pocketmine/block/SandstoneStairs.php @@ -23,8 +23,15 @@ namespace pocketmine\block; class SandstoneStairs extends Stair{ + + protected $id = self::SANDSTONE_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::SANDSTONE_STAIRS, $meta, "Sandstone Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Sandstone Stairs"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/Sapling.php b/src/pocketmine/block/Sapling.php index fafdf1571..cd0a608d1 100644 --- a/src/pocketmine/block/Sapling.php +++ b/src/pocketmine/block/Sapling.php @@ -32,26 +32,32 @@ class Sapling extends Flowable{ const SPRUCE = 1; const BIRCH = 2; const JUNGLE = 3; - const BURN_TIME = 5; + const ACACIA = 4; + const DARK_OAK = 5; - public function __construct($meta = Sapling::OAK){ - parent::__construct(self::SAPLING, $meta, "Sapling"); - $this->isActivable = true; - $names = [ - 0 => "Oak Sapling", - 1 => "Spruce Sapling", - 2 => "Birch Sapling", - 3 => "Jungle Sapling", - 4 => "Acacia Sapling", - 5 => "Dark Oak Sapling", - ]; - $this->name = $names[$this->meta & 0x07]; - $this->hardness = 0; + protected $id = self::SAPLING; + + public function __construct($meta = 0){ + $this->meta = 0; } - public function getBoundingBox(){ - return null; - } + public function canBeActivated(){ + return true; + } + + public function getName(){ + static $names = [ + 0 => "Oak Sapling", + 1 => "Spruce Sapling", + 2 => "Birch Sapling", + 3 => "Jungle Sapling", + 4 => "Acacia Sapling", + 5 => "Dark Oak Sapling", + 6 => "", + 7 => "", + ]; + return $names[$this->meta & 0x07]; + } public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ diff --git a/src/pocketmine/block/SignPost.php b/src/pocketmine/block/SignPost.php index bfece4e1f..9e4bfb277 100644 --- a/src/pocketmine/block/SignPost.php +++ b/src/pocketmine/block/SignPost.php @@ -26,13 +26,25 @@ use pocketmine\level\Level; use pocketmine\Player; class SignPost extends Transparent{ + + protected $id = self::SIGN_POST; + public function __construct($meta = 0){ - parent::__construct(self::SIGN_POST, $meta, "Sign Post"); - $this->isSolid = false; - $this->isFullBlock = false; - $this->hardness = 5; + $this->meta = $meta; } + public function getHardness(){ + return 5; + } + + public function isSolid(){ + return false; + } + + public function getName(){ + return "Sign Post"; + } + public function getBoundingBox(){ return null; } diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index 8ba761364..882917ecf 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -26,27 +26,31 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\Player; class Slab extends Transparent{ + + protected $id = self::SLAB; + public function __construct($meta = 0){ - parent::__construct(self::SLAB, $meta, "Slab"); - $names = [ - 0 => "Stone", - 1 => "Sandstone", - 2 => "Wooden", - 3 => "Cobblestone", - 4 => "Brick", - 5 => "Stone Brick", - 6 => "Quartz", - 7 => "", - ]; - $this->name = (($this->meta & 0x08) === 0x08 ? "Upper " : "") . $names[$this->meta & 0x07] . " Slab"; - if(($this->meta & 0x08) === 0x08){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 30; + $this->meta = $meta; } + public function getHardness(){ + return 30; + } + + public function getName(){ + static $names = [ + 0 => "Stone", + 1 => "Sandstone", + 2 => "Wooden", + 3 => "Cobblestone", + 4 => "Brick", + 5 => "Stone Brick", + 6 => "Quartz", + 7 => "", + ]; + return (($this->meta & 0x08) === 0x08 ? "Upper " : "") . $names[$this->meta & 0x07] . " Slab"; + } + protected function recalculateBoundingBox(){ if(($this->meta & 0x08) > 0){ diff --git a/src/pocketmine/block/Snow.php b/src/pocketmine/block/Snow.php index e841621d7..f0cd4b7e8 100644 --- a/src/pocketmine/block/Snow.php +++ b/src/pocketmine/block/Snow.php @@ -23,9 +23,19 @@ namespace pocketmine\block; class Snow extends Solid{ + + protected $id = self::SNOW_BLOCK; + public function __construct(){ - parent::__construct(self::SNOW_BLOCK, 0, "Snow Block"); - $this->hardness = 1; + } + public function getHardness(){ + return 1; + } + + public function getName(){ + return "Snow Block"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/SnowLayer.php b/src/pocketmine/block/SnowLayer.php index 9bf63659b..b817545ca 100644 --- a/src/pocketmine/block/SnowLayer.php +++ b/src/pocketmine/block/SnowLayer.php @@ -26,17 +26,24 @@ use pocketmine\level\Level; use pocketmine\Player; class SnowLayer extends Flowable{ + + protected $id = self::SNOW_LAYER; + public function __construct($meta = 0){ - parent::__construct(self::SNOW_LAYER, $meta, "Snow Layer"); - $this->isReplaceable = true; - $this->isSolid = false; - $this->isFullBlock = false; - $this->hardness = 0.5; + $this->meta = $meta; } - public function getBoundingBox(){ - return null; - } + public function getName(){ + return "Snow Layer"; + } + + public function canBeReplaced(){ + return true; + } + + public function getHardness(){ + return 0.5; + } public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ diff --git a/src/pocketmine/block/Solid.php b/src/pocketmine/block/Solid.php index 587007b0a..3a1eaf33a 100644 --- a/src/pocketmine/block/Solid.php +++ b/src/pocketmine/block/Solid.php @@ -22,6 +22,8 @@ namespace pocketmine\block; abstract class Solid extends Block{ - public $isSolid = true; - public $isFullBlock = true; + + public function isSolid(){ + return true; + } } \ No newline at end of file diff --git a/src/pocketmine/block/SoulSand.php b/src/pocketmine/block/SoulSand.php index 0b0d02d41..eb41e2810 100644 --- a/src/pocketmine/block/SoulSand.php +++ b/src/pocketmine/block/SoulSand.php @@ -25,11 +25,21 @@ namespace pocketmine\block; use pocketmine\math\AxisAlignedBB; class SoulSand extends Solid{ + + protected $id = self::SOUL_SAND; + public function __construct(){ - parent::__construct(self::SOUL_SAND, 0, "Soul Sand"); - $this->hardness = 2.5; + } + public function getName(){ + return "Soul Sand"; + } + + public function getHardness(){ + return 2.5; + } + protected function recalculateBoundingBox(){ return new AxisAlignedBB( diff --git a/src/pocketmine/block/Sponge.php b/src/pocketmine/block/Sponge.php index fcc482f77..35e7a7a32 100644 --- a/src/pocketmine/block/Sponge.php +++ b/src/pocketmine/block/Sponge.php @@ -23,9 +23,19 @@ namespace pocketmine\block; class Sponge extends Solid{ + + protected $id = self::SPONGE; + public function __construct(){ - parent::__construct(self::SPONGE, "Sponge"); - $this->hardness = 3; + } + public function getHardness(){ + return 3; + } + + public function getName(){ + return "Sponge"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/SpruceWoodStairs.php b/src/pocketmine/block/SpruceWoodStairs.php index 0c06f3f03..549e224f9 100644 --- a/src/pocketmine/block/SpruceWoodStairs.php +++ b/src/pocketmine/block/SpruceWoodStairs.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class SpruceWoodStairs extends Stair{ + + protected $id = self::SPRUCE_WOOD_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::SPRUCE_WOOD_STAIRS, $meta, "Spruce Wood Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Spruce Wood Stairs"; + } + public function getDrops(Item $item){ return [ [$this->id, 0, 1], diff --git a/src/pocketmine/block/StainedClay.php b/src/pocketmine/block/StainedClay.php index 9be2c33e4..c23c390e4 100644 --- a/src/pocketmine/block/StainedClay.php +++ b/src/pocketmine/block/StainedClay.php @@ -24,30 +24,39 @@ namespace pocketmine\block; use pocketmine\item\Item; class StainedClay extends Solid{ + + protected $id = self::STAINED_CLAY; + public function __construct($meta = 0){ - parent::__construct(self::STAINED_CLAY, $meta, "Stained Clay"); - $names = [ - 0 => "White Stained Clay", - 1 => "Orange Stained Clay", - 2 => "Magenta Stained Clay", - 3 => "Light Blue Stained Clay", - 4 => "Yellow Stained Clay", - 5 => "Lime Stained Clay", - 6 => "Pink Stained Clay", - 7 => "Gray Stained Clay", - 8 => "Light Gray Stained Clay", - 9 => "Cyan Stained Clay", - 10 => "Purple Stained Clay", - 11 => "Blue Stained Clay", - 12 => "Brown Stained Clay", - 13 => "Green Stained Clay", - 14 => "Red Stained Clay", - 15 => "Black Stained Clay", - ]; - $this->name = $names[$this->meta]; - $this->hardness = 30; + $this->meta = $meta; } + public function getHardness(){ + return 30; + } + + public function getName(){ + static $names = [ + 0 => "White Stained Clay", + 1 => "Orange Stained Clay", + 2 => "Magenta Stained Clay", + 3 => "Light Blue Stained Clay", + 4 => "Yellow Stained Clay", + 5 => "Lime Stained Clay", + 6 => "Pink Stained Clay", + 7 => "Gray Stained Clay", + 8 => "Light Gray Stained Clay", + 9 => "Cyan Stained Clay", + 10 => "Purple Stained Clay", + 11 => "Blue Stained Clay", + 12 => "Brown Stained Clay", + 13 => "Green Stained Clay", + 14 => "Red Stained Clay", + 15 => "Black Stained Clay", + ]; + return $names[$this->meta]; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/Stair.php b/src/pocketmine/block/Stair.php index 0a4473d07..fbf3fa9de 100644 --- a/src/pocketmine/block/Stair.php +++ b/src/pocketmine/block/Stair.php @@ -27,15 +27,9 @@ use pocketmine\Player; abstract class Stair extends Transparent{ - public function __construct($id, $meta = 0, $name = "Unknown"){ - parent::__construct($id, $meta, $name); - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 30; - } + public function getHardness(){ + return 30; + } /* public function collidesWithBB(AxisAlignedBB $bb, &$list = []){ diff --git a/src/pocketmine/block/StillLava.php b/src/pocketmine/block/StillLava.php index 57195c2ac..051062b2d 100644 --- a/src/pocketmine/block/StillLava.php +++ b/src/pocketmine/block/StillLava.php @@ -22,9 +22,15 @@ namespace pocketmine\block; class StillLava extends Lava{ - public function __construct($meta = 0){ - parent::__construct(self::STILL_LAVA, $meta, "Still Lava"); - $this->hardness = 500; - } + + protected $id = self::STILL_LAVA; + + public function getName(){ + return "Still Lava"; + } + + public function getHardness(){ + return 500; + } } \ No newline at end of file diff --git a/src/pocketmine/block/StillWater.php b/src/pocketmine/block/StillWater.php index a2f24d5d6..aaf3a6db5 100644 --- a/src/pocketmine/block/StillWater.php +++ b/src/pocketmine/block/StillWater.php @@ -22,9 +22,10 @@ namespace pocketmine\block; class StillWater extends Water{ - public function __construct($meta = 0){ - Liquid::__construct(self::STILL_WATER, $meta, "Still Water"); - $this->hardness = 500; - } + + protected $id = self::STILL_WATER; + public function getName(){ + return "Still Water"; + } } \ No newline at end of file diff --git a/src/pocketmine/block/Stone.php b/src/pocketmine/block/Stone.php index ff663a624..dbc472082 100644 --- a/src/pocketmine/block/Stone.php +++ b/src/pocketmine/block/Stone.php @@ -33,24 +33,31 @@ class Stone extends Solid{ const ANDESITE = 5; const POLISHED_ANDESITE = 6; - protected $hardness = 30; protected $id = self::STONE; public function __construct($meta = 0){ $this->meta = $meta; - $names = [ - self::NORMAL => "Stone", - self::GRANITE => "Granite", - self::POLISHED_GRANITE => "Polished Granite", - self::DIORITE => "Diorite", - self::POLISHED_DIORITE => "Polished Diorite", - self::ANDESITE => "Andesite", - self::POLISHED_ANDESITE => "Polished Andesite", - 7 => "Unknown Stone", - ]; - $this->name = $names[$this->meta & 0x07]; + } + public function getHardness(){ + return 30; + } + + public function getName(){ + static $names = [ + self::NORMAL => "Stone", + self::GRANITE => "Granite", + self::POLISHED_GRANITE => "Polished Granite", + self::DIORITE => "Diorite", + self::POLISHED_DIORITE => "Polished Diorite", + self::ANDESITE => "Andesite", + self::POLISHED_ANDESITE => "Polished Andesite", + 7 => "Unknown Stone", + ]; + return $names[$this->meta & 0x07]; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ case 5: diff --git a/src/pocketmine/block/StoneBrickStairs.php b/src/pocketmine/block/StoneBrickStairs.php index ede6833fc..c94ac49b1 100644 --- a/src/pocketmine/block/StoneBrickStairs.php +++ b/src/pocketmine/block/StoneBrickStairs.php @@ -23,8 +23,15 @@ namespace pocketmine\block; class StoneBrickStairs extends Stair{ + + protected $id = self::STONE_BRICK_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::STONE_BRICK_STAIRS, $meta, "Stone Brick Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Stone Brick Stairs"; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/StoneBricks.php b/src/pocketmine/block/StoneBricks.php index 5a776cd72..7821c15de 100644 --- a/src/pocketmine/block/StoneBricks.php +++ b/src/pocketmine/block/StoneBricks.php @@ -24,18 +24,27 @@ namespace pocketmine\block; use pocketmine\item\Item; class StoneBricks extends Solid{ + + protected $id = self::STONE_BRICKS; + public function __construct($meta = 0){ - parent::__construct(self::STONE_BRICKS, $meta, "Stone Bricks"); - $names = [ - 0 => "Stone Bricks", - 1 => "Mossy Stone Bricks", - 2 => "Cracked Stone Bricks", - 3 => "Chiseled Stone Bricks", - ]; - $this->name = $names[$this->meta & 0x03]; - $this->hardness = 30; + $this->meta = $meta; } + public function getHardness(){ + return 30; + } + + public function getName(){ + static $names = [ + 0 => "Stone Bricks", + 1 => "Mossy Stone Bricks", + 2 => "Cracked Stone Bricks", + 3 => "Chiseled Stone Bricks", + ]; + return $names[$this->meta & 0x03]; + } + public function getBreakTime(Item $item){ switch($item->isPickaxe()){ diff --git a/src/pocketmine/block/StoneWall.php b/src/pocketmine/block/StoneWall.php index cde98c444..be277af8b 100644 --- a/src/pocketmine/block/StoneWall.php +++ b/src/pocketmine/block/StoneWall.php @@ -25,17 +25,29 @@ namespace pocketmine\block; use pocketmine\math\AxisAlignedBB; class StoneWall extends Transparent{ + + protected $id = self::STONE_WALL; + public function __construct($meta = 0){ - $meta &= 0x01; - parent::__construct(self::STONE_WALL, $meta, "Cobblestone Wall"); - if($meta === 1){ - $this->name = "Mossy Cobblestone Wall"; - } - $this->isFullBlock = false; - $this->isSolid = false; - $this->hardness = 30; + $this->meta = $meta; } + public function isSolid(){ + return false; + } + + public function getHardness(){ + return 30; + } + + public function getName(){ + if($this->meta === 0x01){ + return "Mossy Cobblestone Wall"; + } + + return "Cobblestone Wall"; + } + protected function recalculateBoundingBox(){ $flag = $this->canConnect($this->getSide(2)); diff --git a/src/pocketmine/block/Stonecutter.php b/src/pocketmine/block/Stonecutter.php index 6a32b788b..9b7a5f0d4 100644 --- a/src/pocketmine/block/Stonecutter.php +++ b/src/pocketmine/block/Stonecutter.php @@ -26,11 +26,21 @@ use pocketmine\Player; //TODO: check orientation class Stonecutter extends Solid{ + + protected $id = self::STONECUTTER; + public function __construct($meta = 0){ - parent::__construct(self::STONECUTTER, $meta, "Stonecutter"); - $this->isActivable = true; + $this->meta = $meta; } + public function getName(){ + return "Stonecutter"; + } + + public function canBeActivated(){ + return true; + } + public function onActivate(Item $item, Player $player = null){ if($player instanceof Player){ $player->craftingType = 2; diff --git a/src/pocketmine/block/Sugarcane.php b/src/pocketmine/block/Sugarcane.php index 262604a48..a98b5a361 100644 --- a/src/pocketmine/block/Sugarcane.php +++ b/src/pocketmine/block/Sugarcane.php @@ -29,14 +29,16 @@ use pocketmine\Player; use pocketmine\Server; class Sugarcane extends Flowable{ + + protected $id = self::SUGARCANE_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::SUGARCANE_BLOCK, $meta, "Sugarcane"); - $this->hardness = 0; + $this->meta = $meta; } - public function getBoundingBox(){ - return null; - } + public function getName(){ + return "Sugarcane"; + } public function getDrops(Item $item){ diff --git a/src/pocketmine/block/TNT.php b/src/pocketmine/block/TNT.php index 90bf9b01b..89d186601 100644 --- a/src/pocketmine/block/TNT.php +++ b/src/pocketmine/block/TNT.php @@ -32,12 +32,25 @@ use pocketmine\Player; use pocketmine\utils\Random; class TNT extends Solid{ + + protected $id = self::TNT; + public function __construct(){ - parent::__construct(self::TNT, 0, "TNT"); - $this->hardness = 0; - $this->isActivable = true; + } + public function getName(){ + return "TNT"; + } + + public function getHardness(){ + return 0; + } + + public function canBeActivated(){ + return true; + } + public function onActivate(Item $item, Player $player = null){ if($item->getID() === Item::FLINT_STEEL){ $item->useOn($this); diff --git a/src/pocketmine/block/TallGrass.php b/src/pocketmine/block/TallGrass.php index f9d25e98c..e7f25ff83 100644 --- a/src/pocketmine/block/TallGrass.php +++ b/src/pocketmine/block/TallGrass.php @@ -25,21 +25,26 @@ use pocketmine\item\Item; use pocketmine\level\Level; class TallGrass extends Flowable{ + + protected $id = self::TALL_GRASS; + public function __construct($meta = 1){ - parent::__construct(self::TALL_GRASS, $meta, "Tall Grass"); - $this->isReplaceable = true; - $names = [ - 0 => "Dead Shrub", - 1 => "Tall Grass", - 2 => "Fern", - ]; - $this->name = $names[$this->meta & 0x03]; - $this->hardness = 0; + $this->meta = $meta; } - public function getBoundingBox(){ - return null; - } + public function canBeReplaced(){ + return true; + } + + public function getName(){ + static $names = [ + 0 => "Dead Shrub", + 1 => "Tall Grass", + 2 => "Fern", + 3 => "" + ]; + return $names[$this->meta & 0x03]; + } public function onUpdate($type){ diff --git a/src/pocketmine/block/Thin.php b/src/pocketmine/block/Thin.php index cc9dae1cc..a3958c463 100644 --- a/src/pocketmine/block/Thin.php +++ b/src/pocketmine/block/Thin.php @@ -26,8 +26,9 @@ use pocketmine\math\AxisAlignedBB; abstract class Thin extends Transparent{ - public $isFullBlock = false; - public $isSolid = false; + public function isSolid(){ + return false; + } protected function recalculateBoundingBox(){ diff --git a/src/pocketmine/block/Torch.php b/src/pocketmine/block/Torch.php index 100ee18a1..096406bf6 100644 --- a/src/pocketmine/block/Torch.php +++ b/src/pocketmine/block/Torch.php @@ -27,16 +27,19 @@ use pocketmine\Player; class Torch extends Flowable{ - public $lightLevel = 15; + protected $id = self::TORCH; public function __construct($meta = 0){ - parent::__construct(self::TORCH, $meta, "Torch"); - $this->hardness = 0; + $this->meta = $meta; } - public function getBoundingBox(){ - return null; - } + public function getLightLevel(){ + return 15; + } + + public function getName(){ + return "Torch"; + } public function onUpdate($type){ diff --git a/src/pocketmine/block/Transparent.php b/src/pocketmine/block/Transparent.php index 65feab367..10571c47b 100644 --- a/src/pocketmine/block/Transparent.php +++ b/src/pocketmine/block/Transparent.php @@ -24,11 +24,8 @@ namespace pocketmine\block; abstract class Transparent extends Block{ - public $isActivable = false; - public $breakable = true; - public $isFlowable = false; - public $isTransparent = true; - public $isReplaceable = false; - public $isPlaceable = true; - public $isSolid = true; + + public function isTransparent(){ + return true; + } } \ No newline at end of file diff --git a/src/pocketmine/block/Trapdoor.php b/src/pocketmine/block/Trapdoor.php index 13d17b782..d58fcf376 100644 --- a/src/pocketmine/block/Trapdoor.php +++ b/src/pocketmine/block/Trapdoor.php @@ -26,17 +26,25 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\Player; class Trapdoor extends Transparent{ + + protected $id = self::TRAPDOOR; + public function __construct($meta = 0){ - parent::__construct(self::TRAPDOOR, $meta, "Trapdoor"); - $this->isActivable = true; - if(($this->meta & 0x04) === 0x04){ - $this->isFullBlock = false; - }else{ - $this->isFullBlock = true; - } - $this->hardness = 15; + $this->meta = $meta; } + public function getName(){ + return "Trapdoor"; + } + + public function getHardness(){ + return 15; + } + + public function canBeActivated(){ + return true; + } + protected function recalculateBoundingBox(){ $damage = $this->getDamage(); diff --git a/src/pocketmine/block/Vine.php b/src/pocketmine/block/Vine.php index 9a6f68147..c25cb2b23 100644 --- a/src/pocketmine/block/Vine.php +++ b/src/pocketmine/block/Vine.php @@ -30,15 +30,28 @@ use pocketmine\Player; class Vine extends Transparent{ - public $hasEntityCollision = true; + protected $id = self::VINE; public function __construct($meta = 0){ - parent::__construct(self::VINE, $meta, "Vines"); - $this->isSolid = false; - $this->isFullBlock = false; - $this->hardness = 1; + $this->meta = $meta; } + public function isSolid(){ + return false; + } + + public function getName(){ + return "Vines"; + } + + public function getHardness(){ + return 1; + } + + public function hasEntityCollision(){ + return true; + } + public function onEntityCollide(Entity $entity){ $entity->fallDistance = 0; } diff --git a/src/pocketmine/block/WallSign.php b/src/pocketmine/block/WallSign.php index 7d7c7b898..2e04b1ac1 100644 --- a/src/pocketmine/block/WallSign.php +++ b/src/pocketmine/block/WallSign.php @@ -23,14 +23,12 @@ namespace pocketmine\block; class WallSign extends SignPost{ - public function __construct($meta = 0){ - Transparent::__construct(self::WALL_SIGN, $meta, "Wall Sign"); - } - public function getBoundingBox(){ - return null; - } + protected $id = self::WALL_SIGN; + public function getName(){ + return "Wall Sign"; + } public function onUpdate($type){ return false; diff --git a/src/pocketmine/block/Water.php b/src/pocketmine/block/Water.php index 8a8bbe3be..49f36375d 100644 --- a/src/pocketmine/block/Water.php +++ b/src/pocketmine/block/Water.php @@ -26,10 +26,20 @@ use pocketmine\item\Item; use pocketmine\Player; class Water extends Liquid{ + + protected $id = self::WATER; + public function __construct($meta = 0){ - parent::__construct(self::WATER, $meta, "Water"); - $this->hardness = 500; + $this->meta = $meta; } + + public function getName(){ + return "Water"; + } + + public function getHardness(){ + return 500; + } public function onEntityCollide(Entity $entity){ $entity->fallDistance = 0; diff --git a/src/pocketmine/block/Wheat.php b/src/pocketmine/block/Wheat.php index fe29fd52e..35a9b5897 100644 --- a/src/pocketmine/block/Wheat.php +++ b/src/pocketmine/block/Wheat.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class Wheat extends Crops{ + + protected $id = self::WHEAT_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::WHEAT_BLOCK, $meta, "Wheat Block"); + $this->meta = $meta; } + public function getName(){ + return "Wheat Block"; + } + public function getDrops(Item $item){ $drops = []; if($this->meta >= 0x07){ diff --git a/src/pocketmine/block/Wood.php b/src/pocketmine/block/Wood.php index a5e5a426f..0bd8e0489 100644 --- a/src/pocketmine/block/Wood.php +++ b/src/pocketmine/block/Wood.php @@ -29,21 +29,29 @@ class Wood extends Solid{ const SPRUCE = 1; const BIRCH = 2; const JUNGLE = 3; - const ACACIA = 4; - const DARK_OAK = 5; + //const ACACIA = 4; + //const DARK_OAK = 5; + + protected $id = self::WOOD; public function __construct($meta = 0){ - parent::__construct(self::WOOD, $meta, "Wood"); - $names = [ - self::OAK => "Oak Wood", - self::SPRUCE => "Spruce Wood", - self::BIRCH => "Birch Wood", - self::JUNGLE => "Jungle Wood", - ]; - $this->name = $names[$this->meta & 0x03]; - $this->hardness = 10; + $this->meta = $meta; } + public function getHardness(){ + return 10; + } + + public function getName(){ + static $names = [ + self::OAK => "Oak Wood", + self::SPRUCE => "Spruce Wood", + self::BIRCH => "Birch Wood", + self::JUNGLE => "Jungle Wood", + ]; + return $names[$this->meta & 0x03]; + } + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ $faces = [ 0 => 0, diff --git a/src/pocketmine/block/Wood2.php b/src/pocketmine/block/Wood2.php index 3dad000ff..8aec3a2fa 100644 --- a/src/pocketmine/block/Wood2.php +++ b/src/pocketmine/block/Wood2.php @@ -27,14 +27,14 @@ class Wood2 extends Wood{ const ACACIA = 0; const DARK_OAK = 1; - public function __construct($meta = 0){ - Solid::__construct(self::WOOD2, $meta, "Wood"); - $names = [ - 0 => "Acacia Wood", - 1 => "Dark Oak Wood", - 2 => "" - ]; - $this->name = $names[$this->meta & 0x03]; - $this->hardness = 10; - } + protected $id = self::WOOD2; + + public function getName(){ + static $names = [ + 0 => "Acacia Wood", + 1 => "Dark Oak Wood", + 2 => "" + ]; + return $names[$this->meta & 0x03]; + } } diff --git a/src/pocketmine/block/WoodDoor.php b/src/pocketmine/block/WoodDoor.php index 25962e31a..e5debe0b2 100644 --- a/src/pocketmine/block/WoodDoor.php +++ b/src/pocketmine/block/WoodDoor.php @@ -24,12 +24,25 @@ namespace pocketmine\block; use pocketmine\item\Item; class WoodDoor extends Door{ + + protected $id = self::WOOD_DOOR_BLOCK; + public function __construct($meta = 0){ - parent::__construct(self::WOOD_DOOR_BLOCK, $meta, "Wood Door Block"); - $this->isActivable = true; - $this->hardness = 15; + $this->meta = $meta; } + public function getName(){ + return "Wood Door Block"; + } + + public function canBeActivated(){ + return true; + } + + public function getHardness(){ + return 15; + } + public function getDrops(Item $item){ return [ [Item::WOODEN_DOOR, 0, 1], diff --git a/src/pocketmine/block/WoodSlab.php b/src/pocketmine/block/WoodSlab.php index d73daf13c..567ca209d 100644 --- a/src/pocketmine/block/WoodSlab.php +++ b/src/pocketmine/block/WoodSlab.php @@ -26,25 +26,31 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\Player; class WoodSlab extends Transparent{ + + protected $id = self::WOOD_SLAB; + public function __construct($meta = 0){ - parent::__construct(self::WOOD_SLAB, $meta, "Wooden Slab"); - $names = [ - 0 => "Oak", - 1 => "Spruce", - 2 => "Birch", - 3 => "Jungle", - 4 => "Acacia", - 5 => "Dark Oak", - ]; - $this->name = (($this->meta & 0x08) === 0x08 ? "Upper " : "") . $names[$this->meta & 0x07] . " Wooden Slab"; - if(($this->meta & 0x08) === 0x08){ - $this->isFullBlock = true; - }else{ - $this->isFullBlock = false; - } - $this->hardness = 15; + $this->meta = $meta; } + public function getHardness(){ + return 15; + } + + public function getName(){ + static $names = [ + 0 => "Oak", + 1 => "Spruce", + 2 => "Birch", + 3 => "Jungle", + 4 => "Acacia", + 5 => "Dark Oak", + 6 => "", + 7 => "" + ]; + return (($this->meta & 0x08) === 0x08 ? "Upper " : "") . $names[$this->meta & 0x07] . " Wooden Slab"; + } + protected function recalculateBoundingBox(){ if(($this->meta & 0x08) > 0){ diff --git a/src/pocketmine/block/WoodStairs.php b/src/pocketmine/block/WoodStairs.php index 64f5dc5e3..7826c4cb9 100644 --- a/src/pocketmine/block/WoodStairs.php +++ b/src/pocketmine/block/WoodStairs.php @@ -24,10 +24,17 @@ namespace pocketmine\block; use pocketmine\item\Item; class WoodStairs extends Stair{ + + protected $id = self::WOOD_STAIRS; + public function __construct($meta = 0){ - parent::__construct(self::WOOD_STAIRS, $meta, "Wood Stairs"); + $this->meta = $meta; } + public function getName(){ + return "Wood Stairs"; + } + public function getBreakTime(Item $item){ switch($item->isAxe()){ diff --git a/src/pocketmine/block/Wool.php b/src/pocketmine/block/Wool.php index 6d7fb3390..a2493613f 100644 --- a/src/pocketmine/block/Wool.php +++ b/src/pocketmine/block/Wool.php @@ -23,28 +23,37 @@ namespace pocketmine\block; class Wool extends Solid{ + + protected $id = self::WOOL; + public function __construct($meta = 0){ - parent::__construct(self::WOOL, $meta, "Wool"); - $names = [ - 0 => "White Wool", - 1 => "Orange Wool", - 2 => "Magenta Wool", - 3 => "Light Blue Wool", - 4 => "Yellow Wool", - 5 => "Lime Wool", - 6 => "Pink Wool", - 7 => "Gray Wool", - 8 => "Light Gray Wool", - 9 => "Cyan Wool", - 10 => "Purple Wool", - 11 => "Blue Wool", - 12 => "Brown Wool", - 13 => "Green Wool", - 14 => "Red Wool", - 15 => "Black Wool", - ]; - $this->name = $names[$this->meta]; - $this->hardness = 4; + $this->meta = $meta; } + public function getHardness(){ + return 4; + } + + public function getName(){ + static $names = [ + 0 => "White Wool", + 1 => "Orange Wool", + 2 => "Magenta Wool", + 3 => "Light Blue Wool", + 4 => "Yellow Wool", + 5 => "Lime Wool", + 6 => "Pink Wool", + 7 => "Gray Wool", + 8 => "Light Gray Wool", + 9 => "Cyan Wool", + 10 => "Purple Wool", + 11 => "Blue Wool", + 12 => "Brown Wool", + 13 => "Green Wool", + 14 => "Red Wool", + 15 => "Black Wool", + ]; + return $names[$this->meta]; + } + } \ No newline at end of file diff --git a/src/pocketmine/block/Workbench.php b/src/pocketmine/block/Workbench.php index 8b5c287d6..75bf45d59 100644 --- a/src/pocketmine/block/Workbench.php +++ b/src/pocketmine/block/Workbench.php @@ -26,12 +26,25 @@ use pocketmine\Player; //TODO: check orientation class Workbench extends Solid{ + + protected $id = self::WORKBENCH; + public function __construct($meta = 0){ - parent::__construct(self::WORKBENCH, $meta, "Crafting Table"); - $this->isActivable = true; - $this->hardness = 15; + $this->meta = $meta; } + public function canBeActivated(){ + return true; + } + + public function getHardness(){ + return 15; + } + + public function getName(){ + return "Crafting Table"; + } + public function onActivate(Item $item, Player $player = null){ if($player instanceof Player){ $player->craftingType = 1;