I'm trying to define a custom recipe, but when I go to use it, nothing happens! I have the right name for the book to. PHP: public function registerRecipe() { //TEST $name = "TEST"; $this->getServer()->getCraftingManager()->registerRecipe((new ShapedRecipe(Item::get(Item::DIAMOND_BOOTS, 0, 1)->setCustomName("§r§4test"), "AAA", "APA", "AGA"))->setIngredient("G", Item::get(Item::BOOK, 0, 1)->getCustomName($name))->setIngredient("P", Item::get(Item::APPLE, 0, 1))->setIngredient("A", Item::get(Item::AIR, 0, 1))); }} Code:
Full code! So basically I'm not getting errors but the recipe dont work either, any idea? PHP: <?phpnamespace CustomItemsEnchantments;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 Loader extends PluginBase implements Listener,CommandExecutor{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getPluginManager()->registerEvents(new ZaRocDamageEvent($this), $this); $this->getServer()->getPluginManager()->registerEvents(new Commands($this), $this); $this->getServer()->getPluginManager()->registerEvents(new WizardsStaff($this), $this); $this->getServer()->getPluginManager()->registerEvents(new BookOfKnowledge($this), $this); $this->getServer()->getPluginManager()->registerEvents(new Combiner($this), $this); $this->getCommand("test")->setExecutor(new Commands($this)); $this->getCommand("buy_zaroc")->setExecutor(new Commands($this)); $this->getCommand("buy_wizards_staff")->setExecutor(new Commands($this)); $this->getCommand("buy_ball_of_energy")->setExecutor(new Commands($this)); $this->getCommand("ce")->setExecutor(new Commands($this)); $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 registerRecipes(Item $item){$item = Item::get(310, 0, 1);$item->setCustomName("§8Obsidian Helmet");$item->addEnchantment(Enchantment::getEnchantment(0)->setLevel(10)); $this->getServer()->getCraftingManager()->registerRecipe((new BigShapedRecipe($item, "XXX", "XYX", "YYY" ))->addIngredient("X", Item::get(Item::OBSIDIAN, 0, 5))->addIngredient("Y", Item::get(Item::AIR, 0, 2)));$item = Item::get(311, 0, 1);$item->setCustomName("§8Obsidian Chestplate");$item->addEnchantment(Enchantment::getEnchantment(0)->setLevel(10)); $this->getServer()->getCraftingManager()->registerRecipe((new BigShapedRecipe($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);$item->setCustomName("§8Obsidian Leggings");$item->addEnchantment(Enchantment::getEnchantment(0)->setLevel(10)); $this->getServer()->getCraftingManager()->registerRecipe((new BigShapedRecipe($item, "XXX", "XYX", "XYX" ))->addIngredient("X", Item::get(Item::OBSIDIAN, 0, 5))->addIngredient("Y", Item::get(Item::AIR, 0, 2)));$item = Item::get(313, 0, 1);$item->setCustomName("§8Obsidian Boots");$item->addEnchantment(Enchantment::getEnchantment(0)->setLevel(10)); $this->getServer()->getCraftingManager()->registerRecipe((new BigShapedRecipe($item, "YYY", "XYX", "XYX" ))->addIngredient("X", Item::get(Item::OBSIDIAN, 0, 5))->addIngredient("Y", Item::get(Item::AIR, 0, 2)));$item = Item::get(276, 0, 1);$item->setCustomName("§8Obsidian Sword");$item->addEnchantment(Enchantment::getEnchantment(9)->setLevel(5)); $this->getServer()->getCraftingManager()->registerRecipe((new BigShapedRecipe($item, "GXG", "GXG", "GYG" ))->addIngredient("X", Item::get(Item::OBSIDIAN, 0, 5))->addIngredient("G", Item::get(Item::AIR, 0, 5))->addIngredient("Y", Item::get(Item:: STICK, 0, 2))); }}
PHP: public function onJoin(PlayerJoinEvent $event){ $this->getServer()->sendRecipeList($event->getPlayer());} try that
Actually, PluginBase implements Plugin extends CommandExecutor. Yo udon't need to explicitly implement CommandExecutor.
Change PHP: public function registerRecipes(Item $item) { to PHP: public function registerRecipes() { And add PHP: $this->registerRecipes(); to the onEnable() function.
"Argument 3 passed to pocketmine\inventory\ShapedRecipe::addIngredient() must be an instance of pocketmine\item\Item, none given, called in C:\Users\Conner\Documents\OFFICIAL-PM\plugins\CustomItemsEnchantments\src\ArchonEnchants\Loader.php on line 42" (EXCEPTION) in "/src/pocketmine/inventory/ShapedRecipe" at line 85
The error is the a debugging tool for developer of beginner or advance learn to read it, master to read it, it WILL help you in the long run i will help you with this time: (Error) called in (location) on line (line) error(what's wrong and why) = Argument 3 passed to pocketmine\inventory\ShapedRecipe::addIngredient() must be an instance of pocketmine\item\Item, none given location(PHP is trying to tell you where that error occured) = ...\ArchonEnchants\Loader.php line(Which Line of that file) = 42 meaning you try to pass something that is NOT instance of Item in this case it is nothing into addIngredient() on the 3rd argument and the error occurred on Loader.php line 42 see how much i can tell you just by looking at the error?, without asking you for your code? next time try that yourself
to say it in a very simple way you forget to give an instance of item to pocketmine\inventory\ShapedRecipe::addIngredient()
Maybe point out the line that has the error first? You should read your error message before asking so that you know what information to give.
ShapedRecipe::addIngredient($argument1, $argument2, $argument3, etc...); this mean argument3 needs to be instanceof pocketmine\item\Item, find what argument 3 in line 85 is, and fix it. Reading the problem is that simple