mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 18:34:56 -04:00
fix crash in block entity ticker, fix wrong displayed available audio source number in f3
This commit is contained in:
parent
d3f53e3b8f
commit
88bc4715b5
@ -58,7 +58,8 @@ class ChunkSection(
|
||||
|
||||
fun realTick(connection: PlayConnection, chunkSectionPosition: Vec3i) {
|
||||
blockEntities.forEach { entity, inChunkSectionPosition ->
|
||||
entity.realTick(connection, blocks[inChunkSectionPosition.index]!!, chunkSectionPosition + inChunkSectionPosition)
|
||||
val block = blocks[inChunkSectionPosition.index] ?: return@forEach // maybe block already got destroyed
|
||||
entity.realTick(connection, block, chunkSectionPosition + inChunkSectionPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,19 +67,9 @@ class AudioPlayer(
|
||||
private lateinit var listener: SoundListener
|
||||
private val sources: MutableList<SoundSource> = synchronizedListOf()
|
||||
|
||||
val availableSources: Int
|
||||
get() {
|
||||
val sources = sources.toSynchronizedList()
|
||||
var available = 0
|
||||
var availableSources: Int = 0
|
||||
private set
|
||||
|
||||
for (source in sources) {
|
||||
if (source.available) {
|
||||
available++
|
||||
}
|
||||
}
|
||||
|
||||
return available
|
||||
}
|
||||
val sourcesCount: Int
|
||||
get() = sources.size
|
||||
|
||||
@ -207,6 +197,15 @@ class AudioPlayer(
|
||||
break
|
||||
}
|
||||
queue.work()
|
||||
|
||||
var availableSources = 0
|
||||
for (source in sources) {
|
||||
if (source.available) {
|
||||
availableSources++
|
||||
}
|
||||
}
|
||||
this.availableSources = availableSources
|
||||
|
||||
Thread.sleep(1L)
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class SoundSource {
|
||||
get() = alGetSourcei(source, AL_SOURCE_STATE) == AL_PLAYING
|
||||
|
||||
val available: Boolean
|
||||
get() = !isPlaying || System.currentTimeMillis() - playTime > (sound?.length ?: 0L) // ToDo: Allow pause
|
||||
get() = !isPlaying || System.currentTimeMillis() - playTime > (sound?.length ?: 0L) // ToDo: Allow pause
|
||||
|
||||
fun play() {
|
||||
playTime = System.currentTimeMillis()
|
||||
|
Loading…
x
Reference in New Issue
Block a user