Arrow: added shake effect and strike sound

This commit is contained in:
Dylan K. Taylor 2018-03-08 19:08:19 +00:00
parent 8cc6a32a04
commit 83a3c6f614
2 changed files with 11 additions and 0 deletions

View File

@ -23,13 +23,17 @@ declare(strict_types=1);
namespace pocketmine\entity\projectile;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\event\inventory\InventoryPickupArrowEvent;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\level\Level;
use pocketmine\math\RayTraceResult;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\protocol\EntityEventPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
use pocketmine\Player;
@ -83,6 +87,12 @@ class Arrow extends Projectile{
protected function onHit(ProjectileHitEvent $event) : void{
$this->setCritical(false);
$this->level->broadcastLevelSoundEvent($this, LevelSoundEventPacket::SOUND_BOW_HIT);
}
protected function onHitBlock(Block $blockHit, RayTraceResult $hitResult) : void{
parent::onHitBlock($blockHit, $hitResult);
$this->broadcastEntityEvent(EntityEventPacket::ARROW_SHAKE, 7); //7 ticks
}
public function onCollideWithPlayer(Player $player){

View File

@ -66,6 +66,7 @@ class EntityEventPacket extends DataPacket{
public const AGENT_ARM_SWING = 36;
public const ENDER_DRAGON_DEATH = 37;
public const DUST_PARTICLES = 38; //not sure what this is
public const ARROW_SHAKE = 39;
public const EATING_ITEM = 57;