Hello everyone, i have a problem i want to cancel ItemFrameDropItemPacket, but my code is not working what is wrong with my code ? Code: public function itemDrop(ItemFrameDropItemPacket $event){ $event->setCancelled(true); }
If you only want to protect item frames from taking out the item in it, use: PHP: public function onTouch(PlayerInteractEvent $event) { $block = $event->getBlock(); $player = $event->getPlayer(); $level = $player->getLevel(); if($level->getName() === "Shop") { // if you don't want players to take out the item in world "Shop" if(!$player->hasPermission("itemframes.touch")) { // if the player has permissions if($block->getId() === Block::ITEM_FRAME_BLOCK) { $event->setCancelled(); } } } }
i was using this code when version 1.0.7 and that was working very well but thank you WinterBuild7074 for the code
Using $level->getFolderName() might be better than $level->getName(). Most people change the folder name instead of the actual world name in level.dat.