Hi, I'm trying to prevent items from burning in lava. This is what I've got however I feel as if this method is inefficient since EntityDamageEvent is constantly called and I was wondering if there was a simpler way to do this that wouldn't keep on calling EntityDamageEvent. The code I've got can be found below, if it is possible to completely remove ItemEntity collision with Lava so it would just not float on lava, that would be phenomenal, or just not set ItemEntity on fire in collision with Lava. PHP: public function onDamageEntity(EntityDamageEvent $e): void { $damaged = $e->getEntity(); if ($damaged instanceof ItemEntity) { // if ($damaged->getItem()->getId() === 52) { $e->setCancelled(true); return; // } } }
This was my first attempt however it didn't work. This is my code. PHP: public function onEntityCombust(EntityCombustEvent $e){ $burned = $e->getEntity(); if($burned instanceof ItemEntity){ $e->setCancelled(); } }
i think u can use EntityDamageByBlockEvent https://github.com/pmmp/PocketMine-...ine/event/entity/EntityDamageByBlockEvent.php
Seems like cancelling EntityCombustByBlockEvent only prevent it from getting set on fire, but does not prevent the fire damage so you would have to cancel EntityDamageByBlockEvent too, pocketmine's logic..?
There's no other way around it. The only one that comes to my mind is to extend whether ItemEntity or Lava class and change its behavior. On the other hand it seems to be a bit overkill in this case.