From ccca3ec0bf3fbb942d7382452f07d8c8f8c16676 Mon Sep 17 00:00:00 2001 From: Yosshi999 Date: Sun, 6 Sep 2015 22:55:56 +0900 Subject: [PATCH 01/36] FIxed a bug No sound for FenceGate missing "use pocketmine\level\sound\DoorSound;" --- src/pocketmine/block/FenceGate.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pocketmine/block/FenceGate.php b/src/pocketmine/block/FenceGate.php index 7c0e0f8ea..4ffef72f7 100644 --- a/src/pocketmine/block/FenceGate.php +++ b/src/pocketmine/block/FenceGate.php @@ -23,6 +23,7 @@ namespace pocketmine\block; use pocketmine\item\Item; use pocketmine\item\Tool; +use pocketmine\level\sound\DoorSound; use pocketmine\math\AxisAlignedBB; use pocketmine\Player; From 9501d03552cf522026b37ef49ddb78a7ef7591ca Mon Sep 17 00:00:00 2001 From: Yosshi999 Date: Sun, 6 Sep 2015 22:59:02 +0900 Subject: [PATCH 02/36] FIxed a bug No sound for TrapDoor missing "use pocketmine\level\sound\DoorSound;" --- src/pocketmine/block/Trapdoor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pocketmine/block/Trapdoor.php b/src/pocketmine/block/Trapdoor.php index 434b3264b..370cef37d 100644 --- a/src/pocketmine/block/Trapdoor.php +++ b/src/pocketmine/block/Trapdoor.php @@ -24,6 +24,7 @@ namespace pocketmine\block; use pocketmine\item\Item; use pocketmine\item\Tool; use pocketmine\math\AxisAlignedBB; +use pocketmine\level\sound\DoorSound; use pocketmine\Player; class Trapdoor extends Transparent{ From a3bce67d35bda64e35a32b7d8a363e45b03fcd99 Mon Sep 17 00:00:00 2001 From: willowmaster66 Date: Fri, 18 Sep 2015 22:17:24 +0200 Subject: [PATCH 03/36] 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 @@ + Date: Fri, 18 Sep 2015 22:18:14 +0200 Subject: [PATCH 04/36] Update of the stonecutter recipes Added the shaped recipes and removed the shapeless ones. --- src/pocketmine/inventory/CraftingManager.php | 175 ++++++++++++++---- ...ipe.php => StonecutterBigShapedRecipe.php} | 2 +- .../inventory/StonecutterShapedRecipe.php | 26 +++ 3 files changed, 170 insertions(+), 33 deletions(-) rename src/pocketmine/inventory/{StonecutterShapelessRecipe.php => StonecutterBigShapedRecipe.php} (92%) create mode 100644 src/pocketmine/inventory/StonecutterShapedRecipe.php diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index 381cbaeee..cdefd883e 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -21,8 +21,15 @@ namespace pocketmine\inventory; + use pocketmine\block\Planks; +use pocketmine\block\Quartz; +use pocketmine\block\Sandstone; +use pocketmine\block\Slab; +use pocketmine\block\Fence; use pocketmine\block\Stone; +use pocketmine\block\StoneBricks; +use pocketmine\block\StoneWall; use pocketmine\block\Wood; use pocketmine\block\Wood2; use pocketmine\item\Item; @@ -117,7 +124,7 @@ class CraftingManager{ $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BED, 0, 1)))->addIngredient(Item::get(Item::WOOL, null, 3))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 3))); $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::CHEST, 0, 1)))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 8))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, 0, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::OAK, 4))); + $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::OAK, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::OAK, 4))); $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::SPRUCE, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4))); $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::BIRCH, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4))); $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::JUNGLE, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4))); @@ -185,38 +192,142 @@ class CraftingManager{ $this->registerRecipe(new FurnaceRecipe(Item::get(Item::HARDENED_CLAY, 0, 1), Item::get(Item::CLAY_BLOCK, 0, 1))); } - protected function registerStonecutter(){ - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::QUARTZ_BLOCK, 0, 1)))->addIngredient(Item::get(Item::QUARTZ, 0, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::BRICK_STAIRS, 0, 4)))->addIngredient(Item::get(Item::BRICKS_BLOCK, 0, 6))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::BRICKS_BLOCK, 0, 1)))->addIngredient(Item::get(Item::BRICK, 0, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SLAB, 4, 6)))->addIngredient(Item::get(Item::BRICKS_BLOCK, 0, 3))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::QUARTZ_BLOCK, 1, 1)))->addIngredient(Item::get(Item::SLAB, 6, 2))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SLAB, 3, 6)))->addIngredient(Item::get(Item::COBBLESTONE, 0, 3))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::COBBLESTONE_WALL, 0, 6)))->addIngredient(Item::get(Item::COBBLESTONE, 0, 6))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::COBBLESTONE_WALL, 1, 6)))->addIngredient(Item::get(Item::MOSS_STONE, 0, 6))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::NETHER_BRICKS, 0, 1)))->addIngredient(Item::get(Item::NETHER_BRICK, 0, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::NETHER_BRICKS_STAIRS, 0, 4)))->addIngredient(Item::get(Item::NETHER_BRICKS, 0, 6))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::QUARTZ_BLOCK, 2, 2)))->addIngredient(Item::get(Item::QUARTZ_BLOCK, 0, 2))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SLAB, 6, 6)))->addIngredient(Item::get(Item::QUARTZ_BLOCK, 0, 3))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SANDSTONE_STAIRS, 0, 4)))->addIngredient(Item::get(Item::SANDSTONE, 0, 6))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SANDSTONE, 0, 1)))->addIngredient(Item::get(Item::SAND, 0, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SANDSTONE, 2, 4)))->addIngredient(Item::get(Item::SANDSTONE, 0, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SANDSTONE, 1, 1)))->addIngredient(Item::get(Item::SLAB, 1, 2))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SLAB, 1, 6)))->addIngredient(Item::get(Item::SANDSTONE, 0, 3))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE_BRICK_STAIRS, 0, 4)))->addIngredient(Item::get(Item::STONE_BRICK, null, 6))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE_BRICK, 0, 4)))->addIngredient(Item::get(Item::STONE, null, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE_BRICK, 3, 1)))->addIngredient(Item::get(Item::SLAB, 5, 2))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE_BRICK, 1, 1)))->addIngredient(Item::get(Item::STONE_BRICK, 0, 1))->addIngredient(Item::get(Item::VINES, 0, 1))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SLAB, 5, 6)))->addIngredient(Item::get(Item::STONE_BRICK, null, 3))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::SLAB, 0, 6)))->addIngredient(Item::get(Item::STONE, null, 3))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::COBBLESTONE_STAIRS, 0, 4)))->addIngredient(Item::get(Item::COBBLESTONE, 0, 6))); + protected function registerStonecutter(){ + $shapes = [ + "slab" => [ + " ", + "XXX", + " " + ], + "stairs" => [ + "X ", + "XX ", + "XXX" + ], + "wall/fence" => [ + "XXX", + "XXX", + " " + ], + "blockrecipe1" => [ + "XX", + "XX" + ], + "blockrecipe2X1" => [ + " ", + " X ", + " X " + ], + "blockrecipe2X2" => [ + "AB", + "BA" + ], + "blockrecipe1X2" => [ + " ", + "AB" + ] + ]; - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE, Stone::POLISHED_GRANITE, 4)))->addIngredient(Item::get(Item::STONE, Stone::GRANITE, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE, Stone::POLISHED_DIORITE, 4)))->addIngredient(Item::get(Item::STONE, Stone::DIORITE, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE, Stone::POLISHED_ANDESITE, 4)))->addIngredient(Item::get(Item::STONE, Stone::ANDESITE, 4))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE, Stone::GRANITE, 1)))->addIngredient(Item::get(Item::STONE, Stone::DIORITE, 1))->addIngredient(Item::get(Item::QUARTZ, 0, 1))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE, Stone::DIORITE, 2)))->addIngredient(Item::get(Item::COBBLESTONE, 0, 2))->addIngredient(Item::get(Item::QUARTZ, 0, 2))); - $this->registerRecipe((new StonecutterShapelessRecipe(Item::get(Item::STONE, Stone::ANDESITE, 2)))->addIngredient(Item::get(Item::COBBLESTONE, 0, 1))->addIngredient(Item::get(Item::STONE, Stone::DIORITE, 1))); + $buildRecipes = []; + + // Single ingedient stone cutter recipes: + $RESULT_ITEMID = 0; $RESULT_META = 1; $INGREDIENT_ITEMID = 2; $INGREDIENT_META = 3; $RECIPE_SHAPE = 4;$RESULT_AMOUNT = 5; + $recipes = [ + //RESULT_ITEM_ID RESULT_META INGREDIENT_ITEMID INGREDIENT_META RECIPE_SHAPE RESULT_AMOUNT + [Item::SLAB, Slab::STONE, Item::STONE, Stone::NORMAL, "slab", 6], + [Item::SLAB, Slab::COBBLESTONE, Item::COBBLESTONE, 0, "slab", 6], + [Item::SLAB, Slab::SANDSTONE, Item::SANDSTONE, 0, "slab", 6], + [Item::SLAB, Slab::BRICK, Item::BRICK, 0, "slab", 6], + [Item::SLAB, Slab::STONE_BRICK, Item::STONE_BRICK, StoneBricks::NORMAL,"slab", 6], + [Item::SLAB, Slab::NETHER_BRICK, Item::NETHER_BRICK_BLOCK, 0, "slab", 6], + [Item::SLAB, Slab::QUARTZ, Item::QUARTZ_BLOCK, 0, "slab", 6], + [Item::COBBLESTONE_STAIRS, 0, Item::COBBLESTONE, 0, "stairs", 4], + [Item::SANDSTONE_STAIRS, 0, Item::SANDSTONE, 0, "stairs", 4], + [Item::STONE_BRICK_STAIRS, 0, Item::STONE_BRICK, StoneBricks::NORMAL,"stairs", 4], + [Item::BRICK_STAIRS, 0, Item::BRICKS_BLOCK, 0, "stairs", 4], + [Item::NETHER_BRICKS_STAIRS,0, Item::NETHER_BRICK_BLOCK, 0, "stairs", 4], + [Item::COBBLESTONE_WALL, StoneWall::NONE_MOSSY_WALL, Item::COBBLESTONE, 0, "wall/fence", 6], + [Item::COBBLESTONE_WALL, StoneWall::MOSSY_WALL, Item::MOSSY_STONE, 0, "wall/fence", 6], + [Item::NETHER_BRICK_FENCE, 0, Item::NETHER_BRICK_BLOCK, 0, "wall/fence", 6], + [Item::NETHER_BRICKS, 0, Item::NETHER_BRICK, 0, "blockrecipe1", 1], + [Item::SANDSTONE, SandStone::NORMAL, Item::SAND, 0, "blockrecipe1", 1], + [Item::SANDSTONE, Sandstone::CHISELED, Item::SANDSTONE, SandStone::NORMAL, "blockrecipe1", 4], + [Item::STONE_BRICK, StoneBricks::NORMAL, Item::STONE, Stone::NORMAL, "blockrecipe1", 4], + [Item::STONE_BRICK, StoneBricks::NORMAL, Item::STONE, Stone::POLISHED_GRANITE,"blockrecipe1", 4], + [Item::STONE_BRICK, StoneBricks::NORMAL, Item::STONE, Stone::POLISHED_DIORITE,"blockrecipe1", 4], + [Item::STONE_BRICK, StoneBricks::NORMAL, Item::STONE, Stone::POLISHED_ANDESITE,"blockrecipe1",4], + [Item::STONE, Stone::POLISHED_GRANITE, Item::STONE, Stone::GRANITE, "blockrecipe1", 4], + [Item::STONE, Stone::POLISHED_DIORITE, Item::STONE, Stone::DIORITE, "blockrecipe1", 4], + [Item::STONE, Stone::POLISHED_ANDESITE, Item::STONE, Stone::ANDESITE, "blockrecipe1", 4], + [Item::QUARTZ_BLOCK, Quartz::QUARTZ_NORMAL, Item::QUARTZ, Stone::ANDESITE, "blockrecipe1", 4], + [Item::QUARTZ_BLOCK, Quartz::QUARTZ_CHISELED, Item::SLAB, Slab::QUARTZ, "blockrecipe2X1", 1], + [Item::SANDSTONE, SandStone::CHISELED, Item::SLAB, Slab::SANDSTONE, "blockrecipe2X1", 1], + [Item::STONE_BRICK, StoneBricks::CHISELED, Item::SLAB, Slab::STONE_BRICK, "blockrecipe2X1", 1], + ]; + foreach ($recipes as $recipe){ + $buildRecipes[] = $this->createOneIngedientRecipe($shapes[$recipe[$RECIPE_SHAPE]], $recipe[$RESULT_ITEMID], $recipe[$RESULT_META], $recipe[$RESULT_AMOUNT], $recipe[$INGREDIENT_ITEMID], $recipe[$INGREDIENT_META], "X", "Stonecutter"); + } + + // Multi-ingredient stone recipes: + $buildRecipes[] = ((new StonecutterShapedRecipe(Item::get(Item::STONE, Stone::GRANITE, 1), + ...$shapes["blockrecipe1X2"] + ))->setIngredient("A", Item::get(Item::STONE, Stone::DIORITE, 1))->setIngredient("B", Item::get(Item::QUARTZ, Quartz::QUARTZ_NORMAL, 1))); + $buildRecipes[] = ((new StonecutterShapedRecipe(Item::get(Item::STONE, Stone::DIORITE, 2), + ...$shapes["blockrecipe2X2"] + ))->setIngredient("A", Item::get(Item::COBBLESTONE, 0, 2))->setIngredient("B", Item::get(Item::QUARTZ, 0, 2))); + $buildRecipes[] = ((new StonecutterShapedRecipe(Item::get(Item::STONE, Stone::ANDESITE, 2), + ...$shapes["blockrecipe1X2"] + ))->setIngredient("A", Item::get(Item::COBBLESTONE, 0, 1))->setIngredient("B", Item::get(Item::STONE, Stone::DIORITE, 1))); + $buildRecipes[] = ((new StonecutterShapedRecipe(Item::get(Item::STONE_BRICK, StoneBricks::MOSSY, 1), + ...$shapes["blockrecipe1X2"] + ))->setIngredient("A", Item::get(Item::STONE_BRICK, StoneBricks::NORMAL, 1))->setIngredient("B", Item::get(Item::VINES, 0, 1))); + + $this->sortAndAddRecipesArray($buildRecipes); + } + + private function sortAndAddRecipesArray(&$recipes){ + // Sort the recipes based on the result item name with the bubblesort algoritm. + for ($i = 0; $i < count($recipes); ++$i){ + $current = $recipes[$i]; + $result = $current->getResult(); + for ($j = count($recipes)-1; $j > $i; --$j) + { + if ($this->sort($result, $recipes[$j]->getResult())>0){ + $swap = $current; + $current = $recipes[$j]; + $recipes[$j] = $swap; + $result = $current->getResult(); + } + } + $this->registerRecipe($current); + } + } + + private function createOneIngedientRecipe($recipeshape, $resultitem, $resultitemmeta, $resultitemamound, $ingedienttype, $ingredientmeta, $ingredientname, $inventoryType = ""){ + $ingredientamount = 0; + $height = 0; + // count how many of the ingredient are in the recipe and check height for big or small recipe. + foreach ($recipeshape as $line){ + $height += 1; + $width = strlen($line); + $ingredientamount += substr_count($line, $ingredientname); + } + $recipe = null; + if ($height < 3){ + // Process small recipe + $fullClassName = "pocketmine\\inventory\\".$inventoryType."ShapedRecipe";// $ShapeClass."ShapedRecipe"; + $recipe = ((new $fullClassName(Item::get($resultitem, $resultitemmeta, $resultitemamound), + ...$recipeshape + ))->setIngredient($ingredientname, Item::get($ingedienttype, $ingredientmeta, $ingredientamount))); + } + else{ + // Process big recipe + $fullClassName = "pocketmine\\inventory\\".$inventoryType."BigShapedRecipe"; + $recipe = ((new $fullClassName(Item::get($resultitem, $resultitemmeta, $resultitemamound), + ...$recipeshape + ))->setIngredient($ingredientname, Item::get($ingedienttype, $ingredientmeta, $ingredientamount))); + } + return $recipe; } protected function registerFood(){ diff --git a/src/pocketmine/inventory/StonecutterShapelessRecipe.php b/src/pocketmine/inventory/StonecutterBigShapedRecipe.php similarity index 92% rename from src/pocketmine/inventory/StonecutterShapelessRecipe.php rename to src/pocketmine/inventory/StonecutterBigShapedRecipe.php index e29e34c86..a1cb800a3 100644 --- a/src/pocketmine/inventory/StonecutterShapelessRecipe.php +++ b/src/pocketmine/inventory/StonecutterBigShapedRecipe.php @@ -21,6 +21,6 @@ namespace pocketmine\inventory; -class StonecutterShapelessRecipe extends ShapelessRecipe{ +class StonecutterBigShapedRecipe extends ShapedRecipe{ } \ No newline at end of file diff --git a/src/pocketmine/inventory/StonecutterShapedRecipe.php b/src/pocketmine/inventory/StonecutterShapedRecipe.php new file mode 100644 index 000000000..6fd1d7c61 --- /dev/null +++ b/src/pocketmine/inventory/StonecutterShapedRecipe.php @@ -0,0 +1,26 @@ + Date: Tue, 29 Sep 2015 00:45:57 +0200 Subject: [PATCH 05/36] Crafting recipes, and packet fix --- src/pocketmine/inventory/CraftingManager.php | 289 +++++++++++++++--- .../network/protocol/CraftingDataPacket.php | 4 +- 2 files changed, 244 insertions(+), 49 deletions(-) diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index cdefd883e..66e8234b5 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -117,56 +117,251 @@ class CraftingManager{ "XX" ))->setIngredient("X", Item::get(Item::STRING, 0, 4))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::TORCH, 0, 4)))->addIngredient(Item::get(Item::COAL, 0, 1))->addIngredient(Item::get(Item::STICK, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::TORCH, 0, 4)))->addIngredient(Item::get(Item::COAL, 1, 1))->addIngredient(Item::get(Item::STICK, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::SUGAR, 0, 1)))->addIngredient(Item::get(Item::SUGARCANE, 0, 1))); + $this->registerRecipe((new ShapedRecipe(Item::get(Item::TORCH, 0, 4), + "C ", + "S" + ))->setIngredient("C", Item::get(Item::COAL,0,1))->setIngredient("S", Item::get(Item::STICK,0,1))); + $this->registerRecipe((new ShapedRecipe(Item::get(Item::TORCH, 0, 4), + "C ", + "S" + ))->setIngredient("C", Item::get(Item::COAL, 1, 1))->setIngredient("S", Item::get(Item::STICK, 0, 1))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BED, 0, 1)))->addIngredient(Item::get(Item::WOOL, null, 3))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::CHEST, 0, 1)))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 8))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::OAK, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::OAK, 4))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::SPRUCE, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::BIRCH, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::JUNGLE, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::ACACIA, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE, Planks::DARK_OAK, 3)))->addIngredient(Item::get(Item::STICK, 0, 2))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_GATE, 0, 1)))->addIngredient(Item::get(Item::STICK, 0, 4))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::OAK, 2))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_GATE_SPRUCE, 0, 1)))->addIngredient(Item::get(Item::STICK, 0, 4))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 2))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_GATE_BIRCH, 0, 1)))->addIngredient(Item::get(Item::STICK, 0, 4))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 2))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_GATE_JUNGLE, 0, 1)))->addIngredient(Item::get(Item::STICK, 0, 4))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 2))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_GATE_DARK_OAK, 0, 1)))->addIngredient(Item::get(Item::STICK, 0, 4))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 2))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FENCE_GATE_ACACIA, 0, 1)))->addIngredient(Item::get(Item::STICK, 0, 4))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 2))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::FURNACE, 0, 1)))->addIngredient(Item::get(Item::COBBLESTONE, 0, 8))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::GLASS_PANE, 0, 16)))->addIngredient(Item::get(Item::GLASS, 0, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::LADDER, 0, 2)))->addIngredient(Item::get(Item::STICK, 0, 7))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::NETHER_REACTOR, 0, 1)))->addIngredient(Item::get(Item::DIAMOND, 0, 3))->addIngredient(Item::get(Item::IRON_INGOT, 0, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::TRAPDOOR, 0, 2)))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOODEN_DOOR, 0, 1)))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOODEN_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::OAK, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::OAK, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::OAK, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::SPRUCE_WOOD_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::SPRUCE, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BIRCH_WOOD_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::BIRCH, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::JUNGLE_WOOD_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::JUNGLE, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::ACACIA_WOOD_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::ACACIA, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::DARK_OAK_WOOD_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 6))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::DARK_OAK, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 3))); + $this->registerRecipe((new ShapedRecipe(Item::get(Item::SUGAR, 0, 1), + "S" + ))->setIngredient("S", Item::get(Item::SUGARCANE, 0, 1))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BUCKET, 0, 1)))->addIngredient(Item::get(Item::IRON_INGOT, 0, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::CLOCK, 0, 1)))->addIngredient(Item::get(Item::GOLD_INGOT, 0, 4))->addIngredient(Item::get(Item::REDSTONE_DUST, 0, 1))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::COMPASS, 0, 1)))->addIngredient(Item::get(Item::IRON_INGOT, 0, 4))->addIngredient(Item::get(Item::REDSTONE_DUST, 0, 1))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::TNT, 0, 1)))->addIngredient(Item::get(Item::GUNPOWDER, 0, 5))->addIngredient(Item::get(Item::SAND, null, 4))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BOWL, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANKS, null, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::MINECART, 0, 1)))->addIngredient(Item::get(Item::IRON_INGOT, 0, 5))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BOOK, 0, 1)))->addIngredient(Item::get(Item::PAPER, 0, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BOOKSHELF, 0, 1)))->addIngredient(Item::get(Item::WOODEN_PLANK, null, 6))->addIngredient(Item::get(Item::BOOK, 0, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::PAINTING, 0, 1)))->addIngredient(Item::get(Item::STICK, 0, 8))->addIngredient(Item::get(Item::WOOL, null, 1))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::PAPER, 0, 1)))->addIngredient(Item::get(Item::SUGARCANE, 0, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::SIGN, 0, 3)))->addIngredient(Item::get(Item::STICK, 0, 1))->addIngredient(Item::get(Item::WOODEN_PLANKS, null, 6))); //TODO: check if it gives one sign or three - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::IRON_BARS, 0, 16)))->addIngredient(Item::get(Item::IRON_INGOT, 0, 6))); + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BED, 0, 1), + "WWW", + "PPP" + ))->setIngredient("W", Item::get(Item::WOOL, null, 3))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::CHEST, 0, 1), + "PPP", + "P P", + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 8))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, 0, 3), + "PSP", + "PSP" + ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 4))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::SPRUCE, 3), + "PSP", + "PSP" + ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::BIRCH, 3), + "PSP", + "PSP" + ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::JUNGLE, 3), + "PSP", + "PSP" + ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::ACACIA, 3), + "PSP", + "PSP" + ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::DARK_OAK, 3), + "PSP", + "PSP" + ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE, 0, 1), + "SPS", + "SPS" + ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 2))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_SPRUCE, 0, 1), + "SPS", + "SPS" + ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 2))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_BIRCH, 0, 1), + "SPS", + "SPS" + ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 2))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_JUNGLE, 0, 1), + "SPS", + "SPS" + ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 2))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_DARK_OAK, 0, 1), + "SPS", + "SPS" + ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 2))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_ACACIA, 0, 1), + "SPS", + "SPS" + ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 2))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FURNACE, 0, 1), + "CCC", + "C C", + "CCC" + ))->setIngredient("C", Item::get(Item::COBBLESTONE, 0, 8))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::GLASS_PANE, 0, 16), + "GGG", + "GGG" + ))->setIngredient("G", Item::get(Item::GLASS, 0, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::LADDER, 0, 2), + "S S", + "SSS", + "S S" + ))->setIngredient("S", Item::get(Item::STICK, 0, 7))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::NETHER_REACTOR, 0, 1), + "IDI", + "IDI", + "IDI" + ))->setIngredient("D", Item::get(Item::DIAMOND, 0, 3))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::TRAPDOOR, 0, 2), + "PPP", + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_DOOR, 0, 1), + "PP", + "PP", + "PP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_STAIRS, 0, 4), + " P", + " PP", + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::OAK, 6), + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SPRUCE_WOOD_STAIRS, 0, 4), + " P", + " PP", + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::SPRUCE, 6), + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BIRCH_WOOD_STAIRS, 0, 4), + " P", + " PP", + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::BIRCH, 6), + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::JUNGLE_WOOD_STAIRS, 0, 4), + "P", + "PP", + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::JUNGLE, 6), + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::ACACIA_WOOD_STAIRS, 0, 4), + " P", + " PP", + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::ACACIA, 6), + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::DARK_OAK_WOOD_STAIRS, 0, 4), + " P", + " PP", + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 6))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::DARK_OAK, 6), + "PPP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BUCKET, 0, 1), + "I I", + " I" + ))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::CLOCK, 0, 1), + " G", + "GR", + " G" + ))->setIngredient("G", Item::get(Item::GOLD_INGOT, 0, 4))->setIngredient("R", Item::get(Item::REDSTONE_DUST, 0, 1))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::COMPASS, 0, 1), + " I ", + "IRI", + " I" + ))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 4))->setIngredient("R", Item::get(Item::REDSTONE_DUST, 0, 1))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::TNT, 0, 1), + "GSG", + "SGS", + "GSG" + ))->setIngredient("G", Item::get(Item::GUNPOWDER, 0, 5))->setIngredient("S", Item::get(Item::SAND, null, 4))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOWL, 0, 4), + "P P", + " P" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANKS, null, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::MINECART, 0, 1), + "I I", + "III" + ))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 5))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOOK, 0, 1), + "P P", + " P " + ))->setIngredient("P", Item::get(Item::PAPER, 0, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOOKSHELF, 0, 1), + "PBP", + "PBP", + "PBP" + ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6))->setIngredient("B", Item::get(Item::BOOK, 0, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::PAINTING, 0, 1), + "SSS", + "SWS", + "SSS" + ))->setIngredient("S", Item::get(Item::STICK, 0, 8))->setIngredient("W", Item::get(Item::WOOL, null, 1))); + + $this->registerRecipe((new ShapedRecipe(Item::get(Item::PAPER, 0, 3), + "SS", + "S" + ))->setIngredient("S", Item::get(Item::SUGARCANE, 0, 3))); + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SIGN, 0, 3), + "PPP", + "PPP", + " S" + ))->setIngredient("S", Item::get(Item::STICK, 0, 1))->setIngredient("P", Item::get(Item::WOODEN_PLANKS, null, 6))); //TODO: check if it gives one sign or three + + $this->registerRecipe((new BigShapedRecipe(Item::get(Item::IRON_BARS, 0, 16), + "III", + "III", + "III" + ))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 9))); } protected function registerFurnace(){ diff --git a/src/pocketmine/network/protocol/CraftingDataPacket.php b/src/pocketmine/network/protocol/CraftingDataPacket.php index 71dfa577c..e43f766e9 100644 --- a/src/pocketmine/network/protocol/CraftingDataPacket.php +++ b/src/pocketmine/network/protocol/CraftingDataPacket.php @@ -76,8 +76,8 @@ class CraftingDataPacket extends DataPacket{ $stream->putInt($recipe->getWidth()); $stream->putInt($recipe->getHeight()); - for($z = 0; $z < $recipe->getWidth(); ++$z){ - for($x = 0; $x < $recipe->getHeight(); ++$x){ + for($z = 0; $z < $recipe->getHeight(); ++$z){ + for($x = 0; $x < $recipe->getWidth(); ++$x){ $stream->putSlot($recipe->getIngredient($x, $z)); } } From 34df516d94040461e2d0973aae4b48e37f90ca57 Mon Sep 17 00:00:00 2001 From: Intyre Date: Wed, 30 Sep 2015 18:09:09 +0200 Subject: [PATCH 06/36] new branch to fix all issues with items and blocks --- TODO.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 000000000..1d96bb645 --- /dev/null +++ b/TODO.md @@ -0,0 +1,6 @@ +# TODO + +This branch will get used to to fix all issues with items and blocks. +Working from branch mcpe-0.12 tested with MCPE 0.12.1 + +- [ ] add things here From 6013213159e140e5b93a40d33e424559d82c404a Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Thu, 1 Oct 2015 08:23:05 +0200 Subject: [PATCH 07/36] More items --- src/pocketmine/item/Arrow.php | 30 +++++++++++++++++++++ src/pocketmine/item/BakedPotato.php | 30 +++++++++++++++++++++ src/pocketmine/item/Beetroot.php | 30 +++++++++++++++++++++ src/pocketmine/item/Bone.php | 30 +++++++++++++++++++++ src/pocketmine/item/Book.php | 30 +++++++++++++++++++++ src/pocketmine/item/Bread.php | 30 +++++++++++++++++++++ src/pocketmine/item/Camera.php | 30 +++++++++++++++++++++ src/pocketmine/item/Clay.php | 30 +++++++++++++++++++++ src/pocketmine/item/Clock.php | 30 +++++++++++++++++++++ src/pocketmine/item/Compass.php | 30 +++++++++++++++++++++ src/pocketmine/item/CookedChicken.php | 30 +++++++++++++++++++++ src/pocketmine/item/CookedPorkchop.php | 30 +++++++++++++++++++++ src/pocketmine/item/Cookie.php | 30 +++++++++++++++++++++ src/pocketmine/item/Dye.php | 30 +++++++++++++++++++++ src/pocketmine/item/Egg.php | 30 +++++++++++++++++++++ src/pocketmine/item/Emerald.php | 30 +++++++++++++++++++++ src/pocketmine/item/Flint.php | 30 +++++++++++++++++++++ src/pocketmine/item/GlowstoneDust.php | 30 +++++++++++++++++++++ src/pocketmine/item/GoldNugget.php | 30 +++++++++++++++++++++ src/pocketmine/item/GoldenApple.php | 30 +++++++++++++++++++++ src/pocketmine/item/Gunpowder.php | 30 +++++++++++++++++++++ src/pocketmine/item/Item.php | 37 ++++++++++++++++++++++++++ src/pocketmine/item/Leather.php | 30 +++++++++++++++++++++ src/pocketmine/item/Melon.php | 30 +++++++++++++++++++++ src/pocketmine/item/Minecart.php | 30 +++++++++++++++++++++ src/pocketmine/item/NetherBrick.php | 30 +++++++++++++++++++++ src/pocketmine/item/Paper.php | 30 +++++++++++++++++++++ src/pocketmine/item/PumpkinPie.php | 30 +++++++++++++++++++++ src/pocketmine/item/Quartz.php | 30 +++++++++++++++++++++ src/pocketmine/item/RawBeef.php | 30 +++++++++++++++++++++ src/pocketmine/item/RawChicken.php | 30 +++++++++++++++++++++ src/pocketmine/item/RawPorkchop.php | 30 +++++++++++++++++++++ src/pocketmine/item/Redstone.php | 30 +++++++++++++++++++++ src/pocketmine/item/Slimeball.php | 30 +++++++++++++++++++++ src/pocketmine/item/Steak.php | 30 +++++++++++++++++++++ src/pocketmine/item/String.php | 30 +++++++++++++++++++++ src/pocketmine/item/Sugar.php | 30 +++++++++++++++++++++ src/pocketmine/item/Wheat.php | 30 +++++++++++++++++++++ 38 files changed, 1147 insertions(+) create mode 100644 src/pocketmine/item/Arrow.php create mode 100644 src/pocketmine/item/BakedPotato.php create mode 100644 src/pocketmine/item/Beetroot.php create mode 100644 src/pocketmine/item/Bone.php create mode 100644 src/pocketmine/item/Book.php create mode 100644 src/pocketmine/item/Bread.php create mode 100644 src/pocketmine/item/Camera.php create mode 100644 src/pocketmine/item/Clay.php create mode 100644 src/pocketmine/item/Clock.php create mode 100644 src/pocketmine/item/Compass.php create mode 100644 src/pocketmine/item/CookedChicken.php create mode 100644 src/pocketmine/item/CookedPorkchop.php create mode 100644 src/pocketmine/item/Cookie.php create mode 100644 src/pocketmine/item/Dye.php create mode 100644 src/pocketmine/item/Egg.php create mode 100644 src/pocketmine/item/Emerald.php create mode 100644 src/pocketmine/item/Flint.php create mode 100644 src/pocketmine/item/GlowstoneDust.php create mode 100644 src/pocketmine/item/GoldNugget.php create mode 100644 src/pocketmine/item/GoldenApple.php create mode 100644 src/pocketmine/item/Gunpowder.php create mode 100644 src/pocketmine/item/Leather.php create mode 100644 src/pocketmine/item/Melon.php create mode 100644 src/pocketmine/item/Minecart.php create mode 100644 src/pocketmine/item/NetherBrick.php create mode 100644 src/pocketmine/item/Paper.php create mode 100644 src/pocketmine/item/PumpkinPie.php create mode 100644 src/pocketmine/item/Quartz.php create mode 100644 src/pocketmine/item/RawBeef.php create mode 100644 src/pocketmine/item/RawChicken.php create mode 100644 src/pocketmine/item/RawPorkchop.php create mode 100644 src/pocketmine/item/Redstone.php create mode 100644 src/pocketmine/item/Slimeball.php create mode 100644 src/pocketmine/item/Steak.php create mode 100644 src/pocketmine/item/String.php create mode 100644 src/pocketmine/item/Sugar.php create mode 100644 src/pocketmine/item/Wheat.php diff --git a/src/pocketmine/item/Arrow.php b/src/pocketmine/item/Arrow.php new file mode 100644 index 000000000..d92b56272 --- /dev/null +++ b/src/pocketmine/item/Arrow.php @@ -0,0 +1,30 @@ + Date: Fri, 2 Oct 2015 01:52:10 +0800 Subject: [PATCH 08/36] Fixed string class conflict --- src/pocketmine/item/Item.php | 20 +++++++++---------- .../item/{String.php => StringItem.php} | 12 +++++------ 2 files changed, 16 insertions(+), 16 deletions(-) rename src/pocketmine/item/{String.php => StringItem.php} (92%) diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 46a4f04c7..2f4ec9719 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -2,11 +2,11 @@ /* * - * ____ _ _ __ __ _ __ __ ____ - * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ + * ____ _ _ __ __ _ __ __ ____ + * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | - * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ - * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| + * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ + * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -540,7 +540,7 @@ class Item{ self::$list[self::RAW_FISH] = Fish::class; self::$list[self::COOKED_FISH] = CookedFish::class; self::$list[self::ARROW] = Arrow::class; - self::$list[self::STRING] = String::class; + self::$list[self::STRING] = StringItem::class; self::$list[self::GUNPOWDER] = Gunpowder::class; self::$list[self::WHEAT] = Wheat::class; self::$list[self::BREAD] = Bread::class; @@ -583,7 +583,7 @@ class Item{ } } } - + self::initCreativeItems(); } @@ -992,7 +992,7 @@ class Item{ $this->name = $this->block->getName(); } } - + public function setCompoundTag($tags){ if($tags instanceof Compound){ $this->setNamedTag($tags); @@ -1000,7 +1000,7 @@ class Item{ $this->tags = $tags; $this->cachedNBT = null; } - + return $this; } @@ -1010,7 +1010,7 @@ class Item{ public function getCompoundTag(){ return $this->tags; } - + public function hasCompoundTag(){ return $this->tags !== "" and $this->tags !== null; } @@ -1244,7 +1244,7 @@ class Item{ return null; } - + public function getNamedTag(){ if(!$this->hasCompoundTag()){ return null; diff --git a/src/pocketmine/item/String.php b/src/pocketmine/item/StringItem.php similarity index 92% rename from src/pocketmine/item/String.php rename to src/pocketmine/item/StringItem.php index 19158ad1a..f6682ec3b 100644 --- a/src/pocketmine/item/String.php +++ b/src/pocketmine/item/StringItem.php @@ -2,11 +2,11 @@ /* * - * ____ _ _ __ __ _ __ __ ____ - * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ + * ____ _ _ __ __ _ __ __ ____ + * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | - * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ - * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| + * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ + * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -15,13 +15,13 @@ * * @author PocketMine Team * @link http://www.pocketmine.net/ - * + * * */ namespace pocketmine\item; -class String extends Item{ +class StringItem extends Item{ public function __construct($meta = 0, $count = 1){ parent::__construct(self::STRING, $meta, $count, "String"); } From 19b2e1b4af5c2de121cbec0c16ad382a5ee6fc95 Mon Sep 17 00:00:00 2001 From: Intyre Date: Thu, 1 Oct 2015 20:05:31 +0200 Subject: [PATCH 09/36] sorted items in init() --- src/pocketmine/item/Item.php | 127 +++++++++++++++++------------------ 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index 2f4ec9719..db827f04f 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -460,32 +460,48 @@ class Item{ public static function init(){ if(self::$list === null){ self::$list = new \SplFixedArray(65536); - self::$list[self::SUGARCANE] = Sugarcane::class; - self::$list[self::WHEAT_SEEDS] = WheatSeeds::class; - self::$list[self::PUMPKIN_SEEDS] = PumpkinSeeds::class; - self::$list[self::MELON_SEEDS] = MelonSeeds::class; - self::$list[self::MUSHROOM_STEW] = MushroomStew::class; - self::$list[self::BEETROOT_SOUP] = BeetrootSoup::class; - self::$list[self::CARROT] = Carrot::class; - self::$list[self::POTATO] = Potato::class; - self::$list[self::BEETROOT_SEEDS] = BeetrootSeeds::class; - self::$list[self::SIGN] = Sign::class; - self::$list[self::WOODEN_DOOR] = WoodenDoor::class; - self::$list[self::BUCKET] = Bucket::class; - self::$list[self::IRON_DOOR] = IronDoor::class; - self::$list[self::CAKE] = Cake::class; - self::$list[self::BED] = Bed::class; - self::$list[self::PAINTING] = Painting::class; - self::$list[self::COAL] = Coal::class; + self::$list[self::IRON_SHOVEL] = IronShovel::class; + self::$list[self::IRON_PICKAXE] = IronPickaxe::class; + self::$list[self::IRON_AXE] = IronAxe::class; + self::$list[self::FLINT_STEEL] = FlintSteel::class; self::$list[self::APPLE] = Apple::class; - self::$list[self::SPAWN_EGG] = SpawnEgg::class; + self::$list[self::BOW] = Bow::class; + self::$list[self::ARROW] = Arrow::class; + self::$list[self::COAL] = Coal::class; self::$list[self::DIAMOND] = Diamond::class; + self::$list[self::IRON_INGOT] = IronIngot::class; + self::$list[self::GOLD_INGOT] = GoldIngot::class; + self::$list[self::IRON_SWORD] = IronSword::class; + self::$list[self::WOODEN_SWORD] = WoodenSword::class; + self::$list[self::WOODEN_SHOVEL] = WoodenShovel::class; + self::$list[self::WOODEN_PICKAXE] = WoodenPickaxe::class; + self::$list[self::WOODEN_AXE] = WoodenAxe::class; + self::$list[self::STONE_SWORD] = StoneSword::class; + self::$list[self::STONE_SHOVEL] = StoneShovel::class; + self::$list[self::STONE_PICKAXE] = StonePickaxe::class; + self::$list[self::STONE_AXE] = StoneAxe::class; + self::$list[self::DIAMOND_SWORD] = DiamondSword::class; + self::$list[self::DIAMOND_SHOVEL] = DiamondShovel::class; + self::$list[self::DIAMOND_PICKAXE] = DiamondPickaxe::class; + self::$list[self::DIAMOND_AXE] = DiamondAxe::class; self::$list[self::STICK] = Stick::class; - self::$list[self::SNOWBALL] = Snowball::class; self::$list[self::BOWL] = Bowl::class; + self::$list[self::MUSHROOM_STEW] = MushroomStew::class; + self::$list[self::GOLD_SWORD] = GoldSword::class; + self::$list[self::GOLD_SHOVEL] = GoldShovel::class; + self::$list[self::GOLD_PICKAXE] = GoldPickaxe::class; + self::$list[self::GOLD_AXE] = GoldAxe::class; + self::$list[self::STRING] = StringItem::class; self::$list[self::FEATHER] = Feather::class; - self::$list[self::BRICK] = Brick::class; - self::$list[self::QUARTZ] = NetherQuartz::class; + self::$list[self::GUNPOWDER] = Gunpowder::class; + self::$list[self::WOODEN_HOE] = WoodenHoe::class; + self::$list[self::STONE_HOE] = StoneHoe::class; + self::$list[self::IRON_HOE] = IronHoe::class; + self::$list[self::DIAMOND_HOE] = DiamondHoe::class; + self::$list[self::GOLD_HOE] = GoldHoe::class; + self::$list[self::WHEAT_SEEDS] = WheatSeeds::class; + self::$list[self::WHEAT] = Wheat::class; + self::$list[self::BREAD] = Bread::class; self::$list[self::LEATHER_CAP] = LeatherCap::class; self::$list[self::LEATHER_TUNIC] = LeatherTunic::class; self::$list[self::LEATHER_PANTS] = LeatherPants::class; @@ -498,60 +514,30 @@ class Item{ self::$list[self::IRON_CHESTPLATE] = IronChestplate::class; self::$list[self::IRON_LEGGINGS] = IronLeggings::class; self::$list[self::IRON_BOOTS] = IronBoots::class; - self::$list[self::GOLD_HELMET] = GoldHelmet::class; - self::$list[self::GOLD_CHESTPLATE] = GoldChestplate::class; - self::$list[self::GOLD_LEGGINGS] = GoldLeggings::class; - self::$list[self::GOLD_BOOTS] = GoldBoots::class; self::$list[self::DIAMOND_HELMET] = DiamondHelmet::class; self::$list[self::DIAMOND_CHESTPLATE] = DiamondChestplate::class; self::$list[self::DIAMOND_LEGGINGS] = DiamondLeggings::class; self::$list[self::DIAMOND_BOOTS] = DiamondBoots::class; - self::$list[self::IRON_SWORD] = IronSword::class; - self::$list[self::IRON_INGOT] = IronIngot::class; - self::$list[self::GOLD_INGOT] = GoldIngot::class; - self::$list[self::IRON_SHOVEL] = IronShovel::class; - self::$list[self::IRON_PICKAXE] = IronPickaxe::class; - self::$list[self::IRON_AXE] = IronAxe::class; - self::$list[self::IRON_HOE] = IronHoe::class; - self::$list[self::DIAMOND_SWORD] = DiamondSword::class; - self::$list[self::DIAMOND_SHOVEL] = DiamondShovel::class; - self::$list[self::DIAMOND_PICKAXE] = DiamondPickaxe::class; - self::$list[self::DIAMOND_AXE] = DiamondAxe::class; - self::$list[self::DIAMOND_HOE] = DiamondHoe::class; - self::$list[self::GOLD_SWORD] = GoldSword::class; - self::$list[self::GOLD_SHOVEL] = GoldShovel::class; - self::$list[self::GOLD_PICKAXE] = GoldPickaxe::class; - self::$list[self::GOLD_AXE] = GoldAxe::class; - self::$list[self::GOLD_HOE] = GoldHoe::class; - self::$list[self::STONE_SWORD] = StoneSword::class; - self::$list[self::STONE_SHOVEL] = StoneShovel::class; - self::$list[self::STONE_PICKAXE] = StonePickaxe::class; - self::$list[self::STONE_AXE] = StoneAxe::class; - self::$list[self::STONE_HOE] = StoneHoe::class; - self::$list[self::WOODEN_SWORD] = WoodenSword::class; - self::$list[self::WOODEN_SHOVEL] = WoodenShovel::class; - self::$list[self::WOODEN_PICKAXE] = WoodenPickaxe::class; - self::$list[self::WOODEN_AXE] = WoodenAxe::class; - self::$list[self::WOODEN_HOE] = WoodenHoe::class; - self::$list[self::FLINT_STEEL] = FlintSteel::class; - self::$list[self::SHEARS] = Shears::class; - self::$list[self::BOW] = Bow::class; - - self::$list[self::RAW_FISH] = Fish::class; - self::$list[self::COOKED_FISH] = CookedFish::class; - self::$list[self::ARROW] = Arrow::class; - self::$list[self::STRING] = StringItem::class; - self::$list[self::GUNPOWDER] = Gunpowder::class; - self::$list[self::WHEAT] = Wheat::class; - self::$list[self::BREAD] = Bread::class; + self::$list[self::GOLD_HELMET] = GoldHelmet::class; + self::$list[self::GOLD_CHESTPLATE] = GoldChestplate::class; + self::$list[self::GOLD_LEGGINGS] = GoldLeggings::class; + self::$list[self::GOLD_BOOTS] = GoldBoots::class; self::$list[self::FLINT] = Flint::class; self::$list[self::RAW_PORKCHOP] = RawPorkchop::class; self::$list[self::COOKED_PORKCHOP] = CookedPorkchop::class; + self::$list[self::PAINTING] = Painting::class; self::$list[self::GOLDEN_APPLE] = GoldenApple::class; + self::$list[self::SIGN] = Sign::class; + self::$list[self::WOODEN_DOOR] = WoodenDoor::class; + self::$list[self::BUCKET] = Bucket::class; self::$list[self::MINECART] = Minecart::class; + self::$list[self::IRON_DOOR] = IronDoor::class; self::$list[self::REDSTONE] = Redstone::class; + self::$list[self::SNOWBALL] = Snowball::class; self::$list[self::LEATHER] = Leather::class; + self::$list[self::BRICK] = Brick::class; self::$list[self::CLAY] = Clay::class; + self::$list[self::SUGARCANE] = Sugarcane::class; self::$list[self::PAPER] = Paper::class; self::$list[self::BOOK] = Book::class; self::$list[self::SLIMEBALL] = Slimeball::class; @@ -559,23 +545,36 @@ class Item{ self::$list[self::COMPASS] = Compass::class; self::$list[self::CLOCK] = Clock::class; self::$list[self::GLOWSTONE_DUST] = GlowstoneDust::class; + self::$list[self::RAW_FISH] = Fish::class; + self::$list[self::COOKED_FISH] = CookedFish::class; self::$list[self::DYE] = Dye::class; self::$list[self::BONE] = Bone::class; self::$list[self::SUGAR] = Sugar::class; + self::$list[self::CAKE] = Cake::class; + self::$list[self::BED] = Bed::class; self::$list[self::COOKIE] = Cookie::class; + self::$list[self::SHEARS] = Shears::class; self::$list[self::MELON] = Melon::class; + self::$list[self::PUMPKIN_SEEDS] = PumpkinSeeds::class; + self::$list[self::MELON_SEEDS] = MelonSeeds::class; self::$list[self::RAW_BEEF] = RawBeef::class; self::$list[self::STEAK] = Steak::class; self::$list[self::RAW_CHICKEN] = RawChicken::class; self::$list[self::COOKED_CHICKEN] = CookedChicken::class; self::$list[self::GOLD_NUGGET] = GoldNugget::class; + self::$list[self::SPAWN_EGG] = SpawnEgg::class; self::$list[self::EMERALD] = Emerald::class; + self::$list[self::CARROT] = Carrot::class; + self::$list[self::POTATO] = Potato::class; self::$list[self::BAKED_POTATO] = BakedPotato::class; self::$list[self::PUMPKIN_PIE] = PumpkinPie::class; self::$list[self::NETHER_BRICK] = NetherBrick::class; self::$list[self::QUARTZ] = Quartz::class; - self::$list[self::CAMERA] = Camera::class; + self::$list[self::QUARTZ] = NetherQuartz::class; + // self::$list[self::CAMERA] = Camera::class; self::$list[self::BEETROOT] = Beetroot::class; + self::$list[self::BEETROOT_SEEDS] = BeetrootSeeds::class; + self::$list[self::BEETROOT_SOUP] = BeetrootSoup::class; for($i = 0; $i < 256; ++$i){ if(Block::$list[$i] !== null){ From 84be56fefb21863b28fd922b6b56eed07c5b56ed Mon Sep 17 00:00:00 2001 From: Intyre Date: Fri, 2 Oct 2015 00:49:56 +0200 Subject: [PATCH 10/36] edited TODO.md --- TODO.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 1d96bb645..156f0fdf4 100644 --- a/TODO.md +++ b/TODO.md @@ -3,4 +3,19 @@ This branch will get used to to fix all issues with items and blocks. Working from branch mcpe-0.12 tested with MCPE 0.12.1 -- [ ] add things here +## src/pocketmine/item/Item.php + +- [x] add missing items + - [x] sort all items in ``public static function init(){}`` + - sort using ID + - [x] create list of missing items +- [ ] create seperate functions for views (maybe?) + - [ ] sort everything in ``private static function initCreativeItems(){}`` + - the way it looks ingame using **MCPE 0.12.1** + +## src/pocketmine/block/Block.php + +- [ ] add missing blocks + - [ ] sort all blocks in init() + - sort using ID + - [ ] create a list of missing blocks From 4e59d85cca883a3e3533665bec7ab6588c02a9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=81=E5=A4=9C=E6=9A=97=E8=8A=92=E4=BD=BF?= <1323471525@qq.com> Date: Wed, 7 Oct 2015 17:04:27 +0800 Subject: [PATCH 11/36] Fixed recursive call --- src/pocketmine/inventory/BaseInventory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index 4a749b3c3..2e1d73ded 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -378,7 +378,7 @@ abstract class BaseInventory implements Inventory{ } public function setMaxStackSize($size){ - $this->setMaxStackSize($size); + $this->maxStackSize = (int) $size; } public function open(Player $who){ From c4fb469b4e5d3ba711b749ba2f655556712c8787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=81=E5=A4=9C=E6=9A=97=E8=8A=92=E4=BD=BF?= <1323471525@qq.com> Date: Wed, 7 Oct 2015 17:04:27 +0800 Subject: [PATCH 12/36] Fixed recursive call --- src/pocketmine/inventory/BaseInventory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index 12cd43882..dee23dd9c 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -385,7 +385,7 @@ abstract class BaseInventory implements Inventory{ } public function setMaxStackSize($size){ - $this->setMaxStackSize($size); + $this->maxStackSize = (int) $size; } public function open(Player $who){ From 813acc54dc3243f495e120ac6999275394ec2c54 Mon Sep 17 00:00:00 2001 From: Intyre Date: Sat, 10 Oct 2015 23:06:28 +0200 Subject: [PATCH 13/36] Fixed translation for banlist command usage --- TODO.md | 21 ------------------- .../command/defaults/BanListCommand.php | 4 ++-- 2 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 TODO.md diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 156f0fdf4..000000000 --- a/TODO.md +++ /dev/null @@ -1,21 +0,0 @@ -# TODO - -This branch will get used to to fix all issues with items and blocks. -Working from branch mcpe-0.12 tested with MCPE 0.12.1 - -## src/pocketmine/item/Item.php - -- [x] add missing items - - [x] sort all items in ``public static function init(){}`` - - sort using ID - - [x] create list of missing items -- [ ] create seperate functions for views (maybe?) - - [ ] sort everything in ``private static function initCreativeItems(){}`` - - the way it looks ingame using **MCPE 0.12.1** - -## src/pocketmine/block/Block.php - -- [ ] add missing blocks - - [ ] sort all blocks in init() - - sort using ID - - [ ] create a list of missing blocks diff --git a/src/pocketmine/command/defaults/BanListCommand.php b/src/pocketmine/command/defaults/BanListCommand.php index 251a096d3..6fe8ba7b5 100644 --- a/src/pocketmine/command/defaults/BanListCommand.php +++ b/src/pocketmine/command/defaults/BanListCommand.php @@ -64,9 +64,9 @@ class BanListCommand extends VanillaCommand{ } if($args[0] === "ips"){ - $sender->sendMessage("commands.banlist.ips", [count($list)]); + $sender->sendMessage(new TranslationContainer("commands.banlist.ips", [count($list)])); }else{ - $sender->sendMessage("commands.banlist.players", [count($list)]); + $sender->sendMessage(new TranslationContainer("commands.banlist.players", [count($list)])); } $sender->sendMessage(substr($message, 0, -2)); From 09b4d4dc7a61270c5a1e6a035b0462a8e2fa02d7 Mon Sep 17 00:00:00 2001 From: Intyre Date: Sat, 10 Oct 2015 23:10:24 +0200 Subject: [PATCH 14/36] Fixes for derps found with PHPStorm code inspector --- src/pocketmine/Player.php | 14 +++++--------- src/pocketmine/Server.php | 2 +- src/pocketmine/entity/Effect.php | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 434df2db9..4dbc5a679 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -69,7 +69,6 @@ use pocketmine\event\TranslationContainer; use pocketmine\inventory\BaseTransaction; use pocketmine\inventory\BigShapedRecipe; use pocketmine\inventory\BigShapelessRecipe; -use pocketmine\inventory\CraftingTransactionGroup; use pocketmine\inventory\FurnaceInventory; use pocketmine\inventory\Inventory; use pocketmine\inventory\InventoryHolder; @@ -713,7 +712,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } unset($this->loadQueue[$index]); - $this->level->requestChunk($X, $Z, $this, LevelProvider::ORDER_ZXY); + $this->level->requestChunk($X, $Z, $this); } if($this->chunkLoadCount >= $this->spawnThreshold and $this->spawned === false and $this->teleportPosition === null){ @@ -2001,7 +2000,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade //TODO: Implement adventure mode checks if($this->level->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this)){ if(!$item->deepEquals($oldItem) or $item->getCount() !== $oldItem->getCount()){ - $this->inventory->setItemInHand($item, $this); + $this->inventory->setItemInHand($item); $this->inventory->sendHeldItem($this->hasSpawned); } break; @@ -2182,7 +2181,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new EntityEventPacket(); $pk->eid = $this->getId(); $pk->event = EntityEventPacket::USE_ITEM; - $pk; $this->dataPacket($pk); Server::broadcastPacket($this->getViewers(), $pk); @@ -2301,7 +2299,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if($this->canInteract($vector->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 6) and $this->level->useBreakOn($vector, $item, $this)){ if($this->isSurvival()){ if(!$item->deepEquals($oldItem) or $item->getCount() !== $oldItem->getCount()){ - $this->inventory->setItemInHand($item, $this); + $this->inventory->setItemInHand($item); $this->inventory->sendHeldItem($this->hasSpawned); } } @@ -2514,7 +2512,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new EntityEventPacket(); $pk->eid = $this->getId(); $pk->event = EntityEventPacket::USE_ITEM; - $pk; $this->dataPacket($pk); Server::broadcastPacket($this->getViewers(), $pk); @@ -2526,7 +2523,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->heal($ev->getAmount(), $ev); --$slot->count; - $this->inventory->setItemInHand($slot, $this); + $this->inventory->setItemInHand($slot); if($slot->getId() === Item::MUSHROOM_STEW or $slot->getId() === Item::BEETROOT_SOUP){ $this->inventory->addItem(Item::get(Item::BOWL, 0, 1)); }elseif($slot->getId() === Item::RAW_FISH and $slot->getDamage() === 3){ //Pufferfish @@ -2550,7 +2547,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade break; } - $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this); + $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1)); $motion = $this->getDirectionVector()->multiply(0.4); $this->level->dropItem($this->add(0, 1.3, 0), $item, $motion, 40); @@ -3568,7 +3565,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $batch = new BatchPacket(); $batch->payload = zlib_encode(Binary::writeInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel); - $batch; $batch->encode(); $batch->isEncoded = true; return $batch; diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 261219566..a41e1b039 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1852,7 +1852,7 @@ class Server{ $task = new CompressBatchedTask($str, $targets, $this->networkCompressionLevel, $channel); $this->getScheduler()->scheduleAsyncTask($task); }else{ - $this->broadcastPacketsCallback(zlib_encode($str, ZLIB_ENCODING_DEFLATE, $this->networkCompressionLevel), $targets, $channel); + $this->broadcastPacketsCallback(zlib_encode($str, ZLIB_ENCODING_DEFLATE, $this->networkCompressionLevel), $targets); } Timings::$playerNetworkTimer->stopTiming(); diff --git a/src/pocketmine/entity/Effect.php b/src/pocketmine/entity/Effect.php index b10dc0d30..30590bff3 100644 --- a/src/pocketmine/entity/Effect.php +++ b/src/pocketmine/entity/Effect.php @@ -48,7 +48,7 @@ class Effect{ const INVISIBILITY = 14; //const BLINDNESS = 15; //const NIGHT_VISION = 16; - //const HUNGER = 17; + const HUNGER = 17; const WEAKNESS = 18; const POISON = 19; const WITHER = 20; From 8ce02d86879a22fa164eea312c21695b67e63d8e Mon Sep 17 00:00:00 2001 From: Intyre Date: Sat, 10 Oct 2015 23:30:42 +0200 Subject: [PATCH 15/36] Hunger effect is not implemented --- src/pocketmine/Player.php | 4 ++-- src/pocketmine/entity/Effect.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 4dbc5a679..edd8a6214 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2527,8 +2527,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if($slot->getId() === Item::MUSHROOM_STEW or $slot->getId() === Item::BEETROOT_SOUP){ $this->inventory->addItem(Item::get(Item::BOWL, 0, 1)); }elseif($slot->getId() === Item::RAW_FISH and $slot->getDamage() === 3){ //Pufferfish - $this->addEffect(Effect::getEffect(Effect::HUNGER)->setAmplifier(2)->setDuration(15 * 20)); - //$this->addEffect(Effect::getEffect(Effect::NAUSEA)->setAmplifier(1)->setDuration(15 * 20)); + //$this->addEffect(Effect::getEffect(Effect::HUNGER)->setAmplifier(2)->setDuration(15 * 20)); + $this->addEffect(Effect::getEffect(Effect::NAUSEA)->setAmplifier(1)->setDuration(15 * 20)); $this->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(3)->setDuration(60 * 20)); } } diff --git a/src/pocketmine/entity/Effect.php b/src/pocketmine/entity/Effect.php index 30590bff3..b10dc0d30 100644 --- a/src/pocketmine/entity/Effect.php +++ b/src/pocketmine/entity/Effect.php @@ -48,7 +48,7 @@ class Effect{ const INVISIBILITY = 14; //const BLINDNESS = 15; //const NIGHT_VISION = 16; - const HUNGER = 17; + //const HUNGER = 17; const WEAKNESS = 18; const POISON = 19; const WITHER = 20; From 958c3589c95421693f9c852124bebe2340172422 Mon Sep 17 00:00:00 2001 From: Intyre Date: Sat, 10 Oct 2015 23:40:59 +0200 Subject: [PATCH 16/36] Fix for #3569 NetherBrickFence --- src/pocketmine/block/NetherBrickFence.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pocketmine/block/NetherBrickFence.php b/src/pocketmine/block/NetherBrickFence.php index 10fb148a8..b42cdbd7f 100644 --- a/src/pocketmine/block/NetherBrickFence.php +++ b/src/pocketmine/block/NetherBrickFence.php @@ -20,15 +20,15 @@ */ namespace pocketmine\block; -use pocketmine\block\Block; -use pocketmine\block\Fence; use pocketmine\item\Item; -//use pocketmine\item\Tool; +use pocketmine\item\Tool; class NetherBrickFence extends Transparent { - - public function __construct(){ - parent::__construct(self::NETHER_BRICK_FENCE); + + protected $id = self::NETHER_BRICK_FENCE; + + public function __construct($meta = 0){ + $this->meta = $meta; } public function getBreakTime(Item $item){ @@ -61,9 +61,9 @@ class NetherBrickFence extends Transparent { } public function getDrops(Item $item){ - if($item->isPickaxe()){ + if($item->isPickaxe() >= Tool::TYPE_WOODEN){ return [ - [Item::FENCE, Fence::FENCE_NETHER_BRICK, 1], + [Item::NETHER_BRICK_FENCE, $this->meta, 1], ]; }else{ return []; From 94b79ac28af63f3a5f94f9d32f2cd70404b75ed9 Mon Sep 17 00:00:00 2001 From: Intyre Date: Sun, 11 Oct 2015 00:52:44 +0200 Subject: [PATCH 17/36] Tool tier added to getDrops --- src/pocketmine/block/Anvil.php | 2 +- src/pocketmine/block/Bricks.php | 2 +- src/pocketmine/block/BurningFurnace.php | 2 +- src/pocketmine/block/Coal.php | 2 +- src/pocketmine/block/CoalOre.php | 2 +- src/pocketmine/block/Cobblestone.php | 2 +- src/pocketmine/block/Diamond.php | 2 +- src/pocketmine/block/DiamondOre.php | 2 +- src/pocketmine/block/DoubleSlab.php | 2 +- src/pocketmine/block/Emerald.php | 2 +- src/pocketmine/block/EmeraldOre.php | 2 +- src/pocketmine/block/EnchantingTable.php | 2 +- src/pocketmine/block/GlowingRedstoneOre.php | 2 +- src/pocketmine/block/Gold.php | 2 +- src/pocketmine/block/GoldOre.php | 2 +- src/pocketmine/block/Iron.php | 2 +- src/pocketmine/block/IronBars.php | 2 +- src/pocketmine/block/IronDoor.php | 2 +- src/pocketmine/block/IronOre.php | 2 +- src/pocketmine/block/Lapis.php | 2 +- src/pocketmine/block/LapisOre.php | 2 +- src/pocketmine/block/MossStone.php | 2 +- src/pocketmine/block/NetherBrick.php | 2 +- src/pocketmine/block/NetherBrickFence.php | 5 ++--- src/pocketmine/block/Netherrack.php | 2 +- src/pocketmine/block/Obsidian.php | 2 +- src/pocketmine/block/Quartz.php | 2 +- src/pocketmine/block/Redstone.php | 2 +- src/pocketmine/block/RedstoneOre.php | 2 +- src/pocketmine/block/Sandstone.php | 2 +- src/pocketmine/block/Slab.php | 2 +- src/pocketmine/block/Stair.php | 2 +- src/pocketmine/block/Stone.php | 1 - src/pocketmine/block/StoneBricks.php | 2 +- src/pocketmine/block/Stonecutter.php | 2 +- 35 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/pocketmine/block/Anvil.php b/src/pocketmine/block/Anvil.php index 4c3114bd4..73c2e6c0f 100644 --- a/src/pocketmine/block/Anvil.php +++ b/src/pocketmine/block/Anvil.php @@ -71,7 +71,7 @@ class Anvil extends Fallable{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [$this->id, 0, 1], //TODO break level ]; diff --git a/src/pocketmine/block/Bricks.php b/src/pocketmine/block/Bricks.php index ef73423b9..d639cc042 100644 --- a/src/pocketmine/block/Bricks.php +++ b/src/pocketmine/block/Bricks.php @@ -49,7 +49,7 @@ class Bricks extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::BRICKS_BLOCK, 0, 1], ]; diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index 18d028e73..ed12a40b6 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -135,7 +135,7 @@ class BurningFurnace extends Solid{ public function getDrops(Item $item){ $drops = []; - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ $drops[] = [Item::FURNACE, 0, 1]; } diff --git a/src/pocketmine/block/Coal.php b/src/pocketmine/block/Coal.php index 75e4fb0d4..494534dcf 100644 --- a/src/pocketmine/block/Coal.php +++ b/src/pocketmine/block/Coal.php @@ -45,7 +45,7 @@ class Coal extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::COAL_BLOCK, 0, 1], ]; diff --git a/src/pocketmine/block/CoalOre.php b/src/pocketmine/block/CoalOre.php index 964ed7647..6c1a78e76 100644 --- a/src/pocketmine/block/CoalOre.php +++ b/src/pocketmine/block/CoalOre.php @@ -45,7 +45,7 @@ class CoalOre extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::COAL, 0, 1], ]; diff --git a/src/pocketmine/block/Cobblestone.php b/src/pocketmine/block/Cobblestone.php index 0a41aa186..5954edbba 100644 --- a/src/pocketmine/block/Cobblestone.php +++ b/src/pocketmine/block/Cobblestone.php @@ -45,7 +45,7 @@ class Cobblestone extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::COBBLESTONE, 0, 1], ]; diff --git a/src/pocketmine/block/Diamond.php b/src/pocketmine/block/Diamond.php index cbe924c95..1fd175dca 100644 --- a/src/pocketmine/block/Diamond.php +++ b/src/pocketmine/block/Diamond.php @@ -45,7 +45,7 @@ class Diamond extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 4){ + if($item->isPickaxe() >= Tool::TIER_IRON){ return [ [Item::DIAMOND_BLOCK, 0, 1], ]; diff --git a/src/pocketmine/block/DiamondOre.php b/src/pocketmine/block/DiamondOre.php index e9b9466db..c05abb384 100644 --- a/src/pocketmine/block/DiamondOre.php +++ b/src/pocketmine/block/DiamondOre.php @@ -45,7 +45,7 @@ class DiamondOre extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 4){ + if($item->isPickaxe() >= Tool::TIER_IRON){ return [ [Item::DIAMOND, 0, 1], ]; diff --git a/src/pocketmine/block/DoubleSlab.php b/src/pocketmine/block/DoubleSlab.php index cf037e961..3ccdcf84b 100644 --- a/src/pocketmine/block/DoubleSlab.php +++ b/src/pocketmine/block/DoubleSlab.php @@ -55,7 +55,7 @@ class DoubleSlab extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::SLAB, $this->meta & 0x07, 2], ]; diff --git a/src/pocketmine/block/Emerald.php b/src/pocketmine/block/Emerald.php index b5db557e0..2f24e34c5 100644 --- a/src/pocketmine/block/Emerald.php +++ b/src/pocketmine/block/Emerald.php @@ -45,7 +45,7 @@ class Emerald extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 4){ + if($item->isPickaxe() >= Tool::TIER_IRON){ return [ [Item::EMERALD_BLOCK, 0, 1], ]; diff --git a/src/pocketmine/block/EmeraldOre.php b/src/pocketmine/block/EmeraldOre.php index 54971f3b4..90fac45c3 100644 --- a/src/pocketmine/block/EmeraldOre.php +++ b/src/pocketmine/block/EmeraldOre.php @@ -45,7 +45,7 @@ class EmeraldOre extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 4){ + if($item->isPickaxe() >= Tool::TIER_IRON){ return [ [Item::EMERALD, 0, 1], ]; diff --git a/src/pocketmine/block/EnchantingTable.php b/src/pocketmine/block/EnchantingTable.php index f65c5f8bc..5890367ab 100644 --- a/src/pocketmine/block/EnchantingTable.php +++ b/src/pocketmine/block/EnchantingTable.php @@ -97,7 +97,7 @@ class EnchantingTable extends Transparent{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [$this->id, 0, 1], ]; diff --git a/src/pocketmine/block/GlowingRedstoneOre.php b/src/pocketmine/block/GlowingRedstoneOre.php index a1675fc02..095241607 100644 --- a/src/pocketmine/block/GlowingRedstoneOre.php +++ b/src/pocketmine/block/GlowingRedstoneOre.php @@ -60,7 +60,7 @@ class GlowingRedstoneOre extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 4){ + if($item->isPickaxe() >= Tool::TIER_IRON){ return [ [Item::REDSTONE_DUST, 0, mt_rand(4, 5)], ]; diff --git a/src/pocketmine/block/Gold.php b/src/pocketmine/block/Gold.php index cb9421124..62b942f53 100644 --- a/src/pocketmine/block/Gold.php +++ b/src/pocketmine/block/Gold.php @@ -45,7 +45,7 @@ class Gold extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 4){ + if($item->isPickaxe() >= Tool::TIER_IRON){ return [ [Item::GOLD_BLOCK, 0, 1], ]; diff --git a/src/pocketmine/block/GoldOre.php b/src/pocketmine/block/GoldOre.php index 5c87c16d4..c56cff977 100644 --- a/src/pocketmine/block/GoldOre.php +++ b/src/pocketmine/block/GoldOre.php @@ -45,7 +45,7 @@ class GoldOre extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 4){ + if($item->isPickaxe() >= Tool::TIER_IRON){ return [ [Item::GOLD_ORE, 0, 1], ]; diff --git a/src/pocketmine/block/Iron.php b/src/pocketmine/block/Iron.php index 66a2c28ee..2ffc4cd6a 100644 --- a/src/pocketmine/block/Iron.php +++ b/src/pocketmine/block/Iron.php @@ -45,7 +45,7 @@ class Iron extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 3){ + if($item->isPickaxe() >= Tool::TIER_STONE){ return [ [Item::IRON_BLOCK, 0, 1], ]; diff --git a/src/pocketmine/block/IronBars.php b/src/pocketmine/block/IronBars.php index bebe0f3a2..b5e70e873 100644 --- a/src/pocketmine/block/IronBars.php +++ b/src/pocketmine/block/IronBars.php @@ -45,7 +45,7 @@ class IronBars extends Thin{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::IRON_BARS, 0, 1], ]; diff --git a/src/pocketmine/block/IronDoor.php b/src/pocketmine/block/IronDoor.php index 447b723f9..70195b9a9 100644 --- a/src/pocketmine/block/IronDoor.php +++ b/src/pocketmine/block/IronDoor.php @@ -45,7 +45,7 @@ class IronDoor extends Door{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::IRON_DOOR, 0, 1], ]; diff --git a/src/pocketmine/block/IronOre.php b/src/pocketmine/block/IronOre.php index 01e8be86d..cda415136 100644 --- a/src/pocketmine/block/IronOre.php +++ b/src/pocketmine/block/IronOre.php @@ -45,7 +45,7 @@ class IronOre extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 3){ + if($item->isPickaxe() >= Tool::TIER_STONE){ return [ [Item::IRON_ORE, 0, 1], ]; diff --git a/src/pocketmine/block/Lapis.php b/src/pocketmine/block/Lapis.php index aa0b9212f..5cc8a2537 100644 --- a/src/pocketmine/block/Lapis.php +++ b/src/pocketmine/block/Lapis.php @@ -45,7 +45,7 @@ class Lapis extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 3){ + if($item->isPickaxe() >= Tool::TIER_STONE){ return [ [Item::LAPIS_BLOCK, 0, 1], ]; diff --git a/src/pocketmine/block/LapisOre.php b/src/pocketmine/block/LapisOre.php index 44d6e9eeb..68ca5626e 100644 --- a/src/pocketmine/block/LapisOre.php +++ b/src/pocketmine/block/LapisOre.php @@ -45,7 +45,7 @@ class LapisOre extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 3){ + if($item->isPickaxe() >= Tool::TIER_STONE){ return [ [Item::DYE, 4, mt_rand(4, 8)], ]; diff --git a/src/pocketmine/block/MossStone.php b/src/pocketmine/block/MossStone.php index 5700d5928..6476028f2 100644 --- a/src/pocketmine/block/MossStone.php +++ b/src/pocketmine/block/MossStone.php @@ -45,7 +45,7 @@ class MossStone extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::MOSS_STONE, $this->meta, 1], ]; diff --git a/src/pocketmine/block/NetherBrick.php b/src/pocketmine/block/NetherBrick.php index 937713b80..12400a516 100644 --- a/src/pocketmine/block/NetherBrick.php +++ b/src/pocketmine/block/NetherBrick.php @@ -45,7 +45,7 @@ class NetherBrick extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::NETHER_BRICKS, 0, 1], ]; diff --git a/src/pocketmine/block/NetherBrickFence.php b/src/pocketmine/block/NetherBrickFence.php index b42cdbd7f..62a182375 100644 --- a/src/pocketmine/block/NetherBrickFence.php +++ b/src/pocketmine/block/NetherBrickFence.php @@ -47,7 +47,6 @@ class NetherBrickFence extends Transparent { } public function getToolType(){ - //Different then the woodfences return Tool::TYPE_PICKAXE; } @@ -61,9 +60,9 @@ class NetherBrickFence extends Transparent { } public function getDrops(Item $item){ - if($item->isPickaxe() >= Tool::TYPE_WOODEN){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ - [Item::NETHER_BRICK_FENCE, $this->meta, 1], + [$this->id, $this->meta, 1], ]; }else{ return []; diff --git a/src/pocketmine/block/Netherrack.php b/src/pocketmine/block/Netherrack.php index 8d3d5135a..7496ad14d 100644 --- a/src/pocketmine/block/Netherrack.php +++ b/src/pocketmine/block/Netherrack.php @@ -45,7 +45,7 @@ class Netherrack extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::NETHERRACK, 0, 1], ]; diff --git a/src/pocketmine/block/Obsidian.php b/src/pocketmine/block/Obsidian.php index cc93e4379..f483c58b9 100644 --- a/src/pocketmine/block/Obsidian.php +++ b/src/pocketmine/block/Obsidian.php @@ -45,7 +45,7 @@ class Obsidian extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 5){ + if($item->isPickaxe() >= Tool::TIER_DIAMOND){ return [ [Item::OBSIDIAN, 0, 1], ]; diff --git a/src/pocketmine/block/Quartz.php b/src/pocketmine/block/Quartz.php index 5dacc3eb7..cbf0c432c 100644 --- a/src/pocketmine/block/Quartz.php +++ b/src/pocketmine/block/Quartz.php @@ -56,7 +56,7 @@ class Quartz extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::QUARTZ_BLOCK, $this->meta & 0x03, 1], ]; diff --git a/src/pocketmine/block/Redstone.php b/src/pocketmine/block/Redstone.php index c2707e016..41cd19d54 100644 --- a/src/pocketmine/block/Redstone.php +++ b/src/pocketmine/block/Redstone.php @@ -45,7 +45,7 @@ class Redstone extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::REDSTONE_BLOCK, 0, 1], ]; diff --git a/src/pocketmine/block/RedstoneOre.php b/src/pocketmine/block/RedstoneOre.php index 6b31c4090..2fb6df907 100644 --- a/src/pocketmine/block/RedstoneOre.php +++ b/src/pocketmine/block/RedstoneOre.php @@ -58,7 +58,7 @@ class RedstoneOre extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 2){ + if($item->isPickaxe() >= Tool::TIER_GOLD){ return [ [Item::REDSTONE_DUST, 0, mt_rand(4, 5)], ]; diff --git a/src/pocketmine/block/Sandstone.php b/src/pocketmine/block/Sandstone.php index eab79265e..60bca024a 100644 --- a/src/pocketmine/block/Sandstone.php +++ b/src/pocketmine/block/Sandstone.php @@ -55,7 +55,7 @@ class Sandstone extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::SANDSTONE, $this->meta & 0x03, 1], ]; diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index 9bb0e3792..0bf6ae950 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -133,7 +133,7 @@ class Slab extends Transparent{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [$this->id, $this->meta & 0x07, 1], ]; diff --git a/src/pocketmine/block/Stair.php b/src/pocketmine/block/Stair.php index bb02a76d1..7416b6fd6 100644 --- a/src/pocketmine/block/Stair.php +++ b/src/pocketmine/block/Stair.php @@ -143,7 +143,7 @@ abstract class Stair extends Transparent{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [$this->getId(), 0, 1], ]; diff --git a/src/pocketmine/block/Stone.php b/src/pocketmine/block/Stone.php index 3b9eadd12..055731d7c 100644 --- a/src/pocketmine/block/Stone.php +++ b/src/pocketmine/block/Stone.php @@ -37,7 +37,6 @@ class Stone extends Solid{ public function __construct($meta = 0){ $this->meta = $meta; - } public function getHardness(){ diff --git a/src/pocketmine/block/StoneBricks.php b/src/pocketmine/block/StoneBricks.php index 0553f49a6..461a39e4e 100644 --- a/src/pocketmine/block/StoneBricks.php +++ b/src/pocketmine/block/StoneBricks.php @@ -55,7 +55,7 @@ class StoneBricks extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::STONE_BRICKS, $this->meta & 0x03, 1], ]; diff --git a/src/pocketmine/block/Stonecutter.php b/src/pocketmine/block/Stonecutter.php index 3dc127c46..918011e3f 100644 --- a/src/pocketmine/block/Stonecutter.php +++ b/src/pocketmine/block/Stonecutter.php @@ -55,7 +55,7 @@ class Stonecutter extends Solid{ } public function getDrops(Item $item){ - if($item->isPickaxe() >= 1){ + if($item->isPickaxe() >= Tool::TIER_WOODEN){ return [ [Item::STONECUTTER, 0, 1], ]; From f9d7e204c8725ad198083d6bbf800ddb75a07287 Mon Sep 17 00:00:00 2001 From: Intyre Date: Sun, 11 Oct 2015 01:32:33 +0200 Subject: [PATCH 18/36] Block update on WallSign fix --- src/pocketmine/block/SignPost.php | 2 +- src/pocketmine/block/WallSign.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/block/SignPost.php b/src/pocketmine/block/SignPost.php index c151f0731..5ae519979 100644 --- a/src/pocketmine/block/SignPost.php +++ b/src/pocketmine/block/SignPost.php @@ -88,7 +88,7 @@ class SignPost extends Transparent{ } public function onBreak(Item $item){ - $this->getLevel()->setBlock($this, new Air(), true, true, true); + $this->getLevel()->setBlock($this, new Air(), true, true); return true; } diff --git a/src/pocketmine/block/WallSign.php b/src/pocketmine/block/WallSign.php index 1a09123fa..66064a8bc 100644 --- a/src/pocketmine/block/WallSign.php +++ b/src/pocketmine/block/WallSign.php @@ -22,6 +22,8 @@ namespace pocketmine\block; +use pocketmine\level\Level; + class WallSign extends SignPost{ protected $id = self::WALL_SIGN; @@ -31,6 +33,20 @@ class WallSign extends SignPost{ } public function onUpdate($type){ + $faces = [ + 2 => 3, + 3 => 2, + 4 => 5, + 5 => 4, + ]; + if($type === Level::BLOCK_UPDATE_NORMAL){ + if(isset($faces[$this->meta])) { + if ($this->getSide($faces[$this->meta])->getId() === self::AIR) { + $this->getLevel()->useBreakOn($this); + } + return Level::BLOCK_UPDATE_NORMAL; + } + } return false; } } \ No newline at end of file From 4d5da41cd03edd53f4cc2f630ad3b6a3b38e2933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=81=E5=A4=9C=E6=9A=97=E8=8A=92=E4=BD=BF?= <1323471525@qq.com> Date: Sat, 31 Oct 2015 13:22:45 +0800 Subject: [PATCH 19/36] Fix autoSave in PlayerQuitEvent --- src/pocketmine/event/player/PlayerQuitEvent.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/event/player/PlayerQuitEvent.php b/src/pocketmine/event/player/PlayerQuitEvent.php index b8c4f63f4..37efeb4da 100644 --- a/src/pocketmine/event/player/PlayerQuitEvent.php +++ b/src/pocketmine/event/player/PlayerQuitEvent.php @@ -36,7 +36,7 @@ class PlayerQuitEvent extends PlayerEvent{ public function __construct(Player $player, $quitMessage, $autoSave = true){ $this->player = $player; $this->quitMessage = $quitMessage; - $this->autoSave = true; + $this->autoSave = $autoSave; } public function setQuitMessage($quitMessage){ @@ -55,4 +55,4 @@ class PlayerQuitEvent extends PlayerEvent{ $this->autoSave = (bool) $value; } -} \ No newline at end of file +} From 6ae0f3c8d831159cd90d9355514507039cdcb365 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Sat, 31 Oct 2015 20:31:24 +0800 Subject: [PATCH 20/36] Cleaner (and maybe faster) INI parsing --- src/pocketmine/lang/BaseLang.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/lang/BaseLang.php b/src/pocketmine/lang/BaseLang.php index 8704ec92c..ccfb6d141 100644 --- a/src/pocketmine/lang/BaseLang.php +++ b/src/pocketmine/lang/BaseLang.php @@ -61,13 +61,13 @@ class BaseLang{ continue; } - $t = explode("=", $line); + $t = explode("=", $line, 2); if(count($t) < 2){ continue; } - $key = trim(array_shift($t)); - $value = trim(implode("=", $t)); + $key = trim($t[0]); + $value = trim($t[1]); if($value === ""){ continue; From ea8ba995ac685388894afa5291a46af1524125ea Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Sat, 31 Oct 2015 21:18:06 +0800 Subject: [PATCH 21/36] Update Player.php --- src/pocketmine/Player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index ae38135f3..60299e101 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1856,7 +1856,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } if($this->teleportPosition !== null or ($this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.1 or $revert))){ - $this->sendPosition($this->forceMovement, $packet->yaw, $packet->pitch); + $this->sendPosition($this->teleportPosition === null ? $this->forceMovement : $this->teleportPosition, $packet->yaw, $packet->pitch); }else{ $packet->yaw %= 360; $packet->pitch %= 360; From cbed8d40ff57ce54297a5c8850af81c815a4a9a3 Mon Sep 17 00:00:00 2001 From: TrinityDevelopers Date: Thu, 5 Nov 2015 17:11:42 -0600 Subject: [PATCH 22/36] Fix a mispelled "new" call --- src/pocketmine/level/generator/Flat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index 5ccdc8c6d..9785a8823 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -67,7 +67,7 @@ class Flat extends Generator{ $ores = new Ore(); $ores->setOreTypes([ new object\OreType(new CoalOre(), 20, 16, 0, 128), - new object\OreType(New IronOre(), 20, 8, 0, 64), + new object\OreType(new IronOre(), 20, 8, 0, 64), new object\OreType(new RedstoneOre(), 8, 7, 0, 16), new object\OreType(new LapisOre(), 1, 6, 0, 32), new object\OreType(new GoldOre(), 2, 8, 0, 32), From 815411968bc10bed2fce9e325eb6d029de0deab4 Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Fri, 20 Nov 2015 00:34:29 +0800 Subject: [PATCH 23/36] Silence the ifconfig not found message --- src/pocketmine/utils/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 8caa74358..c6f13ff9d 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -103,7 +103,7 @@ class Utils{ if(file_exists("/etc/machine-id")){ $machine .= file_get_contents("/etc/machine-id"); }else{ - @exec("ifconfig", $mac); + @exec("ifconfig 2>/dev/null", $mac); $mac = implode("\n", $mac); if(preg_match_all("#HWaddr[ \t]{1,}([0-9a-f:]{17})#", $mac, $matches)){ foreach($matches[1] as $i => $v){ From 2ea81710ad31d28dd934e7831a2419c8e70f77bd Mon Sep 17 00:00:00 2001 From: Intyre Date: Mon, 23 Nov 2015 21:01:02 +0100 Subject: [PATCH 24/36] Bump protocol and fixed packets for 0.13.0 --- src/pocketmine/Player.php | 3 +-- src/pocketmine/PocketMine.php | 4 ++-- src/pocketmine/network/Network.php | 8 ++++---- ...yDataPacket.php => BlockEntityDataPacket.php} | 14 +++++++------- ...{TileEventPacket.php => BlockEventPacket.php} | 16 ++++++++-------- .../network/protocol/ContainerSetSlotPacket.php | 3 +++ src/pocketmine/network/protocol/Info.php | 8 ++++---- src/pocketmine/network/protocol/LoginPacket.php | 1 + .../network/protocol/PlayerListPacket.php | 1 + 9 files changed, 31 insertions(+), 27 deletions(-) rename src/pocketmine/network/protocol/{TileEntityDataPacket.php => BlockEntityDataPacket.php} (89%) rename src/pocketmine/network/protocol/{TileEventPacket.php => BlockEventPacket.php} (89%) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index edd8a6214..8de5b45f9 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1833,7 +1833,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } $this->randomClientId = $packet->clientId; - $this->loginData = ["clientId" => $packet->clientId, "loginData" => null]; $this->uuid = $packet->clientUUID; $this->rawUUID = $this->uuid->toBinary(); @@ -2863,7 +2862,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } break; - case ProtocolInfo::TILE_ENTITY_DATA_PACKET: + case ProtocolInfo::BLOCK_ENTITY_DATA_PACKET: if($this->spawned === false or $this->blocked === true or !$this->isAlive()){ break; } diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 98b4e3302..b284c885f 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -75,8 +75,8 @@ namespace pocketmine { const VERSION = "1.6dev"; const API_VERSION = "1.13.0"; const CODENAME = "[REDACTED]"; - const MINECRAFT_VERSION = "v0.12.1 alpha"; - const MINECRAFT_VERSION_NETWORK = "0.12.1"; + const MINECRAFT_VERSION = "v0.13.0 alpha"; + const MINECRAFT_VERSION_NETWORK = "0.13.0"; /* * Startup code. Do not look at it, it may harm you. diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 8540d56b7..729f7c5be 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -43,7 +43,7 @@ use pocketmine\network\protocol\DropItemPacket; use pocketmine\network\protocol\FullChunkDataPacket; use pocketmine\network\protocol\Info; use pocketmine\network\protocol\SetEntityLinkPacket; -use pocketmine\network\protocol\TileEntityDataPacket; +use pocketmine\network\protocol\BlockEntityDataPacket; use pocketmine\network\protocol\EntityEventPacket; use pocketmine\network\protocol\ExplodePacket; use pocketmine\network\protocol\HurtArmorPacket; @@ -71,7 +71,7 @@ use pocketmine\network\protocol\SetSpawnPositionPacket; use pocketmine\network\protocol\SetTimePacket; use pocketmine\network\protocol\StartGamePacket; use pocketmine\network\protocol\TakeItemEntityPacket; -use pocketmine\network\protocol\TileEventPacket; +use pocketmine\network\protocol\BlockEventPacket; use pocketmine\network\protocol\UpdateBlockPacket; use pocketmine\network\protocol\UseItemPacket; use pocketmine\network\protocol\PlayerListPacket; @@ -325,7 +325,7 @@ class Network{ $this->registerPacket(ProtocolInfo::ADD_PAINTING_PACKET, AddPaintingPacket::class); $this->registerPacket(ProtocolInfo::EXPLODE_PACKET, ExplodePacket::class); $this->registerPacket(ProtocolInfo::LEVEL_EVENT_PACKET, LevelEventPacket::class); - $this->registerPacket(ProtocolInfo::TILE_EVENT_PACKET, TileEventPacket::class); + $this->registerPacket(ProtocolInfo::BLOCK_EVENT_PACKET, BlockEventPacket::class); $this->registerPacket(ProtocolInfo::ENTITY_EVENT_PACKET, EntityEventPacket::class); $this->registerPacket(ProtocolInfo::MOB_EQUIPMENT_PACKET, MobEquipmentPacket::class); $this->registerPacket(ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET, MobArmorEquipmentPacket::class); @@ -349,7 +349,7 @@ class Network{ $this->registerPacket(ProtocolInfo::CRAFTING_DATA_PACKET, CraftingDataPacket::class); $this->registerPacket(ProtocolInfo::CRAFTING_EVENT_PACKET, CraftingEventPacket::class); $this->registerPacket(ProtocolInfo::ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket::class); - $this->registerPacket(ProtocolInfo::TILE_ENTITY_DATA_PACKET, TileEntityDataPacket::class); + $this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class); $this->registerPacket(ProtocolInfo::FULL_CHUNK_DATA_PACKET, FullChunkDataPacket::class); $this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class); $this->registerPacket(ProtocolInfo::PLAYER_LIST_PACKET, PlayerListPacket::class); diff --git a/src/pocketmine/network/protocol/TileEntityDataPacket.php b/src/pocketmine/network/protocol/BlockEntityDataPacket.php similarity index 89% rename from src/pocketmine/network/protocol/TileEntityDataPacket.php rename to src/pocketmine/network/protocol/BlockEntityDataPacket.php index 65f04b738..668da2eea 100644 --- a/src/pocketmine/network/protocol/TileEntityDataPacket.php +++ b/src/pocketmine/network/protocol/BlockEntityDataPacket.php @@ -2,11 +2,11 @@ /* * - * ____ _ _ __ __ _ __ __ ____ - * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ + * ____ _ _ __ __ _ __ __ ____ + * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | - * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ - * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| + * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ + * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -15,7 +15,7 @@ * * @author PocketMine Team * @link http://www.pocketmine.net/ - * + * * */ @@ -24,8 +24,8 @@ namespace pocketmine\network\protocol; #include -class TileEntityDataPacket extends DataPacket{ - const NETWORK_ID = Info::TILE_ENTITY_DATA_PACKET; +class BlockEntityDataPacket extends DataPacket{ + const NETWORK_ID = Info::BLOCK_ENTITY_DATA_PACKET; public $x; public $y; diff --git a/src/pocketmine/network/protocol/TileEventPacket.php b/src/pocketmine/network/protocol/BlockEventPacket.php similarity index 89% rename from src/pocketmine/network/protocol/TileEventPacket.php rename to src/pocketmine/network/protocol/BlockEventPacket.php index b46d2b5ec..1399cfc4d 100644 --- a/src/pocketmine/network/protocol/TileEventPacket.php +++ b/src/pocketmine/network/protocol/BlockEventPacket.php @@ -2,11 +2,11 @@ /* * - * ____ _ _ __ __ _ __ __ ____ - * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ + * ____ _ _ __ __ _ __ __ ____ + * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | - * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ - * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| + * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ + * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -15,7 +15,7 @@ * * @author PocketMine Team * @link http://www.pocketmine.net/ - * + * * */ @@ -24,8 +24,8 @@ namespace pocketmine\network\protocol; #include -class TileEventPacket extends DataPacket{ - const NETWORK_ID = Info::TILE_EVENT_PACKET; +class BlockEventPacket extends DataPacket{ + const NETWORK_ID = Info::BLOCK_EVENT_PACKET; public $x; public $y; @@ -46,4 +46,4 @@ class TileEventPacket extends DataPacket{ $this->putInt($this->case2); } -} \ No newline at end of file +} diff --git a/src/pocketmine/network/protocol/ContainerSetSlotPacket.php b/src/pocketmine/network/protocol/ContainerSetSlotPacket.php index 244aba979..43c4d1c34 100644 --- a/src/pocketmine/network/protocol/ContainerSetSlotPacket.php +++ b/src/pocketmine/network/protocol/ContainerSetSlotPacket.php @@ -30,12 +30,14 @@ class ContainerSetSlotPacket extends DataPacket{ public $windowid; public $slot; + public $hotbarSlot; /** @var Item */ public $item; public function decode(){ $this->windowid = $this->getByte(); $this->slot = $this->getShort(); + $this->hotboarSlot = $this->getShort(); $this->item = $this->getSlot(); } @@ -43,6 +45,7 @@ class ContainerSetSlotPacket extends DataPacket{ $this->reset(); $this->putByte($this->windowid); $this->putShort($this->slot); + $this->putShort($this->hotbarSlot); $this->putSlot($this->item); } diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index e22c2dc1d..c4113e93b 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -30,7 +30,7 @@ interface Info{ /** * Actual Minecraft: PE protocol version */ - const CURRENT_PROTOCOL = 34; + const CURRENT_PROTOCOL = 38; const LOGIN_PACKET = 0x8f; const PLAY_STATUS_PACKET = 0x90; @@ -52,7 +52,7 @@ interface Info{ const ADD_PAINTING_PACKET = 0xa0; const EXPLODE_PACKET = 0xa1; const LEVEL_EVENT_PACKET = 0xa2; - const TILE_EVENT_PACKET = 0xa3; + const BLOCK_EVENT_PACKET = 0xa3; const ENTITY_EVENT_PACKET = 0xa4; const MOB_EFFECT_PACKET = 0xa5; const UPDATE_ATTRIBUTES_PACKET = 0xa6; @@ -78,7 +78,7 @@ interface Info{ const CRAFTING_DATA_PACKET = 0xba; const CRAFTING_EVENT_PACKET = 0xbb; const ADVENTURE_SETTINGS_PACKET = 0xbc; - const TILE_ENTITY_DATA_PACKET = 0xbd; + const BLOCK_ENTITY_DATA_PACKET = 0xbd; //const PLAYER_INPUT_PACKET = 0xbe; const FULL_CHUNK_DATA_PACKET = 0xbf; const SET_DIFFICULTY_PACKET = 0xc0; @@ -86,7 +86,7 @@ interface Info{ //const SET_PLAYER_GAMETYPE_PACKET = 0xc2; const PLAYER_LIST_PACKET = 0xc3; //const TELEMETRY_EVENT_PACKET = 0xc4; - + //const SPAWN_EXPERIENCE_ORB_PACKET = 0xc5 } diff --git a/src/pocketmine/network/protocol/LoginPacket.php b/src/pocketmine/network/protocol/LoginPacket.php index 3cc8eca94..5608ac993 100644 --- a/src/pocketmine/network/protocol/LoginPacket.php +++ b/src/pocketmine/network/protocol/LoginPacket.php @@ -52,6 +52,7 @@ class LoginPacket extends DataPacket{ $this->serverAddress = $this->getString(); $this->clientSecret = $this->getString(); + $this->getByte(); // TODO: skin transparency, experimental or not? $this->slim = $this->getByte() > 0; $this->skin = $this->getString(); } diff --git a/src/pocketmine/network/protocol/PlayerListPacket.php b/src/pocketmine/network/protocol/PlayerListPacket.php index bcb45acd6..9f9658b4a 100644 --- a/src/pocketmine/network/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/protocol/PlayerListPacket.php @@ -53,6 +53,7 @@ class PlayerListPacket extends DataPacket{ $this->putUUID($d[0]); $this->putLong($d[1]); $this->putString($d[2]); + $this->putByte(0); // TODO: skin transparency, experimental or not? $this->putByte($d[3] ? 1 : 0); $this->putString($d[4]); }else{ From 58709293cf4eee2e836a94226bbba4aca0f53908 Mon Sep 17 00:00:00 2001 From: Intyre Date: Mon, 23 Nov 2015 21:04:23 +0100 Subject: [PATCH 25/36] Fixed crafting --- src/pocketmine/Player.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 8de5b45f9..4ca8acee4 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2636,15 +2636,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade for($y = 0; $y < 3; ++$y){ $item = $packet->input[$y * 3 + $x]; $ingredient = $recipe->getIngredient($x, $y); - if($item->getCount() > 0 and $item->getId() > 0){ + if($item->getCount() > 0){ if($ingredient === null or !$ingredient->deepEquals($item, $ingredient->getDamage() !== null, $ingredient->getCompoundTag() !== null)){ $canCraft = false; break; } - - }elseif($ingredient !== null and $ingredient->getId() !== 0){ - $canCraft = false; - break; } } } From 734736492a3cde756809b128195b1703948fbfd5 Mon Sep 17 00:00:00 2001 From: Intyre Date: Mon, 23 Nov 2015 21:56:38 +0100 Subject: [PATCH 26/36] Added some creative items and removed nether reactor --- src/pocketmine/block/Block.php | 2 - src/pocketmine/block/NetherReactor.php | 41 ---- src/pocketmine/inventory/CraftingManager.php | 6 - src/pocketmine/item/Item.php | 230 +++++++++++++++---- src/pocketmine/tile/Tile.php | 1 - 5 files changed, 187 insertions(+), 93 deletions(-) delete mode 100644 src/pocketmine/block/NetherReactor.php diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index a02ec99c4..a1f574598 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -255,7 +255,6 @@ class Block extends Position implements Metadatable{ const BEETROOT_BLOCK = 244; const STONECUTTER = 245; const GLOWING_OBSIDIAN = 246; - const NETHER_REACTOR = 247; /** @var \SplFixedArray */ public static $list = null; @@ -465,7 +464,6 @@ class Block extends Position implements Metadatable{ self::$list[self::BEETROOT_BLOCK] = Beetroot::class; self::$list[self::STONECUTTER] = Stonecutter::class; self::$list[self::GLOWING_OBSIDIAN] = GlowingObsidian::class; - self::$list[self::NETHER_REACTOR] = NetherReactor::class; foreach(self::$list as $id => $class){ if($class !== null){ diff --git a/src/pocketmine/block/NetherReactor.php b/src/pocketmine/block/NetherReactor.php deleted file mode 100644 index 47e49582b..000000000 --- a/src/pocketmine/block/NetherReactor.php +++ /dev/null @@ -1,41 +0,0 @@ -meta = $meta; - } - - public function getName(){ - return "Nether Reactor"; - } - - public function canBeActivated(){ - return true; - } - -} \ No newline at end of file diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index 66e8234b5..aac0d350d 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -219,12 +219,6 @@ class CraftingManager{ "S S" ))->setIngredient("S", Item::get(Item::STICK, 0, 7))); - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::NETHER_REACTOR, 0, 1), - "IDI", - "IDI", - "IDI" - ))->setIngredient("D", Item::get(Item::DIAMOND, 0, 3))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 6))); - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::TRAPDOOR, 0, 2), "PPP", "PPP" diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index db827f04f..c8a7b44fa 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -284,7 +284,6 @@ class Item{ const BEETROOT_BLOCK = 244; const STONECUTTER = 245; const GLOWING_OBSIDIAN = 246; - const NETHER_REACTOR = 247; //Normal Item IDs @@ -590,6 +589,7 @@ class Item{ private static function initCreativeItems(){ self::clearCreativeItems(); + //Building self::addCreativeItem(Item::get(Item::COBBLESTONE, 0)); self::addCreativeItem(Item::get(Item::STONE_BRICKS, 0)); @@ -604,7 +604,6 @@ class Item{ self::addCreativeItem(Item::get(Item::WOODEN_PLANKS, 4)); self::addCreativeItem(Item::get(Item::WOODEN_PLANKS, 5)); self::addCreativeItem(Item::get(Item::BRICKS, 0)); - self::addCreativeItem(Item::get(Item::STONE, 0)); self::addCreativeItem(Item::get(Item::STONE, 1)); self::addCreativeItem(Item::get(Item::STONE, 2)); @@ -648,6 +647,7 @@ class Item{ self::addCreativeItem(Item::get(Item::TRUNK2, 1)); self::addCreativeItem(Item::get(Item::NETHER_BRICKS, 0)); self::addCreativeItem(Item::get(Item::NETHERRACK, 0)); + self::addCreativeItem(Item::get(Item::SOUL_SAND, 0)); self::addCreativeItem(Item::get(Item::BEDROCK, 0)); self::addCreativeItem(Item::get(Item::COBBLESTONE_STAIRS, 0)); self::addCreativeItem(Item::get(Item::OAK_WOODEN_STAIRS, 0)); @@ -673,6 +673,7 @@ class Item{ self::addCreativeItem(Item::get(Item::SLAB, 4)); self::addCreativeItem(Item::get(Item::SLAB, 5)); self::addCreativeItem(Item::get(Item::SLAB, 6)); + // TODO: Nether brick slab self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 0)); self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 1)); self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 2)); @@ -685,9 +686,9 @@ class Item{ self::addCreativeItem(Item::get(Item::EMERALD_ORE, 0)); self::addCreativeItem(Item::get(Item::OBSIDIAN, 0)); self::addCreativeItem(Item::get(Item::ICE, 0)); + // TODO: Packed ice 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)); @@ -704,12 +705,18 @@ class Item{ self::addCreativeItem(Item::get(Item::GLASS, 0)); self::addCreativeItem(Item::get(Item::GLOWSTONE_BLOCK, 0)); self::addCreativeItem(Item::get(Item::VINES, 0)); - self::addCreativeItem(Item::get(Item::NETHER_REACTOR, 0)); self::addCreativeItem(Item::get(Item::LADDER, 0)); self::addCreativeItem(Item::get(Item::SPONGE, 0)); self::addCreativeItem(Item::get(Item::GLASS_PANE, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 0)); + self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 0)); // Oak + self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 1)); // Spruce + self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 2)); // Birch + self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 3)); // Jungle + self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 4)); // Acacia + self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 5)); // Dark oak + // TODO: Iron door self::addCreativeItem(Item::get(Item::TRAPDOOR, 0)); + // TODO: Iron trapdoor 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)); @@ -718,11 +725,11 @@ class Item{ 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)); - self::addCreativeItem(Item::get(Item::FENCE_GATE_DARK_OAK, 0)); + self::addCreativeItem(Item::get(Item::FENCE_GATE_BIRCH, 0)); self::addCreativeItem(Item::get(Item::FENCE_GATE_JUNGLE, 0)); self::addCreativeItem(Item::get(Item::FENCE_GATE_ACACIA, 0)); + self::addCreativeItem(Item::get(Item::FENCE_GATE_DARK_OAK, 0)); self::addCreativeItem(Item::get(Item::IRON_BARS, 0)); self::addCreativeItem(Item::get(Item::BED, 0)); self::addCreativeItem(Item::get(Item::BOOKSHELF, 0)); @@ -730,8 +737,14 @@ class Item{ self::addCreativeItem(Item::get(Item::WORKBENCH, 0)); self::addCreativeItem(Item::get(Item::STONECUTTER, 0)); self::addCreativeItem(Item::get(Item::CHEST, 0)); + // TODO: Trapped chest self::addCreativeItem(Item::get(Item::FURNACE, 0)); + // TODO: Brewing stand + // TODO: Note Block self::addCreativeItem(Item::get(Item::END_PORTAL, 0)); + self::addCreativeItem(Item::get(Item::ANVIL, 0)); + self::addCreativeItem(Item::get(Item::ANVIL, 4)); + self::addCreativeItem(Item::get(Item::ANVIL, 8)); self::addCreativeItem(Item::get(Item::DANDELION, 0)); self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_POPPY)); self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_BLUE_ORCHID)); @@ -742,17 +755,18 @@ class Item{ self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_WHITE_TULIP)); self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_PINK_TULIP)); self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_OXEYE_DAISY)); - //TODO: Lilac - //TODO: Double Tallgrass - //TODO: Large Fern - //TODO: Rose Bush - //TODO: Peony + // TODO: Sunflower + // TODO: Lilac + // TODO: Double Tallgrass + // TODO: Large Fern + // TODO: Rose Bush + // TODO: Peony self::addCreativeItem(Item::get(Item::BROWN_MUSHROOM, 0)); self::addCreativeItem(Item::get(Item::RED_MUSHROOM, 0)); - //TODO: Mushroom block (brown, cover) - //TODO: Mushroom block (red, cover) - //TODO: Mushroom block (brown, stem) - //TODO: Mushroom block (red, stem) + // TODO: Mushroom block (brown, cover) + // TODO: Mushroom block (red, cover) + // TODO: Mushroom block (brown, stem) + // TODO: Mushroom block (red, stem) self::addCreativeItem(Item::get(Item::CACTUS, 0)); self::addCreativeItem(Item::get(Item::MELON_BLOCK, 0)); self::addCreativeItem(Item::get(Item::PUMPKIN, 0)); @@ -775,8 +789,15 @@ class Item{ self::addCreativeItem(Item::get(Item::LEAVES2, 0)); self::addCreativeItem(Item::get(Item::LEAVES2, 1)); self::addCreativeItem(Item::get(Item::CAKE, 0)); + // TODO: Skeleton skull + // TODO: Wither skeleton skull + // TODO: Zombie head + // TODO: Head + // TODO: Creeper head self::addCreativeItem(Item::get(Item::SIGN, 0)); + // TODO: flower pot self::addCreativeItem(Item::get(Item::MONSTER_SPAWNER, 0)); + self::addCreativeItem(Item::get(Item::ENCHANTMENT_TABLE, 0)); self::addCreativeItem(Item::get(Item::WOOL, 0)); self::addCreativeItem(Item::get(Item::WOOL, 7)); self::addCreativeItem(Item::get(Item::WOOL, 6)); @@ -810,64 +831,184 @@ class Item{ self::addCreativeItem(Item::get(Item::CARPET, 9)); self::addCreativeItem(Item::get(Item::CARPET, 8)); - - self::addCreativeItem(Item::get(Item::ANVIL, 0)); - self::addCreativeItem(Item::get(Item::ANVIL, 4)); - self::addCreativeItem(Item::get(Item::ANVIL, 8)); - //Tools - //TODO self::addCreativeItem(Item::get(Item::RAILS, 0)); - //TODO self::addCreativeItem(Item::get(Item::POWERED_RAILS, 0)); + // TODO: self::addCreativeItem(Item::get(Item::RAILS, 0)); + // TODO: self::addCreativeItem(Item::get(Item::POWERED_RAILS, 0)); + // TODO: Detector rail + // TODO: Activator rail self::addCreativeItem(Item::get(Item::TORCH, 0)); self::addCreativeItem(Item::get(Item::BUCKET, 0)); self::addCreativeItem(Item::get(Item::BUCKET, 1)); self::addCreativeItem(Item::get(Item::BUCKET, 8)); self::addCreativeItem(Item::get(Item::BUCKET, 10)); self::addCreativeItem(Item::get(Item::TNT, 0)); - self::addCreativeItem(Item::get(Item::IRON_HOE, 0)); - self::addCreativeItem(Item::get(Item::IRON_SHOVEL, 0)); - self::addCreativeItem(Item::get(Item::IRON_SWORD, 0)); + self::addCreativeItem(Item::get(Item::REDSTONE, 0)); self::addCreativeItem(Item::get(Item::BOW, 0)); - self::addCreativeItem(Item::get(Item::SHEARS, 0)); + // TODO: fishing rod self::addCreativeItem(Item::get(Item::FLINT_AND_STEEL, 0)); + self::addCreativeItem(Item::get(Item::SHEARS, 0)); self::addCreativeItem(Item::get(Item::CLOCK, 0)); self::addCreativeItem(Item::get(Item::COMPASS, 0)); self::addCreativeItem(Item::get(Item::MINECART, 0)); + // TODO: Oak boat + // TODO: Spruce boat + // TODO: Birch boat + // TODO: Jungle boat + // TODO: Acacia boat + // TODO: Dark Oak boat self::addCreativeItem(Item::get(Item::SPAWN_EGG, Villager::NETWORK_ID)); //self::addCreativeItem(Item::get(Item::SPAWN_EGG, 10)); //Chicken //self::addCreativeItem(Item::get(Item::SPAWN_EGG, 11)); //Cow //self::addCreativeItem(Item::get(Item::SPAWN_EGG, 12)); //Pig //self::addCreativeItem(Item::get(Item::SPAWN_EGG, 13)); //Sheep - //TODO: Wolf - //TODO: Mooshroom - //TODO: Creeper - //TODO: Enderman - //TODO: Silverfish - //TODO: Skeleton - //TODO: Slime + // TODO: Wolf + // TODO: Ocelot + // TODO: Mooshroom + // TODO: Bat + // TODO: Rabbit + // TODO: Creeper + // TODO: Enderman + // TODO: Silverfish + // TODO: Skeleton + // TODO: Slime + // TODO: Spider self::addCreativeItem(Item::get(Item::SPAWN_EGG, Zombie::NETWORK_ID)); //TODO: PigZombie self::addCreativeItem(Item::get(Item::SPAWN_EGG, Squid::NETWORK_ID)); - + // TODO: Cave spider + // TODO: Magma cube + // TODO: Ghast + // TODO: Blaze + self::addCreativeItem(Item::get(Item::WOODEN_SWORD, 0)); + self::addCreativeItem(Item::get(Item::WOODEN_HOE, 0)); + self::addCreativeItem(Item::get(Item::WOODEN_SHOVEL, 0)); + self::addCreativeItem(Item::get(Item::WOODEN_PICKAXE, 0)); + self::addCreativeItem(Item::get(Item::WOODEN_AXE, 0)); + self::addCreativeItem(Item::get(Item::STONE_SWORD, 0)); + self::addCreativeItem(Item::get(Item::STONE_HOE, 0)); + self::addCreativeItem(Item::get(Item::STONE_SHOVEL, 0)); + self::addCreativeItem(Item::get(Item::STONE_PICKAXE, 0)); + self::addCreativeItem(Item::get(Item::STONE_AXE, 0)); + self::addCreativeItem(Item::get(Item::IRON_SWORD, 0)); + self::addCreativeItem(Item::get(Item::IRON_HOE, 0)); + self::addCreativeItem(Item::get(Item::IRON_SHOVEL, 0)); + self::addCreativeItem(Item::get(Item::IRON_PICKAXE, 0)); + self::addCreativeItem(Item::get(Item::IRON_AXE, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_SWORD, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_HOE, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_SHOVEL, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_PICKAXE, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_AXE, 0)); + self::addCreativeItem(Item::get(Item::GOLD_SWORD, 0)); + self::addCreativeItem(Item::get(Item::GOLD_HOE, 0)); + self::addCreativeItem(Item::get(Item::GOLD_SHOVEL, 0)); + self::addCreativeItem(Item::get(Item::GOLD_PICKAXE, 0)); + self::addCreativeItem(Item::get(Item::GOLD_AXE, 0)); + self::addCreativeItem(Item::get(Item::LEATHER_CAP, 0)); + self::addCreativeItem(Item::get(Item::LEATHER_TUNIC, 0)); + self::addCreativeItem(Item::get(Item::LEATHER_PANTS, 0)); + self::addCreativeItem(Item::get(Item::LEATHER_BOOTS, 0)); + self::addCreativeItem(Item::get(Item::CHAIN_HELMET, 0)); + self::addCreativeItem(Item::get(Item::CHAIN_CHESTPLATE, 0)); + self::addCreativeItem(Item::get(Item::CHAIN_LEGGINGS, 0)); + self::addCreativeItem(Item::get(Item::CHAIN_BOOTS, 0)); + self::addCreativeItem(Item::get(Item::IRON_HELMET, 0)); + self::addCreativeItem(Item::get(Item::IRON_CHESTPLATE, 0)); + self::addCreativeItem(Item::get(Item::IRON_LEGGINGS, 0)); + self::addCreativeItem(Item::get(Item::IRON_BOOTS, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_HELMET, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_CHESTPLATE, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_LEGGINGS, 0)); + self::addCreativeItem(Item::get(Item::DIAMOND_BOOTS, 0)); + self::addCreativeItem(Item::get(Item::GOLD_HELMET, 0)); + self::addCreativeItem(Item::get(Item::GOLD_CHESTPLATE, 0)); + self::addCreativeItem(Item::get(Item::GOLD_LEGGINGS, 0)); + self::addCreativeItem(Item::get(Item::GOLD_BOOTS, 0)); + // TODO: Lever + // TODO: Redstone lamp + // TODO: Redstone torch + // TODO: Wood pressure plate + // TODO: Stone pressure plate + // TODO: Weighted pressure plate light + // TODO: Weighted pressure plate heavy + // TODO: Wood button + // TODO: Stone button + // TODO: Daylight sensor + // TODO: Tripwire hook self::addCreativeItem(Item::get(Item::SNOWBALL)); - //Seeds + self::addCreativeItem(Item::get(Item::COAL, 0)); + self::addCreativeItem(Item::get(Item::COAL, 1)); + self::addCreativeItem(Item::get(Item::DIAMOND, 0)); + self::addCreativeItem(Item::get(Item::IRON_INGOT, 0)); + self::addCreativeItem(Item::get(Item::GOLD_INGOT, 0)); + self::addCreativeItem(Item::get(Item::EMERALD, 0)); + self::addCreativeItem(Item::get(Item::STICK, 0)); + self::addCreativeItem(Item::get(Item::BOWL, 0)); + self::addCreativeItem(Item::get(Item::STRING, 0)); + self::addCreativeItem(Item::get(Item::FEATHER, 0)); + self::addCreativeItem(Item::get(Item::FLINT, 0)); + self::addCreativeItem(Item::get(Item::LEATHER, 0)); + // TODO: Rabbit hide + self::addCreativeItem(Item::get(Item::CLAY, 0)); + self::addCreativeItem(Item::get(Item::SUGAR, 0)); + self::addCreativeItem(Item::get(Item::NETHER_QUARTZ, 0)); + self::addCreativeItem(Item::get(Item::PAPER, 0)); + self::addCreativeItem(Item::get(Item::BOOK, 0)); + self::addCreativeItem(Item::get(Item::ARROW, 0)); + self::addCreativeItem(Item::get(Item::BONE, 0)); self::addCreativeItem(Item::get(Item::SUGARCANE, 0)); self::addCreativeItem(Item::get(Item::WHEAT, 0)); self::addCreativeItem(Item::get(Item::SEEDS, 0)); - self::addCreativeItem(Item::get(Item::MELON_SEEDS, 0)); self::addCreativeItem(Item::get(Item::PUMPKIN_SEEDS, 0)); - self::addCreativeItem(Item::get(Item::CARROT, 0)); - self::addCreativeItem(Item::get(Item::POTATO, 0)); + self::addCreativeItem(Item::get(Item::MELON_SEEDS, 0)); self::addCreativeItem(Item::get(Item::BEETROOT_SEEDS, 0)); self::addCreativeItem(Item::get(Item::EGG, 0)); + self::addCreativeItem(Item::get(Item::APPLE, 0)); + self::addCreativeItem(Item::get(Item::GOLDEN_APPLE, 0)); + // TODO: Golden apple enchanted self::addCreativeItem(Item::get(Item::RAW_FISH, 0)); - self::addCreativeItem(Item::get(Item::RAW_FISH, 1)); - self::addCreativeItem(Item::get(Item::RAW_FISH, 2)); - self::addCreativeItem(Item::get(Item::RAW_FISH, 3)); + self::addCreativeItem(Item::get(Item::RAW_FISH, 1)); // TODO: Raw salmon + self::addCreativeItem(Item::get(Item::RAW_FISH, 2)); // TODO: Clownfish + self::addCreativeItem(Item::get(Item::RAW_FISH, 3)); // TODO: Pufferfish self::addCreativeItem(Item::get(Item::COOKED_FISH, 0)); - self::addCreativeItem(Item::get(Item::COOKED_FISH, 1)); + self::addCreativeItem(Item::get(Item::COOKED_FISH, 1)); //salmon + // TODO: Rotten flesh + // TODO: Mushroom stew + self::addCreativeItem(Item::get(Item::BREAD, 0)); + self::addCreativeItem(Item::get(Item::RAW_PORKCHOP, 0)); + self::addCreativeItem(Item::get(Item::COOKED_PORKCHOP, 0)); + self::addCreativeItem(Item::get(Item::RAW_CHICKEN, 0)); + self::addCreativeItem(Item::get(Item::COOKED_CHICKEN, 0)); + self::addCreativeItem(Item::get(Item::RAW_BEEF, 0)); + self::addCreativeItem(Item::get(Item::STEAK, 0)); + self::addCreativeItem(Item::get(Item::MELON, 0)); + self::addCreativeItem(Item::get(Item::CARROT, 0)); + self::addCreativeItem(Item::get(Item::POTATO, 0)); + self::addCreativeItem(Item::get(Item::BAKED_POTATO, 0)); + // TODO: Poisonous potato + self::addCreativeItem(Item::get(Item::COOKIE, 0)); + self::addCreativeItem(Item::get(Item::PUMPKIN_PIE, 0)); + // TODO: Raw rabbit + // TODO: Cooked rabbit + // TODO: Rabbit stew + // TODO: Magma cream + // TODO: Blaze rod + self::addCreativeItem(Item::get(Item::GOLD_NUGGET, 0)); + // TODO: Golden carrot + // TODO: Glistering melon + // TODO: Rabbit's foot + // TODO: Ghast tear + self::addCreativeItem(Item::get(Item::SLIMEBALL, 0)); + // TODO: Blaze powder + // TODO: Nether wart + self::addCreativeItem(Item::get(Item::GUNPOWDER, 0)); + self::addCreativeItem(Item::get(Item::GLOWSTONE_DUST, 0)); + // TODO: Spider eye + // TODO: Fermented spider eye + // TODO: Bottle o' enchanting + // TODO: Enchanted books self::addCreativeItem(Item::get(Item::DYE, 0)); self::addCreativeItem(Item::get(Item::DYE, 7)); self::addCreativeItem(Item::get(Item::DYE, 6)); @@ -884,6 +1025,9 @@ class Item{ self::addCreativeItem(Item::get(Item::DYE, 10)); self::addCreativeItem(Item::get(Item::DYE, 9)); self::addCreativeItem(Item::get(Item::DYE, 8)); + // TODO: Glass bottle + // TODO: Water bottle + // TODO: Potions } public static function clearCreativeItems(){ diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index d3ad814f1..689236f66 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -21,7 +21,6 @@ /** * All the Tile classes and related classes - * TODO: Add Nether Reactor tile */ namespace pocketmine\tile; From 963f7ee0777082b12558080c6eb436dd7bab950e Mon Sep 17 00:00:00 2001 From: hmy2001 Date: Wed, 25 Nov 2015 21:00:03 +0900 Subject: [PATCH 27/36] Update Spawnable.php --- src/pocketmine/tile/Spawnable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/tile/Spawnable.php b/src/pocketmine/tile/Spawnable.php index 37828e0c3..50515d14f 100644 --- a/src/pocketmine/tile/Spawnable.php +++ b/src/pocketmine/tile/Spawnable.php @@ -25,7 +25,7 @@ use pocketmine\level\format\FullChunk; use pocketmine\nbt\NBT; use pocketmine\nbt\tag\Compound; use pocketmine\network\Network; -use pocketmine\network\protocol\TileEntityDataPacket; +use pocketmine\network\protocol\BlockEntityDataPacket; use pocketmine\Player; abstract class Spawnable extends Tile{ @@ -37,7 +37,7 @@ abstract class Spawnable extends Tile{ $nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt->setData($this->getSpawnCompound()); - $pk = new TileEntityDataPacket(); + $pk = new BlockEntityDataPacket(); $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; From 8edebed11c175771df9ece6e3b8f69d0140f7f29 Mon Sep 17 00:00:00 2001 From: hmy2001 Date: Wed, 25 Nov 2015 21:08:04 +0900 Subject: [PATCH 28/36] Update DoubleChestInventory.php --- src/pocketmine/inventory/DoubleChestInventory.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/inventory/DoubleChestInventory.php b/src/pocketmine/inventory/DoubleChestInventory.php index 9cfd9ad93..34b0b7bf8 100644 --- a/src/pocketmine/inventory/DoubleChestInventory.php +++ b/src/pocketmine/inventory/DoubleChestInventory.php @@ -24,7 +24,7 @@ namespace pocketmine\inventory; use pocketmine\item\Item; use pocketmine\level\Level; use pocketmine\network\Network; -use pocketmine\network\protocol\TileEventPacket; +use pocketmine\network\protocol\BlockEventPacket; use pocketmine\Player; use pocketmine\tile\Chest; @@ -99,7 +99,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ parent::onOpen($who); if(count($this->getViewers()) === 1){ - $pk = new TileEventPacket(); + $pk = new BlockEventPacket(); $pk->x = $this->right->getHolder()->getX(); $pk->y = $this->right->getHolder()->getY(); $pk->z = $this->right->getHolder()->getZ(); @@ -113,7 +113,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ public function onClose(Player $who){ if(count($this->getViewers()) === 1){ - $pk = new TileEventPacket(); + $pk = new BlockEventPacket(); $pk->x = $this->right->getHolder()->getX(); $pk->y = $this->right->getHolder()->getY(); $pk->z = $this->right->getHolder()->getZ(); @@ -139,4 +139,4 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ public function getRightSide(){ return $this->right; } -} \ No newline at end of file +} From 4f12533ad37caf9c59df8749a40da82034a39f11 Mon Sep 17 00:00:00 2001 From: hmy2001 Date: Wed, 25 Nov 2015 21:08:28 +0900 Subject: [PATCH 29/36] Update ChestInventory.php --- src/pocketmine/inventory/ChestInventory.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/inventory/ChestInventory.php b/src/pocketmine/inventory/ChestInventory.php index bfa764d43..20cf04fe1 100644 --- a/src/pocketmine/inventory/ChestInventory.php +++ b/src/pocketmine/inventory/ChestInventory.php @@ -23,7 +23,7 @@ namespace pocketmine\inventory; use pocketmine\level\Level; use pocketmine\network\Network; -use pocketmine\network\protocol\TileEventPacket; +use pocketmine\network\protocol\BlockEventPacket; use pocketmine\Player; use pocketmine\tile\Chest; @@ -44,7 +44,7 @@ class ChestInventory extends ContainerInventory{ parent::onOpen($who); if(count($this->getViewers()) === 1){ - $pk = new TileEventPacket(); + $pk = new BlockEventPacket(); $pk->x = $this->getHolder()->getX(); $pk->y = $this->getHolder()->getY(); $pk->z = $this->getHolder()->getZ(); @@ -58,7 +58,7 @@ class ChestInventory extends ContainerInventory{ public function onClose(Player $who){ if(count($this->getViewers()) === 1){ - $pk = new TileEventPacket(); + $pk = new BlockEventPacket(); $pk->x = $this->getHolder()->getX(); $pk->y = $this->getHolder()->getY(); $pk->z = $this->getHolder()->getZ(); @@ -70,4 +70,4 @@ class ChestInventory extends ContainerInventory{ } parent::onClose($who); } -} \ No newline at end of file +} From c803dd8e6930fa7bce65d6758758ce3184cfd243 Mon Sep 17 00:00:00 2001 From: Intyre Date: Thu, 26 Nov 2015 00:47:58 +0100 Subject: [PATCH 30/36] skins fixed and added SetPlayerGameTypePacket --- src/pocketmine/Player.php | 15 +------ src/pocketmine/network/Network.php | 2 + src/pocketmine/network/protocol/Info.php | 2 +- .../network/protocol/LoginPacket.php | 2 +- .../network/protocol/PlayerListPacket.php | 2 +- .../protocol/SetPlayerGameTypePacket.php | 41 +++++++++++++++++++ 6 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 src/pocketmine/network/protocol/SetPlayerGameTypePacket.php diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 4ca8acee4..330f06ca6 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -113,6 +113,7 @@ use pocketmine\network\protocol\Info as ProtocolInfo; use pocketmine\network\protocol\PlayerActionPacket; use pocketmine\network\protocol\PlayStatusPacket; use pocketmine\network\protocol\RespawnPacket; +use pocketmine\network\protocol\SetPlayerGameTypePacket; use pocketmine\network\protocol\TextPacket; use pocketmine\network\protocol\MovePlayerPacket; @@ -1085,7 +1086,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return false; } - $this->gamemode = $gm; $this->allowFlight = $this->isCreative(); @@ -1098,19 +1098,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->namedtag->playerGameType = new Int("playerGameType", $this->gamemode); - $spawnPosition = $this->getSpawn(); - - $pk = new StartGamePacket(); - $pk->seed = -1; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->spawnX = (int) $spawnPosition->x; - $pk->spawnY = (int) $spawnPosition->y; - $pk->spawnZ = (int) $spawnPosition->z; - $pk->generator = 1; //0 old, 1 infinite, 2 flat + $pk = new SetPlayerGameTypePacket(); $pk->gamemode = $this->gamemode & 0x01; - $pk->eid = 0; $this->dataPacket($pk); $this->sendSettings(); diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 729f7c5be..49053ea95 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -74,6 +74,7 @@ use pocketmine\network\protocol\TakeItemEntityPacket; use pocketmine\network\protocol\BlockEventPacket; use pocketmine\network\protocol\UpdateBlockPacket; use pocketmine\network\protocol\UseItemPacket; +use pocketmine\network\protocol\SetPlayerGameTypePacket; use pocketmine\network\protocol\PlayerListPacket; use pocketmine\Player; use pocketmine\Server; @@ -352,6 +353,7 @@ class Network{ $this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class); $this->registerPacket(ProtocolInfo::FULL_CHUNK_DATA_PACKET, FullChunkDataPacket::class); $this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class); + $this->registerPacket(ProtocolInfo::SET_PLAYER_GAMETYPE_PACKET, SetPlayerGameTypePacket::class); $this->registerPacket(ProtocolInfo::PLAYER_LIST_PACKET, PlayerListPacket::class); } } diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index c4113e93b..3f0bdd7d6 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -83,7 +83,7 @@ interface Info{ const FULL_CHUNK_DATA_PACKET = 0xbf; const SET_DIFFICULTY_PACKET = 0xc0; //const CHANGE_DIMENSION_PACKET = 0xc1; - //const SET_PLAYER_GAMETYPE_PACKET = 0xc2; + const SET_PLAYER_GAMETYPE_PACKET = 0xc2; const PLAYER_LIST_PACKET = 0xc3; //const TELEMETRY_EVENT_PACKET = 0xc4; //const SPAWN_EXPERIENCE_ORB_PACKET = 0xc5 diff --git a/src/pocketmine/network/protocol/LoginPacket.php b/src/pocketmine/network/protocol/LoginPacket.php index 5608ac993..921b7ef03 100644 --- a/src/pocketmine/network/protocol/LoginPacket.php +++ b/src/pocketmine/network/protocol/LoginPacket.php @@ -52,8 +52,8 @@ class LoginPacket extends DataPacket{ $this->serverAddress = $this->getString(); $this->clientSecret = $this->getString(); - $this->getByte(); // TODO: skin transparency, experimental or not? $this->slim = $this->getByte() > 0; + $this->getByte(); // TODO: skin transparency, experimental or not? $this->skin = $this->getString(); } diff --git a/src/pocketmine/network/protocol/PlayerListPacket.php b/src/pocketmine/network/protocol/PlayerListPacket.php index 9f9658b4a..4ec5e4476 100644 --- a/src/pocketmine/network/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/protocol/PlayerListPacket.php @@ -53,8 +53,8 @@ class PlayerListPacket extends DataPacket{ $this->putUUID($d[0]); $this->putLong($d[1]); $this->putString($d[2]); - $this->putByte(0); // TODO: skin transparency, experimental or not? $this->putByte($d[3] ? 1 : 0); + $this->putByte(0); // TODO: skin transparency, experimental or not? $this->putString($d[4]); }else{ $this->putUUID($d[0]); diff --git a/src/pocketmine/network/protocol/SetPlayerGameTypePacket.php b/src/pocketmine/network/protocol/SetPlayerGameTypePacket.php new file mode 100644 index 000000000..46e0ad72e --- /dev/null +++ b/src/pocketmine/network/protocol/SetPlayerGameTypePacket.php @@ -0,0 +1,41 @@ + + + +class SetPlayerGameTypePacket extends DataPacket{ + const NETWORK_ID = Info::SET_PLAYER_GAMETYPE_PACKET; + + public $gamemode; + + public function decode(){ + + } + + public function encode(){ + $this->reset(); + $this->putInt($this->gamemode); + } + +} From 2ddc4455c50c050dce6e9c43f1436cc648c5f39c Mon Sep 17 00:00:00 2001 From: Intyre Date: Sun, 29 Nov 2015 01:46:35 +0100 Subject: [PATCH 31/36] Added some blocks and items --- src/pocketmine/block/Block.php | 17 ++- src/pocketmine/block/BrewingStand.php | 46 +++++++ src/pocketmine/block/FlowerPot.php | 38 ++++++ src/pocketmine/block/IronTrapdoor.php | 156 ++++++++++++++++++++++ src/pocketmine/block/PackedIce.php | 47 +++++++ src/pocketmine/block/TrappedChest.php | 181 ++++++++++++++++++++++++++ src/pocketmine/item/FishingRod.php | 30 +++++ src/pocketmine/item/FlowerPot.php | 31 +++++ src/pocketmine/item/Item.php | 28 ++-- 9 files changed, 555 insertions(+), 19 deletions(-) create mode 100644 src/pocketmine/block/BrewingStand.php create mode 100644 src/pocketmine/block/FlowerPot.php create mode 100644 src/pocketmine/block/IronTrapdoor.php create mode 100644 src/pocketmine/block/PackedIce.php create mode 100644 src/pocketmine/block/TrappedChest.php create mode 100644 src/pocketmine/item/FishingRod.php create mode 100644 src/pocketmine/item/FlowerPot.php diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index a1f574598..2bfc61b7d 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -187,7 +187,7 @@ class Block extends Position implements Metadatable{ const ENCHANTING_TABLE = 116; const ENCHANT_TABLE = 116; const ENCHANTMENT_TABLE = 116; - + const BREWING_STAND = 117; const END_PORTAL_FRAME = 120; const END_STONE = 121; @@ -205,11 +205,12 @@ class Block extends Position implements Metadatable{ const COBBLE_WALL = 139; const STONE_WALL = 139; const COBBLESTONE_WALL = 139; - + const FLOWER_POT_BLOCK = 140; const CARROT_BLOCK = 141; const POTATO_BLOCK = 142; const ANVIL = 145; + const TRAPPED_CHEST = 146; const REDSTONE_BLOCK = 152; @@ -236,11 +237,12 @@ class Block extends Position implements Metadatable{ const DARK_OAK_WOOD_STAIRS = 164; const DARK_OAK_WOODEN_STAIRS = 164; + const IRON_TRAPDOOR = 167; const HAY_BALE = 170; const CARPET = 171; const HARDENED_CLAY = 172; const COAL_BLOCK = 173; - + const PACKED_ICE = 174; const DOUBLE_PLANT = 175; const FENCE_GATE_SPRUCE = 183; @@ -416,7 +418,7 @@ class Block extends Position implements Metadatable{ self::$list[self::NETHER_BRICKS_STAIRS] = NetherBrickStairs::class; self::$list[self::ENCHANTING_TABLE] = EnchantingTable::class; - + self::$list[self::BREWING_STAND] = BrewingStand::class; self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class; self::$list[self::END_STONE] = EndStone::class; self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class; @@ -427,11 +429,11 @@ class Block extends Position implements Metadatable{ 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::FLOWER_POT_BLOCK] = FlowerPot::class; self::$list[self::CARROT_BLOCK] = Carrot::class; self::$list[self::POTATO_BLOCK] = Potato::class; self::$list[self::ANVIL] = Anvil::class; - + self::$list[self::TRAPPED_CHEST] = TrappedChest::class; self::$list[self::REDSTONE_BLOCK] = Redstone::class; self::$list[self::QUARTZ_BLOCK] = Quartz::class; @@ -445,11 +447,12 @@ class Block extends Position implements Metadatable{ self::$list[self::ACACIA_WOOD_STAIRS] = AcaciaWoodStairs::class; self::$list[self::DARK_OAK_WOOD_STAIRS] = DarkOakWoodStairs::class; + self::$list[self::IRON_TRAPDOOR] = IronTrapdoor::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::PACKED_ICE] = PackedIce::class; self::$list[self::DOUBLE_PLANT] = DoublePlant::class; self::$list[self::FENCE_GATE_SPRUCE] = FenceGateSpruce::class; diff --git a/src/pocketmine/block/BrewingStand.php b/src/pocketmine/block/BrewingStand.php new file mode 100644 index 000000000..e0e7aaa9a --- /dev/null +++ b/src/pocketmine/block/BrewingStand.php @@ -0,0 +1,46 @@ +meta = $meta; + } + + public function getName(){ + return "Flower Pot Block"; + } + +} \ No newline at end of file diff --git a/src/pocketmine/block/IronTrapdoor.php b/src/pocketmine/block/IronTrapdoor.php new file mode 100644 index 000000000..b23d2a225 --- /dev/null +++ b/src/pocketmine/block/IronTrapdoor.php @@ -0,0 +1,156 @@ +meta = $meta; + } + + public function getName(){ + return "Iron Trapdoor"; + } + + public function getHardness(){ + return 5; + } + + public function canBeActivated(){ + return true; + } + + protected function recalculateBoundingBox(){ + + $damage = $this->getDamage(); + + $f = 0.1875; + + if(($damage & 0x08) > 0){ + $bb = new AxisAlignedBB( + $this->x, + $this->y + 1 - $f, + $this->z, + $this->x + 1, + $this->y + 1, + $this->z + 1 + ); + }else{ + $bb = new AxisAlignedBB( + $this->x, + $this->y, + $this->z, + $this->x + 1, + $this->y + $f, + $this->z + 1 + ); + } + + if(($damage & 0x04) > 0){ + if(($damage & 0x03) === 0){ + $bb->setBounds( + $this->x, + $this->y, + $this->z + 1 - $f, + $this->x + 1, + $this->y + 1, + $this->z + 1 + ); + }elseif(($damage & 0x03) === 1){ + $bb->setBounds( + $this->x, + $this->y, + $this->z, + $this->x + 1, + $this->y + 1, + $this->z + $f + ); + } + if(($damage & 0x03) === 2){ + $bb->setBounds( + $this->x + 1 - $f, + $this->y, + $this->z, + $this->x + 1, + $this->y + 1, + $this->z + 1 + ); + } + if(($damage & 0x03) === 3){ + $bb->setBounds( + $this->x, + $this->y, + $this->z, + $this->x + $f, + $this->y + 1, + $this->z + 1 + ); + } + } + + return $bb; + } + + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ + if(($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1){ + $faces = [ + 2 => 0, + 3 => 1, + 4 => 2, + 5 => 3, + ]; + $this->meta = $faces[$face] & 0x03; + if($fy > 0.5){ + $this->meta |= 0x08; + } + $this->getLevel()->setBlock($block, $this, true, true); + + return true; + } + + return false; + } + + public function getDrops(Item $item){ + return [ + [$this->id, 0, 1], + ]; + } + + public function onActivate(Item $item, Player $player = null){ + $this->meta ^= 0x04; + $this->getLevel()->setBlock($this, $this, true); + $this->level->addSound(new DoorSound($this)); + return true; + } + + public function getToolType(){ + return Tool::TYPE_PICKAXE; + } +} \ No newline at end of file diff --git a/src/pocketmine/block/PackedIce.php b/src/pocketmine/block/PackedIce.php new file mode 100644 index 000000000..8d9e30a9d --- /dev/null +++ b/src/pocketmine/block/PackedIce.php @@ -0,0 +1,47 @@ +meta = $meta; + } + + public function canBeActivated(){ + return true; + } + + public function getHardness(){ + return 2.5; + } + + public function getName(){ + return "Trapped Chest"; + } + + public function getToolType(){ + return Tool::TYPE_AXE; + } + + protected function recalculateBoundingBox(){ + return new AxisAlignedBB( + $this->x + 0.0625, + $this->y, + $this->z + 0.0625, + $this->x + 0.9375, + $this->y + 0.9475, + $this->z + 0.9375 + ); + } + + public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ + $faces = [ + 0 => 4, + 1 => 2, + 2 => 5, + 3 => 3, + ]; + + $chest = null; + $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; + + for($side = 2; $side <= 5; ++$side){ + if(($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)){ + continue; + }elseif(($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)){ + continue; + } + $c = $this->getSide($side); + if($c instanceof Chest and $c->getDamage() === $this->meta){ + $tile = $this->getLevel()->getTile($c); + if($tile instanceof TileChest and !$tile->isPaired()){ + $chest = $tile; + break; + } + } + } + + $this->getLevel()->setBlock($block, $this, true, true); + $nbt = new Compound("", [ + new Enum("Items", []), + new String("id", Tile::CHEST), + new Int("x", $this->x), + new Int("y", $this->y), + new Int("z", $this->z) + ]); + $nbt->Items->setTagType(NBT::TAG_Compound); + + if($item->hasCustomName()){ + $nbt->CustomName = new String("CustomName", $item->getCustomName()); + } + + if($item->hasCustomBlockData()){ + foreach($item->getCustomBlockData() as $key => $v){ + $nbt->{$key} = $v; + } + } + + $tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); + + if($chest instanceof TileChest and $tile instanceof TileChest){ + $chest->pairWith($tile); + $tile->pairWith($chest); + } + + return true; + } + + public function onBreak(Item $item){ + $t = $this->getLevel()->getTile($this); + if($t instanceof TileChest){ + $t->unpair(); + } + $this->getLevel()->setBlock($this, new Air(), true, true); + + return true; + } + + public function onActivate(Item $item, Player $player = null){ + if($player instanceof Player){ + $top = $this->getSide(1); + if($top->isTransparent() !== true){ + return true; + } + + $t = $this->getLevel()->getTile($this); + $chest = null; + if($t instanceof TileChest){ + $chest = $t; + }else{ + $nbt = new Compound("", [ + new Enum("Items", []), + new String("id", Tile::CHEST), + new Int("x", $this->x), + new Int("y", $this->y), + new Int("z", $this->z) + ]); + $nbt->Items->setTagType(NBT::TAG_Compound); + $chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); + } + + if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String){ + if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){ + return true; + } + } + + if($player->isCreative()){ + return true; + } + $player->addWindow($chest->getInventory()); + } + + return true; + } + + public function getDrops(Item $item){ + return [ + [$this->id, 0, 1], + ]; + } +} \ No newline at end of file diff --git a/src/pocketmine/item/FishingRod.php b/src/pocketmine/item/FishingRod.php new file mode 100644 index 000000000..26df171fc --- /dev/null +++ b/src/pocketmine/item/FishingRod.php @@ -0,0 +1,30 @@ +block = Block::get(Item::FLOWER_POT_BLOCK); + parent::__construct(self::FLOWER_POT, 0, $count, "Flower Pot"); + } +} \ No newline at end of file diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index c8a7b44fa..659a76a83 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -216,7 +216,7 @@ class Item{ const ENCHANTING_TABLE = 116; const ENCHANT_TABLE = 116; const ENCHANTMENT_TABLE = 116; - + const BREWING_STAND = 117; const END_PORTAL = 120; const END_STONE = 121; @@ -234,11 +234,12 @@ class Item{ const COBBLE_WALL = 139; const STONE_WALL = 139; const COBBLESTONE_WALL = 139; - + const FLOWER_POT_BLOCK = 140; const CARROT_BLOCK = 141; const POTATO_BLOCK = 142; const ANVIL = 145; + const TRAPPED_CHEST = 146; const REDSTONE_BLOCK = 152; @@ -265,11 +266,12 @@ class Item{ const DARK_OAK_WOOD_STAIRS = 164; const DARK_OAK_WOODEN_STAIRS = 164; + const IRON_TRAPDOOR = 167; const HAY_BALE = 170; const CARPET = 171; const HARDENED_CLAY = 172; const COAL_BLOCK = 173; - + const PACKED_ICE = 174; const DOUBLE_PLANT = 175; const FENCE_GATE_SPRUCE = 183; @@ -387,7 +389,7 @@ class Item{ const EGG = 344; const COMPASS = 345; - + const FISHING_ROD = 346; const CLOCK = 347; const GLOWSTONE_DUST = 348; const RAW_FISH = 349; @@ -421,6 +423,7 @@ class Item{ const EMERALD = 388; + const FLOWER_POT = 390; const CARROT = 391; const CARROTS = 391; const POTATO = 392; @@ -563,6 +566,7 @@ class Item{ self::$list[self::GOLD_NUGGET] = GoldNugget::class; self::$list[self::SPAWN_EGG] = SpawnEgg::class; self::$list[self::EMERALD] = Emerald::class; + self::$list[self::FLOWER_POT] = FlowerPot::class; self::$list[self::CARROT] = Carrot::class; self::$list[self::POTATO] = Potato::class; self::$list[self::BAKED_POTATO] = BakedPotato::class; @@ -673,7 +677,7 @@ class Item{ self::addCreativeItem(Item::get(Item::SLAB, 4)); self::addCreativeItem(Item::get(Item::SLAB, 5)); self::addCreativeItem(Item::get(Item::SLAB, 6)); - // TODO: Nether brick slab + self::addCreativeItem(Item::get(Item::SLAB, 7)); self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 0)); self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 1)); self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 2)); @@ -686,7 +690,7 @@ class Item{ self::addCreativeItem(Item::get(Item::EMERALD_ORE, 0)); self::addCreativeItem(Item::get(Item::OBSIDIAN, 0)); self::addCreativeItem(Item::get(Item::ICE, 0)); - // TODO: Packed ice + self::addCreativeItem(Item::get(Item::PACKED_ICE, 0)); self::addCreativeItem(Item::get(Item::SNOW_BLOCK, 0)); self::addCreativeItem(Item::get(Item::END_STONE, 0)); @@ -714,9 +718,9 @@ class Item{ self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 3)); // Jungle self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 4)); // Acacia self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 5)); // Dark oak - // TODO: Iron door + self::addCreativeItem(Item::get(Item::IRON_DOOR, 0)); self::addCreativeItem(Item::get(Item::TRAPDOOR, 0)); - // TODO: Iron trapdoor + self::addCreativeItem(Item::get(Item::IRON_TRAPDOOR, 0)); 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)); @@ -737,9 +741,9 @@ class Item{ self::addCreativeItem(Item::get(Item::WORKBENCH, 0)); self::addCreativeItem(Item::get(Item::STONECUTTER, 0)); self::addCreativeItem(Item::get(Item::CHEST, 0)); - // TODO: Trapped chest + self::addCreativeItem(Item::get(Item::TRAPPED_CHEST, 0)); self::addCreativeItem(Item::get(Item::FURNACE, 0)); - // TODO: Brewing stand + self::addCreativeItem(Item::get(Item::BREWING_STAND, 0)); // TODO: Note Block self::addCreativeItem(Item::get(Item::END_PORTAL, 0)); self::addCreativeItem(Item::get(Item::ANVIL, 0)); @@ -795,7 +799,7 @@ class Item{ // TODO: Head // TODO: Creeper head self::addCreativeItem(Item::get(Item::SIGN, 0)); - // TODO: flower pot + self::addCreativeItem(Item::get(Item::FLOWER_POT, 0)); self::addCreativeItem(Item::get(Item::MONSTER_SPAWNER, 0)); self::addCreativeItem(Item::get(Item::ENCHANTMENT_TABLE, 0)); self::addCreativeItem(Item::get(Item::WOOL, 0)); @@ -844,7 +848,7 @@ class Item{ self::addCreativeItem(Item::get(Item::TNT, 0)); self::addCreativeItem(Item::get(Item::REDSTONE, 0)); self::addCreativeItem(Item::get(Item::BOW, 0)); - // TODO: fishing rod + self::addCreativeItem(Item::get(Item::FISHING_ROD, 0)); self::addCreativeItem(Item::get(Item::FLINT_AND_STEEL, 0)); self::addCreativeItem(Item::get(Item::SHEARS, 0)); self::addCreativeItem(Item::get(Item::CLOCK, 0)); From 7954754d4c35e66d20f9274a8d7c3b3a696a0889 Mon Sep 17 00:00:00 2001 From: Creeperface01 Date: Fri, 4 Dec 2015 16:00:02 +0100 Subject: [PATCH 32/36] Update Cake.php --- src/pocketmine/block/Cake.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pocketmine/block/Cake.php b/src/pocketmine/block/Cake.php index 7f0187f51..d95b64a7c 100644 --- a/src/pocketmine/block/Cake.php +++ b/src/pocketmine/block/Cake.php @@ -96,16 +96,18 @@ class Cake extends Transparent{ $ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING); $player->heal($ev->getAmount(), $ev); - if($this->meta >= 0x06){ - $this->getLevel()->setBlock($this, new Air(), true); - }else{ - $this->getLevel()->setBlock($this, $this, true); + if(!$ev->isCancelled()){ + if($this->meta >= 0x06){ + $this->getLevel()->setBlock($this, new Air(), true); + }else{ + $this->getLevel()->setBlock($this, $this, true); + } + + return true; } - - return true; } return false; } -} \ No newline at end of file +} From 90c3e66e6b87ad8763669850d70c108f364dcaa2 Mon Sep 17 00:00:00 2001 From: Intyre Date: Wed, 16 Dec 2015 14:37:46 +0100 Subject: [PATCH 33/36] Updated for .13.1. skinName replaces isSlim, API bump --- src/pocketmine/Player.php | 10 +++++----- src/pocketmine/PocketMine.php | 6 +++--- src/pocketmine/Server.php | 8 ++++---- src/pocketmine/entity/Human.php | 18 +++++++++--------- .../network/protocol/LoginPacket.php | 5 ++--- .../network/protocol/PlayerListPacket.php | 3 +-- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 330f06ca6..f1985bc04 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -571,14 +571,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade public function setDisplayName($name){ $this->displayName = $name; if($this->spawned){ - $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getDisplayName(), $this->isSkinSlim(), $this->getSkinData()); + $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getDisplayName(), $this->getSkinName(), $this->getSkinData()); } } - public function setSkin($str, $isSlim = false){ - parent::setSkin($str, $isSlim); + public function setSkin($str, $skinName){ + parent::setSkin($str, $skinName); if($this->spawned){ - $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getDisplayName(), $isSlim, $str); + $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getDisplayName(), $skinName, $str); } } @@ -1856,7 +1856,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade break; } - $this->setSkin($packet->skin, $packet->slim); + $this->setSkin($packet->skin, $packet->skinName); $this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason")); if($ev->isCancelled()){ diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index b284c885f..a4facf3dc 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -73,10 +73,10 @@ namespace pocketmine { use pocketmine\wizard\Installer; const VERSION = "1.6dev"; - const API_VERSION = "1.13.0"; + const API_VERSION = "1.13.1"; const CODENAME = "[REDACTED]"; - const MINECRAFT_VERSION = "v0.13.0 alpha"; - const MINECRAFT_VERSION_NETWORK = "0.13.0"; + const MINECRAFT_VERSION = "v0.13.1 alpha"; + const MINECRAFT_VERSION_NETWORK = "0.13.1"; /* * Startup code. Do not look at it, it may harm you. diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index a41e1b039..93452e7c4 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -2248,7 +2248,7 @@ class Server{ public function addOnlinePlayer(Player $player){ $this->playerList[$player->getRawUniqueId()] = $player; - $this->updatePlayerListData($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->isSkinSlim(), $player->getSkinData()); + $this->updatePlayerListData($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinName(), $player->getSkinData()); } public function removeOnlinePlayer(Player $player){ @@ -2262,10 +2262,10 @@ class Server{ } } - public function updatePlayerListData(UUID $uuid, $entityId, $name, $isSlim, $skinData, array $players = null){ + public function updatePlayerListData(UUID $uuid, $entityId, $name, $skinName, $skinData, array $players = null){ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; - $pk->entries[] = [$uuid, $entityId, $name, $isSlim, $skinData]; + $pk->entries[] = [$uuid, $entityId, $name, $skinName, $skinData]; Server::broadcastPacket($players === null ? $this->playerList : $players, $pk); } @@ -2280,7 +2280,7 @@ class Server{ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; foreach($this->playerList as $player){ - $pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->isSkinSlim(), $player->getSkinData()]; + $pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinName(), $player->getSkinData()]; } $p->dataPacket($pk); diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 34e15f785..08ccaba28 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -57,15 +57,15 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ public $height = 1.8; public $eyeHeight = 1.62; + protected $skinName; protected $skin; - protected $isSlim = false; public function getSkinData(){ return $this->skin; } - public function isSkinSlim(){ - return $this->isSlim; + public function getSkinName(){ + return $this->skinName; } /** @@ -84,11 +84,11 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ /** * @param string $str - * @param bool $isSlim + * @param string $skinName */ - public function setSkin($str, $isSlim = false){ + public function setSkin($str, $skinName){ $this->skin = $str; - $this->isSlim = (bool) $isSlim; + $this->skinName = $skinName; } public function getInventory(){ @@ -112,7 +112,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ } if(isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof Compound){ - $this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Slim"] > 0); + $this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Name"]); } $this->uuid = UUID::fromData($this->getId(), $this->getSkinData(), $this->getNameTag()); @@ -195,7 +195,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ if(strlen($this->getSkinData()) > 0){ $this->namedtag->Skin = new Compound("Skin", [ "Data" => new String("Data", $this->getSkinData()), - "Slim" => new Byte("Slim", $this->isSkinSlim() ? 1 : 0) + "Name" => new String("Name", $this->getSkinName()) ]); } } @@ -210,7 +210,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ if(!($this instanceof Player)){ - $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $this->isSlim, $this->skin, [$player]); + $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $this->skinName, $this->skin, [$player]); } $pk = new AddPlayerPacket(); diff --git a/src/pocketmine/network/protocol/LoginPacket.php b/src/pocketmine/network/protocol/LoginPacket.php index 921b7ef03..6b8079f19 100644 --- a/src/pocketmine/network/protocol/LoginPacket.php +++ b/src/pocketmine/network/protocol/LoginPacket.php @@ -36,7 +36,7 @@ class LoginPacket extends DataPacket{ public $serverAddress; public $clientSecret; - public $slim = false; + public $skinName; public $skin = null; public function decode(){ @@ -52,8 +52,7 @@ class LoginPacket extends DataPacket{ $this->serverAddress = $this->getString(); $this->clientSecret = $this->getString(); - $this->slim = $this->getByte() > 0; - $this->getByte(); // TODO: skin transparency, experimental or not? + $this->skinName = $this->getString(); $this->skin = $this->getString(); } diff --git a/src/pocketmine/network/protocol/PlayerListPacket.php b/src/pocketmine/network/protocol/PlayerListPacket.php index 4ec5e4476..c9f65a664 100644 --- a/src/pocketmine/network/protocol/PlayerListPacket.php +++ b/src/pocketmine/network/protocol/PlayerListPacket.php @@ -53,8 +53,7 @@ class PlayerListPacket extends DataPacket{ $this->putUUID($d[0]); $this->putLong($d[1]); $this->putString($d[2]); - $this->putByte($d[3] ? 1 : 0); - $this->putByte(0); // TODO: skin transparency, experimental or not? + $this->putString($d[3]); $this->putString($d[4]); }else{ $this->putUUID($d[0]); From c1a484ee5cb8705f03e5021a64fe824796dfee14 Mon Sep 17 00:00:00 2001 From: Intyre Date: Sat, 19 Dec 2015 23:58:05 +0100 Subject: [PATCH 34/36] fixed #3702 and fix for setting timezone from php.ini --- src/pocketmine/Player.php | 12 ++++++++++-- src/pocketmine/PocketMine.php | 8 +++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index f1985bc04..acd3d5de6 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -3375,9 +3375,16 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return true; } + /** + * @param Vector3|Position|Location $pos + * @param float $yaw + * @param float $pitch + * + * @return bool + */ public function teleport(Vector3 $pos, $yaw = null, $pitch = null){ if(!$this->isOnline()){ - return; + return false; } $oldPos = $this->getPosition(); @@ -3398,11 +3405,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->spawnToAll(); } - $this->resetFallDistance(); $this->nextChunkOrderRun = 0; $this->newPosition = null; + return true; } + return false; } /** diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index a4facf3dc..f5e70a574 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -164,11 +164,13 @@ namespace pocketmine { * This is here so that people don't come to us complaining and fill up the issue tracker when they put * an incorrect timezone abbreviation in php.ini apparently. */ - $default_timezone = date_default_timezone_get(); - if(strpos($default_timezone, "/") === false){ - $default_timezone = timezone_name_from_abbr($default_timezone); + $timezone = ini_get("date.timezone"); + if(strpos($timezone, "/") === false){ + $default_timezone = timezone_name_from_abbr($timezone); ini_set("date.timezone", $default_timezone); date_default_timezone_set($default_timezone); + } else { + date_default_timezone_set($timezone); } } From 78525e1f74e01d8c0cc3f8f41648404c6a6423a5 Mon Sep 17 00:00:00 2001 From: Intyre Date: Tue, 22 Dec 2015 21:26:26 +0100 Subject: [PATCH 35/36] Seperated kick/ban messages --- src/pocketmine/Player.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 6b41f5be6..b2a0f3f82 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2909,7 +2909,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, $this->getLeaveMessage())); if(!$ev->isCancelled()){ if($isAdmin){ - $message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : ""); + if(!$this->isBanned()) { + $message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : ""); + }else{ + $message = $reason; + } }else{ if($reason === ""){ $message = "disconnectionScreen.noReason"; From 0b42ead2ab3bd718a1e4df41b0997a52547e7f7b Mon Sep 17 00:00:00 2001 From: markkrueg Date: Sun, 27 Dec 2015 12:44:56 -0800 Subject: [PATCH 36/36] Update Stair.php to add use pocketmine\item\Tool; Without this >= Tool::TIER_WOODEN does not work; so stone stairs do not give drops when broken. They also revert to not being broken on next connection. --- src/pocketmine/block/Stair.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/block/Stair.php b/src/pocketmine/block/Stair.php index 7416b6fd6..8e5b30f8a 100644 --- a/src/pocketmine/block/Stair.php +++ b/src/pocketmine/block/Stair.php @@ -22,6 +22,7 @@ namespace pocketmine\block; use pocketmine\item\Item; +use pocketmine\item\Tool; use pocketmine\math\AxisAlignedBB; use pocketmine\Player; @@ -151,4 +152,4 @@ abstract class Stair extends Transparent{ return []; } } -} \ No newline at end of file +}