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/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index 381cbaeee..66e8234b5 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; @@ -110,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, 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::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(){ @@ -185,38 +387,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 @@ +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)); } }