hello Guys. how to chest get removed and replaced tnt explosion effect when player touch it . and player get all items in the chest. like how SupplyCrate / Envoys work(Bukkit) LINK: https://www.spigotmc.org/resources/envoy-supply-crates-free.20665/
It never changed the block to TNT but I'll answer the question on title PHP: public function onPlayerInteract(PlayerInteractEvent $event) { $event->getBlock()->getLevel()->setBlock($event->getBlock(), Block::get(Block::TNT));} It won't do the same as in video because in the video the block was replaced by air and spawned Explosion with no terrain damage, Explosion::explodeA() AFAIR, here's the code for explosion, It's better to use InventoryOpenEvent PHP: public function onInventoryOpen(InventoryOpenEvent $event) { if($event->getInventory() instanceof ChestInventory) { # Do some additional checks, like if the chest is an envoy (what a fancy name) # Transfer all items, there is way more efficient way to do this... foreach($event->getInventory()->getContents() as $item) { $event->getPlayer()->getInventory()->addItem($item); } # Make an explosion # Remove block $event->getBlock()->getLevel()->setBlock($event->getBlock(), Block::get(0)); }} There is class named Explosion but I'm not sure will it spawn sound and particles as well but you can try tho PHP: $explosion = new Explosion($event->getBlock(), 1, $event->getBlock()); // Don't put size 0 to avoid 'division by zero'$explosion->explodeA(); P.S. I'm the only one who dislikes kids who make minecraft videos?
Why is using InventoryOpenEvent better than using PlayerInteractEvent? P.S. I hate those YouTubers who record themselves playing as well. They are just public relations experts. They don't really create anything for us, except for those who showcase their own creation, such as redstone mechanisms invented by themselves, showcases for their own plugins, etc.