Hello I have been trying since this morning to use "onEntityCollide" on a block, the action runs well when I am in the block (with a setblock) but I would like it to work when the player gets hold of the block or glued to the block. Here is the class of my block. I tried to be inspired by the magma block but unfortunately with the same code it does not work or half. PS: The block is a full block PHP: <?phpnamespace minicore\block;use pocketmine\block\BlockToolType;use pocketmine\block\Solid;use pocketmine\entity\Entity;use pocketmine\event\entity\EntityDamageByBlockEvent;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\item\TieredTool;use pocketmine\Player;class Spike extends Solid{ public function __construct() { parent::__construct(211); } public function getName(): string { return "Spike"; } public function getHardness() : float { return 30; } public function getToolType() : int { return BlockToolType::TYPE_PICKAXE; } public function getToolHarvestLevel() : int { return TieredTool::TIER_IRON; } public function hasEntityCollision() : bool{ return true; } public function onEntityCollide(Entity $entity): void { var_dump(1); // the var dump works when the player is in the block, inside, in the feet or in the head if(!$entity instanceof Player) return; $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 3); $entity->attack($ev); }}
I did not expect you ... The cactus is less complicated because it is not a full block, the client therefore allows himself to enter the "hitbox" of the block.
Sorry for bumping the thread, but for those who might be looking for a solution. Expand the bounding box in Block::recalculateBoundingBox