mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 11:58:00 +00:00
Implemented critical hits (#1929)
This commit is contained in:
committed by
Dylan K. Taylor
parent
cbbed6a6c1
commit
ad8d67137e
@@ -2411,6 +2411,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
if(!$this->isSprinting() and !$this->isFlying() and $this->fallDistance > 0 and !$this->hasEffect(Effect::BLINDNESS) and !$this->isInsideOfWater()){
|
||||
$ev->setDamage($ev->getFinalDamage() / 2, EntityDamageEvent::MODIFIER_CRITICAL);
|
||||
}
|
||||
|
||||
$target->attack($ev);
|
||||
|
||||
if($ev->isCancelled()){
|
||||
@@ -2420,6 +2424,16 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return true;
|
||||
}
|
||||
|
||||
if($ev->getDamage(EntityDamageEvent::MODIFIER_CRITICAL) > 0){
|
||||
$pk = new AnimatePacket();
|
||||
$pk->action = AnimatePacket::ACTION_CRITICAL_HIT;
|
||||
$pk->entityRuntimeId = $target->getId();
|
||||
$this->server->broadcastPacket($target->getViewers(), $pk);
|
||||
if($target instanceof Player){
|
||||
$target->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->isSurvival()){
|
||||
if($heldItem->useOn($target)){
|
||||
$this->inventory->setItemInHand($heldItem);
|
||||
|
Reference in New Issue
Block a user