Okay, this is rather a help thread than a question. This was/had been a huge problem on my server for a whole month. I never bothered on *fixing* this because... WHO REALLY CARES ABOUT ITEM FRAMES? But then it started getting a bit annoying, seeing soon many item frames just empty. So here you go until we get an ItemFrameDropItemEvent. PHP: public function onDataReceive(\pocketmine\event\server\DataPacketReceiveEvent $event){ if(($pk = $event->getPacket())::NETWORK_ID === \pocketmine\network\protocol\Info::ITEM_FRAME_DROP_ITEM_PACKET){ if(!$event->getPlayer()->isOp()){//or some other criteria. $event->setCancelled(); $event->getPlayer()->getLevel()->getTile(new \pocketmine\math\Vector3($pk->x, $pk->y, $pk->z))->spawnTo($event->getPlayer()); } }}
This works too PHP: public function playerBlockTouch(PlayerInteractEvent $event){ if($event->getBlock()->getId() === Block::ITEM_FRAME_BLOCK && $event->getAction() === PlayerInteractEvent::LEFT_CLICK_BLOCK){ $event->setCancelled(); }}
It should work? According to this https://github.com/pmmp/PocketMine-...dc9707630c7df/src/pocketmine/Player.php#L2155
I have a shop, with a hundreds of ItemFrames. I extra put Glass in front of the ItemFrames that players cannot get them out. But they still can! Glass is easy enough to break and then after a few seconds the item inside the ItemFrame jumps out. Then they can collect it. How can I stop people doing this?
Use the code above or use invisible bedrock. Not implemented in pmmp yet but u cud add it yourself. Placing invisible bedrock is permanent though.
Use MagicWE. Place Stone blocks then do //replace 1 95 the stone will be replaced with invisible bedrock
I know that, but: MagicWE says he doesn't know that block (I don't extra want to edit the code for that), I want to find another way to fix this problem. PHP: public function onInteract(PlayerInteractEvent $event) { $block = $event->getBlock(); if($block === "102") { $event->setCancelled(); }}
I don't know what you are trying to do, since PlayerInteractEvent currently can't prevent Item Frame griefing, but $event->getBlock() will be a Block object, not the string "102".
OK, wait, I'll try again... PHP: public function onInteract(PlayerInteractEvent $event) { $block = $event->getBlock(); $level = $event->getLevel(); if($level->getName() === "Shop" && $block->getId() === 102) { // if player is in Shop and tries to break the GlassPane/ItemFrame $event->setCancelled(); }}
Then I'll write a bot that ignores the invisible bedrock, or simply a mod that treats invisible bedrock as air.
i guess i am right on the assumption that PMMP dont check if player actually have access to a block before allowing it to be broken
@SOFe Can you make a PlayerItemFrameDropEvent? Then you can cancel the event. Or maybe my code will work.
You'd be delighted when you learn that I don't even have MCPE installed in my phone Therefore I can't even test anything directly related to the client.
Um, maybe my code will work? Before the player tries to break the block (touching only), it cancels the event. @SOFe If that will work, then PlayerItemFrameDropEvent is not needed...?