I created craft custom but the problem is that I would like to remove crafts to avoid that for example a sword can be crafter with a bousolle
I'm confused. You want to create a custom crafting recipe right? Are you saying that you'd like to remove one you've already made, or to delete a default one so yours replaces it?
Does works help me please :/ PHP: <?phpnamespace dellitem;use pocketmine\Server;use pocketmine\event\Cancellable;use pocketmine\event\CancellableTrait;use pocketmine\event\Event;use pocketmine\inventory\CraftingRecipe;use pocketmine\inventory\transaction\CraftingTransaction;use pocketmine\item\Item;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\entity\EffectInstance;use pocketmine\event\Listener;use pocketmine\level\Position;use pocketmine\event\player\PlayerInteractEvent;class Main extends PluginBase{ public function onEnable(){ $this->getLogger()->info("§1[Blutonia]§r DellItem Loading... ━━━━━━M━━A━━T━━R━━O━━X━━P━━L━━A━━Y━━━━━━"); } public function onDisable(){ $this->getLogger()->info("§1[Blutonia]§r DellItem Loading... ━━━━━━M━━A━━T━━R━━O━━X━━P━━L━━A━━Y━━━━━━"); } public function OnCraftEvent(CraftItemEvent $event){ if($event->getRecipe()->getResult()->getId() === Item::BED){ $event->setCancelled(); } }}
You forgot to register events PHP: class Main extends PluginBase implements Listener{ PHP: public function onEnable(){$this->getServer()->getPluginManager()->registerEvents($this,$this);}
PHP: public function onCraftEvent(CraftItemEvent $event){ foreach($event->getRecipe()->getResults() as $results) if($results->getId() === Item::BONE){ $event->setCancelled(); } if($results->getId() === Item::BLAZE_ROD){ $event->setCancelled(); break; } } I have a problem with "onCraftEvent"
Please specify the problem. Is the server crashing? Is your computer exploding? Did the code become self aware?? You have to specify because I don't think we can deal with a terminator right now
My full code PHP: public function OnCraftEvent(CraftItemEvent $event){ foreach($event->getRecipe()->getResults() as $result) if($result->getId() === Item::SEALANTERN or $result->getId() === Item::MAGMA or $result->getId() === Item::PRISMARINE or $result->getId() === Item::DYE or $result->getId() === Item::END_ROD or $result->getId() === Item::IRON_TRAPDOOR or $result->getId() === Item::END_ROD or $result->getId() === Item::BLAZE_POWDER or $result->getId() === Item::BREWING_STAND){ $event->setCancelled(); $event->getPlayer()->sendTip("§4Cette item n'est pas disponible !!"); if ($result->getId() === 167 && $result->getCustomName() == "§lHidenTrap") { $event->setCancelled(false); $event->getPlayer()->sendTip(" "); }