mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Update of the stonecutter recipes
Added the shaped recipes and removed the shapeless ones.
This commit is contained in:
parent
a3bce67d35
commit
0b9ef5b856
@ -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(){
|
||||
|
@ -21,6 +21,6 @@
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
class StonecutterShapelessRecipe extends ShapelessRecipe{
|
||||
class StonecutterBigShapedRecipe extends ShapedRecipe{
|
||||
|
||||
}
|
26
src/pocketmine/inventory/StonecutterShapedRecipe.php
Normal file
26
src/pocketmine/inventory/StonecutterShapedRecipe.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
class StonecutterShapedRecipe extends ShapedRecipe{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user