Why I cant craft the Obsidian Armor. Code: <?php namespace BattleAlan; use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; use pocketmine\utils\TextFormat; use CustomItemsEnchantments\Commands; use pocketmine\event\entity\EntitySpawnEvent; use pocketmine\command\CommandExecutor; use pocketmine\utils\Config; use pocketmine\command\CommandSender; use pocketmine\command\Command; use pocketmine\inventory\BigShapedRecipe; use pocketmine\inventory\ShapedRecipe; use pocketmine\item\Item; use pocketmine\event\player\PlayerJoinEvent; use pocketmine\item\Emerald; class Main extends PluginBase { public function onEnable(){ $this->getLogger()->info(TextFormat::GREEN."CustomItemsRewrite Enabled!"); } public function onDisable(){ $this->getLogger()->info(TextFormat::RED."CustomItemsRewrite Disabled!"); } public function OnJoin(PlayerJoinEvent $event){ $this->getServer()->sendRecipeList($event->getPlayer()); } public function registerRecipe(){ $item = Item::get(311, 0, 1); $item->setCustomName("§8Obsidian Chestplate"); $item->addEnchantment(Enchantment::getEnchantment(0)->setLevel(10)); $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe($item, "XYX", "XXX", "XXX" ))->addIngredient("X", Item::get(Item::OBSIDIAN, 0, 7))->addIngredient("Y", Item::get(Item::AIR, 0, 2))); $item = Item::get(312, 0, 1); $this->plugin->getServer()->getCraftingManager()->registerRecipe($recipe); } }
PHP: public function onEnable(){ $this->registerRecipe(); $this->getLogger()->info(TextFormat::GREEN."CustomItemsRewrite Enabled!"); } The registerRecipe() function does not run.
I fix something and get this error PHP: [03:22:20] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\inventory\ShapedRecipe::__construct() must be of the type array, object given, called in phar:///home/minecraft/plugins/phar_CustomCraft_ecibrh7KFG7DDqH.phar/src/BattleAlan/Main.php on line 41" (EXCEPTION) in "src/pocketmine/inventory/ShapedRecipe" at line 63 Here the code PHP: public function registerRecipe(){ $item = Item::get(311, 0, 1); $item->setCustomName("§8Obsidian Chestplate"); $item->addEnchantment(new EnchantmentInstance(Enchantment::getEnchantment(0), 4)); $recipe = new ShapedRecipe( $item, ["XYX", "XXX", "XXX"], [ "X" => Item::get(49,0,1), "Y" => Item::get(0,0,1) //line 41 ]); $this->getServer()->getCraftingManager()->registerRecipe($recipe); }}
https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/inventory/ShapedRecipe.php#L63 You have to change $item to an array.