fix: client-side note player
This commit is contained in:
parent
79b11498c1
commit
314957eeb5
@ -27,6 +27,7 @@ import net.minecraft.world.level.material.MapColor
|
|||||||
import net.minecraft.world.phys.BlockHitResult
|
import net.minecraft.world.phys.BlockHitResult
|
||||||
import quaedam.Quaedam
|
import quaedam.Quaedam
|
||||||
import quaedam.projector.Projector
|
import quaedam.projector.Projector
|
||||||
|
import quaedam.utils.sendBlockUpdated
|
||||||
|
|
||||||
object CyberInstrument {
|
object CyberInstrument {
|
||||||
|
|
||||||
@ -176,6 +177,7 @@ class CyberInstrumentBlockEntity(pos: BlockPos, state: BlockState) :
|
|||||||
if (player == null && !level!!.isClientSide && checkProjections()) {
|
if (player == null && !level!!.isClientSide && checkProjections()) {
|
||||||
player = MusicPlayer(level!!.random.nextLong(), level!!, blockPos)
|
player = MusicPlayer(level!!.random.nextLong(), level!!, blockPos)
|
||||||
setChanged()
|
setChanged()
|
||||||
|
sendBlockUpdated()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +188,7 @@ class CyberInstrumentBlockEntity(pos: BlockPos, state: BlockState) :
|
|||||||
if (player?.isEnd == true) {
|
if (player?.isEnd == true) {
|
||||||
player = null
|
player = null
|
||||||
setChanged()
|
setChanged()
|
||||||
|
sendBlockUpdated()
|
||||||
if (level!!.random.nextInt(7) != 0) {
|
if (level!!.random.nextInt(7) != 0) {
|
||||||
startMusic()
|
startMusic()
|
||||||
}
|
}
|
||||||
@ -194,6 +197,7 @@ class CyberInstrumentBlockEntity(pos: BlockPos, state: BlockState) :
|
|||||||
} else {
|
} else {
|
||||||
player = null
|
player = null
|
||||||
setChanged()
|
setChanged()
|
||||||
|
sendBlockUpdated()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package quaedam.projection.music
|
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.BlockPos
|
||||||
import net.minecraft.core.Holder
|
import net.minecraft.core.Holder
|
||||||
import net.minecraft.core.particles.ParticleTypes
|
import net.minecraft.core.particles.ParticleTypes
|
||||||
import net.minecraft.nbt.CompoundTag
|
import net.minecraft.nbt.CompoundTag
|
||||||
import net.minecraft.sounds.SoundEvent
|
import net.minecraft.sounds.SoundEvent
|
||||||
import net.minecraft.sounds.SoundSource
|
import net.minecraft.sounds.SoundSource
|
||||||
|
import net.minecraft.util.RandomSource
|
||||||
import net.minecraft.world.level.Level
|
import net.minecraft.world.level.Level
|
||||||
import net.minecraft.world.level.block.NoteBlock
|
import net.minecraft.world.level.block.NoteBlock
|
||||||
import net.minecraft.world.level.block.entity.SkullBlockEntity
|
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(
|
val instance = SimpleSoundInstance(
|
||||||
null,
|
holder.value().location,
|
||||||
pos.x.toDouble() + 0.5,
|
|
||||||
pos.y.toDouble() + 0.5,
|
|
||||||
pos.z.toDouble() + 0.5,
|
|
||||||
holder,
|
|
||||||
SoundSource.RECORDS,
|
SoundSource.RECORDS,
|
||||||
volume,
|
volume,
|
||||||
pitch,
|
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--
|
noteTime--
|
||||||
|
Loading…
Reference in New Issue
Block a user