Sound::encode() position is no longer nullable

making this nullable was based on the invalid assumption that global sounds have no position, but it turns out they _do_ still use the position to make the sound come from the correct direction.
This commit is contained in:
Dylan K. Taylor 2021-10-23 02:01:26 +01:00
parent e50072dc27
commit 701a71a4ee
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
54 changed files with 54 additions and 54 deletions

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilBreakSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_BREAK, 0, $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilFallSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_FALL, 0, $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilUseSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_USE, 0, $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class ArrowHitSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BOW_HIT, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class BarrelCloseSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BLOCK_BARREL_CLOSE, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class BarrelOpenSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BLOCK_BARREL_OPEN, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
final class BellRingSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BLOCK_BELL_HIT, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class BlazeShootSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT, 0, $pos)];
}
}

View File

@ -37,7 +37,7 @@ class BlockBreakSound implements Sound{
$this->block = $block;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BREAK, $pos, false, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()))];
}
}

View File

@ -37,7 +37,7 @@ class BlockPlaceSound implements Sound{
$this->block = $block;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_PLACE, $pos, false, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()))];
}
}

View File

@ -40,7 +40,7 @@ class BlockPunchSound implements Sound{
$this->block = $block;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(
LevelSoundEventPacket::SOUND_HIT,
$pos,

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class BowShootSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BOW, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class BucketEmptyLavaSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BUCKET_EMPTY_LAVA, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class BucketEmptyWaterSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BUCKET_EMPTY_WATER, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class BucketFillLavaSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BUCKET_FILL_LAVA, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class BucketFillWaterSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BUCKET_FILL_WATER, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class ChestCloseSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_CHEST_CLOSED, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class ChestOpenSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_CHEST_OPEN, $pos, false)];
}
}

View File

@ -39,7 +39,7 @@ class ClickSound implements Sound{
return $this->pitch;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_CLICK, (int) ($this->pitch * 1000), $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorBumpSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR_BUMP, 0, $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorCrashSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR_CRASH, 0, $pos)];
}
}

View File

@ -39,7 +39,7 @@ class DoorSound implements Sound{
return $this->pitch;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR, (int) ($this->pitch * 1000), $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class EnderChestCloseSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_ENDERCHEST_CLOSED, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class EnderChestOpenSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_ENDERCHEST_OPEN, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class EndermanTeleportSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT, 0, $pos)];
}
}

View File

@ -31,7 +31,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
*/
class EntityAttackNoDamageSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create(
LevelSoundEventPacket::SOUND_ATTACK_NODAMAGE,
$pos,

View File

@ -31,7 +31,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
*/
class EntityAttackSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create(
LevelSoundEventPacket::SOUND_ATTACK_STRONG, //TODO: seems like ATTACK is dysfunctional
$pos,

View File

@ -44,7 +44,7 @@ class EntityLandSound implements Sound{
$this->blockLandedOn = $blockLandedOn;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create(
LevelSoundEventPacket::SOUND_LAND,
$pos,

View File

@ -40,7 +40,7 @@ class EntityLongFallSound implements Sound{
$this->entity = $entity;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create(
LevelSoundEventPacket::SOUND_FALL_BIG,
$pos,

View File

@ -39,7 +39,7 @@ class EntityShortFallSound implements Sound{
$this->entity = $entity;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create(
LevelSoundEventPacket::SOUND_FALL_SMALL,
$pos,

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class ExplodeSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_EXPLODE, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
final class FireExtinguishSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_EXTINGUISH_FIRE, $pos, false)];
}
}

View File

@ -39,7 +39,7 @@ class FizzSound implements Sound{
return $this->pitch;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_FIZZ, (int) ($this->pitch * 1000), $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class FlintSteelSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_IGNITE, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastShootSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_GHAST_SHOOT, 0, $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_GHAST, 0, $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class IgniteSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_IGNITE, 0, $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class ItemBreakSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_BREAK, $pos, false)];
}
}

View File

@ -39,7 +39,7 @@ class LaunchSound implements Sound{
return $this->pitch;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_SHOOT, (int) ($this->pitch * 1000), $pos)];
}
}

View File

@ -41,7 +41,7 @@ class NoteSound implements Sound{
$this->note = $note;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_NOTE, $pos, false, ($this->instrument->getMagicNumber() << 8) | $this->note)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class PaintingPlaceSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
//item frame and painting have the same sound
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ITEMFRAME_PLACE, 0, $pos)];
}

View File

@ -39,7 +39,7 @@ class PopSound implements Sound{
return $this->pitch;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_POP, (int) ($this->pitch * 1000), $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class PotionSplashSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_GLASS, $pos, false)];
}
}

View File

@ -36,7 +36,7 @@ class RecordSound implements Sound{
$this->recordType = $recordType;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound($this->recordType->getSoundId(), $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class RecordStopSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_STOP_RECORD, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class RedstonePowerOffSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_POWER_OFF, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class RedstonePowerOnSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_POWER_ON, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class ShulkerBoxCloseSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_SHULKERBOX_CLOSED, $pos, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class ShulkerBoxOpenSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_SHULKERBOX_OPEN, $pos, false)];
}
}

View File

@ -31,5 +31,5 @@ interface Sound{
/**
* @return ClientboundPacket[]
*/
public function encode(?Vector3 $pos) : array;
public function encode(Vector3 $pos) : array;
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class ThrowSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create(LevelSoundEventPacket::SOUND_THROW, $pos, -1, "minecraft:player", false, false)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class TotemUseSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_TOTEM, 0, $pos)];
}
}

View File

@ -28,7 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
class XpCollectSound implements Sound{
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
return [LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ORB, 0, $pos)];
}
}

View File

@ -41,7 +41,7 @@ class XpLevelUpSound implements Sound{
return $this->xpLevel;
}
public function encode(?Vector3 $pos) : array{
public function encode(Vector3 $pos) : array{
//No idea why such odd numbers, but this works...
//TODO: check arbitrary volume
return [LevelSoundEventPacket::nonActorSound(LevelSoundEventPacket::SOUND_LEVELUP, $pos, false, 0x10000000 * intdiv(min(30, $this->xpLevel), 5))];