BlockBreakEvent does not work and idk why... But PlayerInteractEvent works perfectly. Here's the code: PHP: public function onBreak(BlockBreakEvent $ev){ //NOT WORKING if($ev->getPlayer()->isOp()) { if ($ev->getBlock()->getId() == 7) { //Bedrock $bx = $ev->getBlock()->getX(); $by = $ev->getBlock()->getY(); $bz = $ev->getBlock()->getZ(); $ev->getBlock()->getLevel()->dropItem(new Vector3($bx,$by,$bz), Item::get(7, 0, 1)); $ev->getBlock()->getLevel()->setBlock(new Vector3($bx,$by,$bz), Block::get(0)); } } }public function onTouch(PlayerInteractEvent $ev){ //WORKS PERFECTLY if($ev->getPlayer()->isOp()) { if ($ev->getBlock()->getId() == 7) { $bx = $ev->getBlock()->getX(); $by = $ev->getBlock()->getY(); $bz = $ev->getBlock()->getZ(); $ev->getBlock()->getLevel()->dropItem(new Vector3($bx,$by,$bz), Item::get(7, 0, 1)); $ev->getBlock()->getLevel()->setBlock(new Vector3($bx,$by,$bz), Block::get(0)); } } } Help will be Appreciated...
change PHP: $ev->getBlock()->getLevel()->dropItem(new Vector3($bx,$by,$bz), Item::get(7, 0, 1)); to PHP: $e->setDrops(); and PHP: $ev->getBlock()->getLevel()->setBlock(new Vector3($bx,$by,$bz), Block::get(0)); to PHP: $e->setCancelled();
$event->setDrops() doesnt work in PlayerInteractEvent $event->setDrops() = PlayerDeathEvent, BlockBreakEvent
he asking how to fix problem with block break event no interact event read thread name ps: Cortex pe you cant check block because it is already breaken try $e->setCancelled(); Spoiler PHP: public function onBreak(BlockBreakEvent $ev){ if($ev->getPlayer()->isOp()) { if ($ev->getBlock()->getId() == 7) { $ev->getPlayer()->sendMessage("Nah!"); $ev->setDrops(); $ev->setCancelled(); } }}
That "SetBlock" Part was only for debugging... (I was gonna remove it but I forgot... ) I tried setDrops even before using dropItem, And it didnt work. The whole BlockBreakEvent doesn't work - Thats my only problem. I tried to echo a string if it gets triggered and it didnt return a thing. I also tried to send a message to the player and it still didnt work.
It should work. Did you register your class as a listener? did you really echo at the highest level of the function call?
Listener - ✓ Echo at the top of everything - ✓ SendMessage to player - ✓ Spoiler: Included Files PHP: use pocketmine\plugin\PluginBase;use pocketmine\plugin\Plugin;use pocketmine\event\Listener;use pocketmine\utils\TextFormat as TF;use pocketmine\block\Block;use pocketmine\math\Vector3;use pocketmine\item\Item;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\command\CommandExecutor;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\block\BlockBreakEvent;