diff --git a/common/src/main/kotlin/quaedam/projection/music/CyberInstrument.kt b/common/src/main/kotlin/quaedam/projection/music/CyberInstrument.kt index 9febe42..6a358d9 100644 --- a/common/src/main/kotlin/quaedam/projection/music/CyberInstrument.kt +++ b/common/src/main/kotlin/quaedam/projection/music/CyberInstrument.kt @@ -27,6 +27,7 @@ import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.BlockHitResult import quaedam.Quaedam import quaedam.projector.Projector +import quaedam.utils.sendBlockUpdated object CyberInstrument { @@ -176,6 +177,7 @@ class CyberInstrumentBlockEntity(pos: BlockPos, state: BlockState) : if (player == null && !level!!.isClientSide && checkProjections()) { player = MusicPlayer(level!!.random.nextLong(), level!!, blockPos) setChanged() + sendBlockUpdated() } } @@ -186,6 +188,7 @@ class CyberInstrumentBlockEntity(pos: BlockPos, state: BlockState) : if (player?.isEnd == true) { player = null setChanged() + sendBlockUpdated() if (level!!.random.nextInt(7) != 0) { startMusic() } @@ -194,6 +197,7 @@ class CyberInstrumentBlockEntity(pos: BlockPos, state: BlockState) : } else { player = null setChanged() + sendBlockUpdated() } } diff --git a/common/src/main/kotlin/quaedam/projection/music/MusicPlayer.kt b/common/src/main/kotlin/quaedam/projection/music/MusicPlayer.kt index 3774e78..42e2b3c 100644 --- a/common/src/main/kotlin/quaedam/projection/music/MusicPlayer.kt +++ b/common/src/main/kotlin/quaedam/projection/music/MusicPlayer.kt @@ -1,11 +1,15 @@ package quaedam.projection.music +import dev.architectury.utils.GameInstance +import net.minecraft.client.resources.sounds.SimpleSoundInstance +import net.minecraft.client.resources.sounds.SoundInstance import net.minecraft.core.BlockPos import net.minecraft.core.Holder import net.minecraft.core.particles.ParticleTypes import net.minecraft.nbt.CompoundTag import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundSource +import net.minecraft.util.RandomSource import net.minecraft.world.level.Level import net.minecraft.world.level.block.NoteBlock import net.minecraft.world.level.block.entity.SkullBlockEntity @@ -84,17 +88,19 @@ class MusicPlayer(val seed: Long, val level: Level, val pos: BlockPos, val start ) } - level.playSeededSound( - null, - pos.x.toDouble() + 0.5, - pos.y.toDouble() + 0.5, - pos.z.toDouble() + 0.5, - holder, + val instance = SimpleSoundInstance( + holder.value().location, SoundSource.RECORDS, volume, pitch, - level.random.nextLong() + RandomSource.create(level.random.nextLong()), + false, 0, SoundInstance.Attenuation.NONE, + pos.x.toDouble() + 0.5, + pos.y.toDouble() + 0.5, + pos.z.toDouble() + 0.5, + false ) + GameInstance.getClient().soundManager.play(instance) } } noteTime--