1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Custom Craft Error

Discussion in 'Help' started by BattleAlan, Mar 8, 2019.

  1. BattleAlan

    BattleAlan Spider

    Messages:
    13
    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);
        }
    }
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
        public function onEnable(){
            
    $this->registerRecipe();
            
    $this->getLogger()->info(TextFormat::GREEN."CustomItemsRewrite Enabled!");
        }
    The registerRecipe() function does not run.
     
  3. BattleAlan

    BattleAlan Spider

    Messages:
    13
    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" (EXCEPTIONin "src/pocketmine/inventory/ShapedRecipe" at line 63
    Here the code
    PHP:
        public function registerRecipe(){
            
    $item Item::get(31101);
            
    $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);
        }
    }
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
  5. BattleAlan

    BattleAlan Spider

    Messages:
    13
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.