PHP: public function onMove(PlayerMoveEvent $ev){$p = $ev->getPlayer();$block = $ev->getPlayer()->getLevel()->getBlock($ev->getPlayer()->floor()->subtract(0, 1));if($ev->getTo()->getY() > $ev->getFrom()->getY() && $block->getId() == 0){ $p->sendTip("TEST"); $p->attack(1, new EntityDamageByEntityEvent($p, EntityDamageEvent::CAUSE_CONTACT, 2)); I actually wanna create a critical plugin, it's a thing that when you jump and hit player while in the air it'll register the critical. and the problem on this code EntityDamageByEntityEvent don't have getPlayer, so in this situation how do I add getEntity? PHP: $center = new Vector3($p->getX(),$p->getY(),$p->getZ()); $radius = 1; $count = 3; $particle = new CriticalParticle($center); for($yaw = 2, $y = $center->y; $y < $center->y + 3; $yaw += (M_PI * 2) / 10, $y += 1 / 10){ $x = -sin($yaw) + $center->x; $z = cos($yaw) + $center->z; $particle->setComponents($x, $y, $z); $ev->getEntity()->getLevel()->addParticle($particle);} also I wanna add these particles, how?
What do you mean by "how do I add getEntity"? And you do not need to handle PlayerMoveEvent to know handle an attack. You only need to handle EntityDamageEvent. And a player is an entity. PHP: public function e_damage(EntityDamageEvent $event){ if(!($event instanceof EntityDamageByEntityEvent) or !($event->getDamager() instanceof Player)) return; $player = $event->getDamager(); $block = $player->getLevel()->getBlock($player->subtract(0, 1)); if($block instanceof Air){ // player is attacking in air // spawn critical particle at $event->getEntity(), which is the victim $event->setDamage((int) ($event->getDamage() * 1.5)); // magnify the damage }} This is based on your code. However, there are a few things you may be interested to know: This will only work when the entity is attacked at the exact moment the player jumped more than 1 meter high and before falling. A player jumps slightly more than 1 meter high. In Minecraft, players actually only attack with critical damage when they are falling, or more precisely, when they are in air but lower than the highest position since their last jump (e.g. if you are in creative, fly up, then fly down a bit, then start killing your pig). This means, you should try to detect player movement speed instead. Try this: PHP: if($player->speed->y < 0)
Finally the reply I wanted has come thank you so much actually on my code for EntityDamageEvent if I didnt make it EntityDamageByEntityEvent it just damage player everytime the player jumps so i tried EntityDamageByEntityEvent and it didnt work because the $p = $ev->getPlayer must be getEntity, and i cant make it getEntity because the $ev is playerMoveEvent
The first code didnt worked* and i tried the code with vector and [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\entity\EntityDamageByEntityEvent' to 'ServerCore v1.0': Undefined property: pocketmine\Player::$vector on ServerCore\Main