So i spawned a entity(FallingSand) and i tried hitting it and it wont do any damage here is my code(i also tried to output to console and nothing worked at all) the entity spawns perfectly Code: PHP: public function spawnEgg($id = 122, $damage = 0, Player $player){ $pos1 = $player->getPosition(); $block1 = Entity::createEntity("FallingSand", $player->getLevel(), new CompoundTag("", [ "Pos" => new ListTag("Pos", [ new DoubleTag("", $pos1->x), new DoubleTag("", $pos1->y), new DoubleTag("", $pos1->z) ]), "Motion" => new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]), "Rotation" => new ListTag("Rotation", [ new FloatTag("", 0), new FloatTag("", 0) ]), "TileID" => new IntTag("TileID", $id), "Data" => new ByteTag("Data", $damage), ])); $block1->spawnToAll(); if($block1 instanceof FallingSand){ $this->block[$block1->getBlock()] = 100; } } public function onHit(EntityDamageEvent $ev){ $entity = $ev->getEntity(); if($entity instanceof FallingSand){ if(isset($this->block[$entity->getBlock()])){ $damage = $ev->getOriginalDamage(); $this->block[$entity->getBlock()] = ($this->block[$entity->getBlock()] - $damage); if($damage >= $this->block[$entity->getBlock()]){ $entity->close(); } $blockEvent = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_VOID, $damage); $entity->attack($damage, $blockEvent); echo $this->block[$entity->getBlock()]; } }
Its because of this line https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/FallingSand.php#L75 If you want it to deal damage i think the only quick way is to modify the source
But if you do parent::attack() from your class that extends it will call FallingSand::attack() and it would stop there as it would not be void damage :/ If you want to do it that way you need to copy FallingSand class into the plugin, modify then Entity::registerEntity()
if you overwrite the attack function to not call parent::attack but your own attack handler, shouldnt that fix it as i consider copying a whole file then editing it is bad, especially when you can get away with extending and such
Just call Entity::attack() from your custom falling sand's attack function to call pocketmine/entity/Entity.php's attack method.
Ohhh I didn't know that will work! I've learned something new today! I've always thought it will call it statically