mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 16:29:40 +00:00
clean up some direct LevelEvent usages for sounds
This commit is contained in:
parent
37b5ad8350
commit
10db57655e
@ -43,6 +43,8 @@ use pocketmine\item\FoodSource;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\Totem;
|
use pocketmine\item\Totem;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
|
use pocketmine\level\sound\TotemUseSound;
|
||||||
|
use pocketmine\level\sound\XpCollectSound;
|
||||||
use pocketmine\nbt\NBT;
|
use pocketmine\nbt\NBT;
|
||||||
use pocketmine\nbt\tag\ByteArrayTag;
|
use pocketmine\nbt\tag\ByteArrayTag;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
@ -51,7 +53,6 @@ use pocketmine\nbt\tag\ListTag;
|
|||||||
use pocketmine\nbt\tag\StringTag;
|
use pocketmine\nbt\tag\StringTag;
|
||||||
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
|
||||||
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
use pocketmine\network\mcpe\protocol\EntityEventPacket;
|
||||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
|
||||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||||
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||||
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
use pocketmine\network\mcpe\protocol\PlayerSkinPacket;
|
||||||
@ -65,7 +66,6 @@ use function array_values;
|
|||||||
use function ceil;
|
use function ceil;
|
||||||
use function max;
|
use function max;
|
||||||
use function min;
|
use function min;
|
||||||
use function mt_rand;
|
|
||||||
use function random_int;
|
use function random_int;
|
||||||
use function strlen;
|
use function strlen;
|
||||||
use const INT32_MAX;
|
use const INT32_MAX;
|
||||||
@ -448,7 +448,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
if((int) ($newLevel / 5) > (int) ($oldLevel / 5)){
|
if((int) ($newLevel / 5) > (int) ($oldLevel / 5)){
|
||||||
$this->playLevelUpSound($newLevel);
|
$this->playLevelUpSound($newLevel);
|
||||||
}elseif($this->getCurrentTotalXp() > $oldTotal){
|
}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->addEffect(new EffectInstance(Effect::ABSORPTION(), 5 * 20, 1));
|
||||||
|
|
||||||
$this->broadcastEntityEvent(EntityEventPacket::CONSUME_TOTEM);
|
$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();
|
$hand = $this->inventory->getItemInHand();
|
||||||
if($hand instanceof Totem){
|
if($hand instanceof Totem){
|
||||||
|
@ -28,9 +28,9 @@ use pocketmine\entity\Explosive;
|
|||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
use pocketmine\event\entity\ExplosionPrimeEvent;
|
use pocketmine\event\entity\ExplosionPrimeEvent;
|
||||||
use pocketmine\level\Explosion;
|
use pocketmine\level\Explosion;
|
||||||
|
use pocketmine\level\sound\IgniteSound;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\ShortTag;
|
use pocketmine\nbt\tag\ShortTag;
|
||||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
|
||||||
|
|
||||||
class PrimedTNT extends Entity implements Explosive{
|
class PrimedTNT extends Entity implements Explosive{
|
||||||
public const NETWORK_ID = self::TNT;
|
public const NETWORK_ID = self::TNT;
|
||||||
@ -66,7 +66,7 @@ class PrimedTNT extends Entity implements Explosive{
|
|||||||
$this->setGenericFlag(self::DATA_FLAG_IGNITED, true);
|
$this->setGenericFlag(self::DATA_FLAG_IGNITED, true);
|
||||||
$this->propertyManager->setInt(self::DATA_FUSE_LENGTH, $this->fuse);
|
$this->propertyManager->setInt(self::DATA_FUSE_LENGTH, $this->fuse);
|
||||||
|
|
||||||
$this->level->broadcastLevelEvent($this, LevelEventPacket::EVENT_SOUND_IGNITE);
|
$this->level->addSound($this, new IgniteSound());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
34
src/pocketmine/level/sound/IgniteSound.php
Normal file
34
src/pocketmine/level/sound/IgniteSound.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\level\sound;
|
||||||
|
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||||
|
|
||||||
|
class IgniteSound implements Sound{
|
||||||
|
|
||||||
|
public function encode(Vector3 $pos){
|
||||||
|
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_IGNITE, 0, $pos);
|
||||||
|
}
|
||||||
|
}
|
34
src/pocketmine/level/sound/TotemUseSound.php
Normal file
34
src/pocketmine/level/sound/TotemUseSound.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\level\sound;
|
||||||
|
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||||
|
|
||||||
|
class TotemUseSound implements Sound{
|
||||||
|
|
||||||
|
public function encode(Vector3 $pos){
|
||||||
|
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_TOTEM, 0, $pos);
|
||||||
|
}
|
||||||
|
}
|
34
src/pocketmine/level/sound/XpCollectSound.php
Normal file
34
src/pocketmine/level/sound/XpCollectSound.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\level\sound;
|
||||||
|
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||||
|
|
||||||
|
class XpCollectSound implements Sound{
|
||||||
|
|
||||||
|
public function encode(Vector3 $pos){
|
||||||
|
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ORB, 0, $pos);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user