I want to make a custom tnt item,which when you try to place it in ground,it will be ignited automatically and then it will explode like a normal tnt,but I have problems though. Firstly,if I try to place a normal tnt or the automatic tnt I made in the air,an ignited tnt is being spawned. Secondly, if I place again those tnts in ground,it seems that a non ignited tnt is placed and then after some blocks away,an ignited tnt is being spawned and it blows up the with the other tnt. The result I ought to expect,would be after placing the tnt with custom name,(automatic tnt),I should have seen the tnt I just placed being ignited etc. but it didn't happen exactly. PHP: /** * @param BlockPlaceEvent $event */ public function onPlace(BlockPlaceEvent $event) { $player = $event->getPlayer(); $block = $event->getBlock(); $item = $event->getItem(); $hand = $player->getInventory()->getItemInHand(); if($hand->getName() === "§l§6Automatic §eTNT" and $hand->getId() === Block::TNT) { $block->ignite(); $hand->pop(); $player->getInventory()->setItemInHand($hand); $block->getLevel()->setBlock($block, Block::get(Block::AIR)); } } I may did some mistakes when checking the custom tnt placing,but I couldn't find anything helpful enough on google.I just want someone to help me if it's possible.
I tried to make also some different checks and add different codes to make those tnts work but I got same results.