diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 9748fd0de..816f8cb7d 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -43,6 +43,8 @@ use pocketmine\item\FoodSource; use pocketmine\item\Item; use pocketmine\item\Totem; use pocketmine\level\Level; +use pocketmine\level\sound\TotemUseSound; +use pocketmine\level\sound\XpCollectSound; use pocketmine\nbt\NBT; use pocketmine\nbt\tag\ByteArrayTag; use pocketmine\nbt\tag\CompoundTag; @@ -51,7 +53,6 @@ use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\StringTag; use pocketmine\network\mcpe\protocol\AddPlayerPacket; use pocketmine\network\mcpe\protocol\EntityEventPacket; -use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\PlayerListPacket; use pocketmine\network\mcpe\protocol\PlayerSkinPacket; @@ -65,7 +66,6 @@ use function array_values; use function ceil; use function max; use function min; -use function mt_rand; use function random_int; use function strlen; use const INT32_MAX; @@ -448,7 +448,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ if((int) ($newLevel / 5) > (int) ($oldLevel / 5)){ $this->playLevelUpSound($newLevel); }elseif($this->getCurrentTotalXp() > $oldTotal){ - $this->level->broadcastLevelEvent($this, LevelEventPacket::EVENT_SOUND_ORB, mt_rand()); + $this->level->addSound($this, new XpCollectSound()); } } @@ -770,7 +770,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $this->addEffect(new EffectInstance(Effect::ABSORPTION(), 5 * 20, 1)); $this->broadcastEntityEvent(EntityEventPacket::CONSUME_TOTEM); - $this->level->broadcastLevelEvent($this->add(0, $this->eyeHeight, 0), LevelEventPacket::EVENT_SOUND_TOTEM); + $this->level->addSound($this->add(0, $this->eyeHeight, 0), new TotemUseSound()); $hand = $this->inventory->getItemInHand(); if($hand instanceof Totem){ diff --git a/src/pocketmine/entity/object/PrimedTNT.php b/src/pocketmine/entity/object/PrimedTNT.php index 4b171fb45..ec2b2da97 100644 --- a/src/pocketmine/entity/object/PrimedTNT.php +++ b/src/pocketmine/entity/object/PrimedTNT.php @@ -28,9 +28,9 @@ use pocketmine\entity\Explosive; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\ExplosionPrimeEvent; use pocketmine\level\Explosion; +use pocketmine\level\sound\IgniteSound; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\ShortTag; -use pocketmine\network\mcpe\protocol\LevelEventPacket; class PrimedTNT extends Entity implements Explosive{ public const NETWORK_ID = self::TNT; @@ -66,7 +66,7 @@ class PrimedTNT extends Entity implements Explosive{ $this->setGenericFlag(self::DATA_FLAG_IGNITED, true); $this->propertyManager->setInt(self::DATA_FUSE_LENGTH, $this->fuse); - $this->level->broadcastLevelEvent($this, LevelEventPacket::EVENT_SOUND_IGNITE); + $this->level->addSound($this, new IgniteSound()); } diff --git a/src/pocketmine/level/sound/IgniteSound.php b/src/pocketmine/level/sound/IgniteSound.php new file mode 100644 index 000000000..3fa28ffac --- /dev/null +++ b/src/pocketmine/level/sound/IgniteSound.php @@ -0,0 +1,34 @@ +