!  KingHELP
! KingHELP
FFilament
Created by ! KingHELP on 2/3/2024 in #❓┊help
Custom Crafts Plugin help
private function registerRecipe($id, $name, $pattern, $ingredients, $enchantmentLevel = 0) { $item = Item::get($id, 0, 1); $item->setCustomName("§r§aEmerald " . $name); $item->addEnchantment(Enchantment::getEnchantment(0)->setLevel($enchantmentLevel)); $craftingRecipe = new BigShapedRecipe($item, ...$pattern); foreach ($ingredients as $ingredient => $ingredientItem) { $craftingRecipe->setIngredient($ingredient, Item::get(...$ingredientItem)); } $this->getServer()->getCraftingManager()->registerRecipe($craftingRecipe); } public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool { // Handle your commands here if needed return true; } }
5 replies
FFilament
Created by ! KingHELP on 2/3/2024 in #❓┊help
Custom Crafts Plugin help
<?php namespace customcrafts; use pocketmine\command\CommandSender; use pocketmine\command\Command; use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; use pocketmine\inventory\BigShapedRecipe; use pocketmine\item\enchantment\Enchantment; use pocketmine\item\Item; use pocketmine\utils\Config; class CustomCrafts extends PluginBase implements Listener { public function onEnable() { $this->saveDefaultConfig(); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->registerRecipes(); } public function registerRecipes() { $config = $this->getConfig()->getAll(); if (isset($config['recipes']['armor'])) { $this->registerRecipeGroup($config['recipes']['armor']); } if (isset($config['recipes']['weapons'])) { $this->registerRecipeGroup($config['recipes']['weapons']); } if (isset($config['recipes']['tools'])) { $this->registerRecipeGroup($config['recipes']['tools']); } } private function registerRecipeGroup($recipes) { foreach ($recipes as $recipe) { $id = $recipe['id']; $name = $recipe['name']; $pattern = $recipe['pattern']; $ingredients = $recipe['ingredients']; $enchantment = $recipe['enchantment'] ?? 0; $this->registerRecipe($id, $name, $pattern, $ingredients, $enchantment); } }
5 replies
FFilament
Created by ! KingHELP on 2/3/2024 in #❓┊help
Custom Crafts Plugin help
Im trying to create a MCPE plugin for custom crafting but i cant figure out the probem why it doesnt work , here is my code
5 replies