Last active
August 2, 2019 02:06
-
-
Save BEcraft/c03a491b5baf397b98e61303412efd67 to your computer and use it in GitHub Desktop.
Modifica el knockback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types = 1); | |
/** | |
* @name Combo | |
* @author BEcraft | |
* @main BEcraft\Combo\Base | |
* @version 1.0 | |
* @api 3.0.0+12 | |
*/ | |
namespace BEcraft\Combo; | |
use pocketmine\plugin\PluginBase; | |
use pocketmine\event\Listener; | |
use pocketmine\entity\Living; | |
use pocketmine\event\entity\EntityDamageEvent; | |
use pocketmine\event\entity\EntityDamageByEntityEvent; | |
class Base extends PluginBase implements Listener | |
{ | |
public function onEnable(): void | |
{ | |
$this->getServer()->getPluginManager()->registerEvents($this, $this); | |
} | |
/** | |
* @priority HIGHEST | |
* @ignoreCancelled false | |
*/ | |
public function atacar(EntityDamageEvent $evento): void | |
{ | |
$atacante = (($evento instanceof EntityDamageByEntityEvent) ? $evento->getDamager() : null); | |
if ( ! ($atacante instanceof Living) || ! ($evento->getEntity() instanceof Living)) | |
{ | |
return; | |
} | |
$victima = $evento->getEntity(); | |
($propiedad = (new \ReflectionClass($victima))->getProperty("attackTime"))->setAccessible(true); $propiedad->setValue($victima, 0); | |
if (($atacante->getY() + $atacante->getEyeHeight() + 1) > $victima->getY()) | |
{ | |
$victima->setMotion($victima->getMotion()->setComponents($atacante->getDirectionVector()->getX() / 4.8, 0.3, $atacante->getDirectionVector()->getZ() / 4.8)); | |
} | |
$victima->setLastDamageCause($evento); # > ÚLtima causa de daño. | |
$victima->setHealth($victima->getHealth() - $evento->getFinalDamage()); # > Quitar vida de la entidad. | |
$victima->broadcastEntityEvent(2); # > Efecto de daño. | |
$evento->setCancelled(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment