From a3bce67d35bda64e35a32b7d8a363e45b03fcd99 Mon Sep 17 00:00:00 2001 From: willowmaster66 Date: Fri, 18 Sep 2015 22:17:24 +0200 Subject: [PATCH] Updating blocks and items Added new blocks/items and added constants to existing blocks/items for clearer recipe making. --- src/pocketmine/block/Block.php | 4 +- src/pocketmine/block/DoubleSlab.php | 2 +- src/pocketmine/block/Fence.php | 22 ++++--- src/pocketmine/block/NetherBrickFence.php | 72 +++++++++++++++++++++++ src/pocketmine/block/Quartz.php | 13 ++-- src/pocketmine/block/Sandstone.php | 10 +++- src/pocketmine/block/Slab.php | 24 +++++--- src/pocketmine/block/StoneBricks.php | 12 ++-- src/pocketmine/block/StoneWall.php | 2 + src/pocketmine/item/Item.php | 18 +++--- src/pocketmine/item/NetherQuartz.php | 29 +++++++++ 11 files changed, 171 insertions(+), 37 deletions(-) create mode 100644 src/pocketmine/block/NetherBrickFence.php create mode 100644 src/pocketmine/item/NetherQuartz.php diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 833eab7cb..a02ec99c4 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -181,7 +181,7 @@ class Block extends Position implements Metadatable{ const LILY_PAD = 111; const NETHER_BRICKS = 112; const NETHER_BRICK_BLOCK = 112; - + const NETHER_BRICK_FENCE = 113; const NETHER_BRICKS_STAIRS = 114; const ENCHANTING_TABLE = 116; @@ -413,7 +413,7 @@ class Block extends Position implements Metadatable{ self::$list[self::MYCELIUM] = Mycelium::class; self::$list[self::WATER_LILY] = WaterLily::class; self::$list[self::NETHER_BRICKS] = NetherBrick::class; - + self::$list[self::NETHER_BRICK_FENCE] = NetherBrickFence::class; self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class; self::$list[self::ENCHANTING_TABLE] = EnchantingTable::class; diff --git a/src/pocketmine/block/DoubleSlab.php b/src/pocketmine/block/DoubleSlab.php index 23c712ab8..cf037e961 100644 --- a/src/pocketmine/block/DoubleSlab.php +++ b/src/pocketmine/block/DoubleSlab.php @@ -49,7 +49,7 @@ class DoubleSlab extends Solid{ 4 => "Brick", 5 => "Stone Brick", 6 => "Quartz", - 7 => "", + 7 => "Nether Brick", ]; return "Double " . $names[$this->meta & 0x07] . " Slab"; } diff --git a/src/pocketmine/block/Fence.php b/src/pocketmine/block/Fence.php index 2262e1490..510ea39f7 100644 --- a/src/pocketmine/block/Fence.php +++ b/src/pocketmine/block/Fence.php @@ -26,7 +26,13 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\math\Vector3; class Fence extends Transparent{ - + const FENCE_OAK = 0; + const FENCE_SPRUCE = 1; + const FENCE_BIRCH = 2; + const FENCE_JUNGLE = 3; + const FENCE_ACACIA = 4; + const FENCE_DARKOAK = 5; + protected $id = self::FENCE; public function __construct($meta = 0){ @@ -38,18 +44,18 @@ class Fence extends Transparent{ } public function getToolType(){ - return Tool::TYPE_PICKAXE; + return Tool::TYPE_AXE; } public function getName(){ static $names = [ - 0 => "Oak Fence", - 1 => "Spruce Fence", - 2 => "Birch Fence", - 3 => "Jungle Fence", - 4 => "Acacia Fence", - 5 => "Dark Oak Fence", + self::FENCE_OAK => "Oak Fence", + self::FENCE_SPRUCE => "Spruce Fence", + self::FENCE_BIRCH => "Birch Fence", + self::FENCE_JUNGLE => "Jungle Fence", + self::FENCE_ACACIA => "Acacia Fence", + self::FENCE_DARKOAK => "Dark Oak Fence", "", "" ]; diff --git a/src/pocketmine/block/NetherBrickFence.php b/src/pocketmine/block/NetherBrickFence.php new file mode 100644 index 000000000..10fb148a8 --- /dev/null +++ b/src/pocketmine/block/NetherBrickFence.php @@ -0,0 +1,72 @@ +isSolid() and !$block->isTransparent(); + } + + public function getDrops(Item $item){ + if($item->isPickaxe()){ + return [ + [Item::FENCE, Fence::FENCE_NETHER_BRICK, 1], + ]; + }else{ + return []; + } + } +} diff --git a/src/pocketmine/block/Quartz.php b/src/pocketmine/block/Quartz.php index 74b4deb72..5dacc3eb7 100644 --- a/src/pocketmine/block/Quartz.php +++ b/src/pocketmine/block/Quartz.php @@ -26,6 +26,11 @@ use pocketmine\item\Tool; class Quartz extends Solid{ + const QUARTZ_NORMAL = 0; + const QUARTZ_CHISELED = 1; + const QUARTZ_PILLAR = 2; + const QUARTZ_PILLAR2 = 3; + protected $id = self::QUARTZ_BLOCK; public function __construct($meta = 0){ @@ -38,10 +43,10 @@ class Quartz extends Solid{ public function getName(){ static $names = [ - 0 => "Quartz Block", - 1 => "Chiseled Quartz Block", - 2 => "Quartz Pillar", - 3 => "Quartz Pillar", + self::QUARTZ_NORMAL => "Quartz Block", + self::QUARTZ_CHISELED => "Chiseled Quartz Block", + self::QUARTZ_PILLAR => "Quartz Pillar", + self::QUARTZ_PILLAR2 => "Quartz Pillar", ]; return $names[$this->meta & 0x03]; } diff --git a/src/pocketmine/block/Sandstone.php b/src/pocketmine/block/Sandstone.php index a94a32ae3..eab79265e 100644 --- a/src/pocketmine/block/Sandstone.php +++ b/src/pocketmine/block/Sandstone.php @@ -26,6 +26,10 @@ use pocketmine\item\Tool; class Sandstone extends Solid{ + const NORMAL = 0; + const CHISELED = 1; + const SMOOTH = 2; + protected $id = self::SANDSTONE; public function __construct($meta = 0){ @@ -38,9 +42,9 @@ class Sandstone extends Solid{ public function getName(){ static $names = [ - 0 => "Sandstone", - 1 => "Chiseled Sandstone", - 2 => "Smooth Sandstone", + self::NORMAL => "Sandstone", + self::CHISELED => "Chiseled Sandstone", + self::SMOOTH => "Smooth Sandstone", 3 => "", ]; return $names[$this->meta & 0x03]; diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index 303d8fbd0..9bb0e3792 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -27,6 +27,14 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\Player; class Slab extends Transparent{ + const STONE = 0; + const SANDSTONE = 1; + const WOODEN = 2; + const COBBLESTONE = 3; + const BRICK = 4; + const STONE_BRICK = 5; + const QUARTZ = 6; + const NETHER_BRICK = 7; protected $id = self::SLAB; @@ -40,14 +48,14 @@ class Slab extends Transparent{ public function getName(){ static $names = [ - 0 => "Stone", - 1 => "Sandstone", - 2 => "Wooden", - 3 => "Cobblestone", - 4 => "Brick", - 5 => "Stone Brick", - 6 => "Quartz", - 7 => "", + self::STONE => "Stone", + self::SANDSTONE => "Sandstone", + self::WOODEN => "Wooden", + self::COBBLESTONE => "Cobblestone", + self::BRICK => "Brick", + self::STONE_BRICK => "Stone Brick", + self::QUARTZ => "Quartz", + self::NETHER_BRICK => "Nether Brick", ]; return (($this->meta & 0x08) > 0 ? "Upper " : "") . $names[$this->meta & 0x07] . " Slab"; } diff --git a/src/pocketmine/block/StoneBricks.php b/src/pocketmine/block/StoneBricks.php index ecb17ed5e..0553f49a6 100644 --- a/src/pocketmine/block/StoneBricks.php +++ b/src/pocketmine/block/StoneBricks.php @@ -25,6 +25,10 @@ use pocketmine\item\Item; use pocketmine\item\Tool; class StoneBricks extends Solid{ + const NORMAL = 0; + const MOSSY = 1; + const CRACKED = 2; + const CHISELED = 3; protected $id = self::STONE_BRICKS; @@ -42,10 +46,10 @@ class StoneBricks extends Solid{ public function getName(){ static $names = [ - 0 => "Stone Bricks", - 1 => "Mossy Stone Bricks", - 2 => "Cracked Stone Bricks", - 3 => "Chiseled Stone Bricks", + self::NORMAL => "Stone Bricks", + self::MOSSY => "Mossy Stone Bricks", + self::CRACKED => "Cracked Stone Bricks", + self::CHISELED => "Chiseled Stone Bricks", ]; return $names[$this->meta & 0x03]; } diff --git a/src/pocketmine/block/StoneWall.php b/src/pocketmine/block/StoneWall.php index 953c182c0..cf689b694 100644 --- a/src/pocketmine/block/StoneWall.php +++ b/src/pocketmine/block/StoneWall.php @@ -27,6 +27,8 @@ use pocketmine\math\AxisAlignedBB; use pocketmine\math\Vector3; class StoneWall extends Transparent{ + const NONE_MOSSY_WALL = 0; + const MOSSY_WALL = 1; protected $id = self::STONE_WALL; diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index e58fbd533..4addd7116 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -25,6 +25,7 @@ namespace pocketmine\item; use pocketmine\block\Block; +use pocketmine\block\Fence; use pocketmine\block\Flower; use pocketmine\entity\Entity; use pocketmine\entity\Squid; @@ -209,7 +210,7 @@ class Item{ const LILY_PAD = 111; const NETHER_BRICKS = 112; const NETHER_BRICK_BLOCK = 112; - + const NETHER_BRICK_FENCE = 113; const NETHER_BRICKS_STAIRS = 114; const ENCHANTING_TABLE = 116; @@ -484,6 +485,7 @@ class Item{ self::$list[self::BOWL] = Bowl::class; self::$list[self::FEATHER] = Feather::class; self::$list[self::BRICK] = Brick::class; + self::$list[self::QUARTZ] = NetherQuartz::class; self::$list[self::LEATHER_CAP] = LeatherCap::class; self::$list[self::LEATHER_TUNIC] = LeatherTunic::class; self::$list[self::LEATHER_PANTS] = LeatherPants::class; @@ -649,6 +651,7 @@ class Item{ self::addCreativeItem(Item::get(Item::ICE, 0)); self::addCreativeItem(Item::get(Item::SNOW_BLOCK, 0)); self::addCreativeItem(Item::get(Item::END_STONE, 0)); + self::addCreativeItem(Item::get(Item::QUARTZ, 0)); //Decoration self::addCreativeItem(Item::get(Item::COBBLESTONE_WALL, 0)); @@ -671,12 +674,13 @@ class Item{ self::addCreativeItem(Item::get(Item::GLASS_PANE, 0)); self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 0)); self::addCreativeItem(Item::get(Item::TRAPDOOR, 0)); - self::addCreativeItem(Item::get(Item::FENCE, 0)); - self::addCreativeItem(Item::get(Item::FENCE, 1)); - self::addCreativeItem(Item::get(Item::FENCE, 2)); - self::addCreativeItem(Item::get(Item::FENCE, 3)); - self::addCreativeItem(Item::get(Item::FENCE, 4)); - self::addCreativeItem(Item::get(Item::FENCE, 5)); + self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_OAK)); + self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_SPRUCE)); + self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_BIRCH)); + self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_JUNGLE)); + self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_ACACIA)); + self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_DARKOAK)); + self::addCreativeItem(Item::get(Item::NETHER_BRICK_FENCE, 0)); self::addCreativeItem(Item::get(Item::FENCE_GATE, 0)); self::addCreativeItem(Item::get(Item::FENCE_GATE_BIRCH, 0)); self::addCreativeItem(Item::get(Item::FENCE_GATE_SPRUCE, 0)); diff --git a/src/pocketmine/item/NetherQuartz.php b/src/pocketmine/item/NetherQuartz.php new file mode 100644 index 000000000..070d804a0 --- /dev/null +++ b/src/pocketmine/item/NetherQuartz.php @@ -0,0 +1,29 @@ +