mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
do audio async, fix packet particles, text flow (chat) caching
This commit is contained in:
parent
8895a29f77
commit
5707631d53
@ -53,7 +53,6 @@ open class TextFlowElement(
|
||||
get() = maxSize
|
||||
set(value) = Unit
|
||||
|
||||
override var cacheEnabled: Boolean = false // ToDo: Cache
|
||||
private var textSize = Vec2i.EMPTY
|
||||
|
||||
override fun forceRender(offset: Vec2i, z: Int, consumer: GUIVertexConsumer, options: GUIVertexOptions?): Int {
|
||||
@ -122,6 +121,7 @@ open class TextFlowElement(
|
||||
_size = Vec2i(maxSize.x, visibleLines.size * Font.TOTAL_CHAR_HEIGHT)
|
||||
background.size = size
|
||||
this.visibleLines = visibleLines
|
||||
cacheUpToDate = false
|
||||
}
|
||||
|
||||
fun addMessage(message: ChatComponent) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.particle
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.norender.ExplosionEmitterParticle
|
||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.explosion.ExplosionParticle
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.times
|
||||
@ -45,27 +46,29 @@ object DefaultParticleBehavior {
|
||||
}
|
||||
},
|
||||
CallbackEventInvoker.of<ParticleSpawnEvent> {
|
||||
if (it.initiator == EventInitiators.SERVER && typesConfig.packet) {
|
||||
return@of
|
||||
}
|
||||
fun spawn(position: Vec3d, velocity: Vec3d) {
|
||||
val particle = it.data.type.factory?.build(connection, position, velocity, it.data) ?: let { _ ->
|
||||
Log.log(LogMessageType.RENDERING_GENERAL, LogLevels.WARN) { "Can not spawn particle: ${it.data.type}" }
|
||||
return
|
||||
DefaultThreadPool += add@{
|
||||
if (it.initiator == EventInitiators.SERVER && !typesConfig.packet) {
|
||||
return@add
|
||||
}
|
||||
particleRenderer += particle
|
||||
}
|
||||
// ToDo: long distance = always spawn?
|
||||
if (it.count == 0) {
|
||||
val velocity = it.offset * it.speed
|
||||
fun spawn(position: Vec3d, velocity: Vec3d) {
|
||||
val particle = it.data.type.factory?.build(connection, position, velocity, it.data) ?: let { _ ->
|
||||
Log.log(LogMessageType.RENDERING_GENERAL, LogLevels.WARN) { "Can not spawn particle: ${it.data.type}" }
|
||||
return
|
||||
}
|
||||
particleRenderer += particle
|
||||
}
|
||||
// ToDo: long distance = always spawn?
|
||||
if (it.count == 0) {
|
||||
val velocity = it.offset * it.speed
|
||||
|
||||
spawn(it.position, Vec3d(velocity))
|
||||
} else {
|
||||
for (i in 0 until it.count) {
|
||||
val offset = Vec3d(it.offset) * { random.nextGaussian() }
|
||||
val velocity = Vec3d(it.speed) * { random.nextGaussian() }
|
||||
spawn(it.position, Vec3d(velocity))
|
||||
} else {
|
||||
for (i in 0 until it.count) {
|
||||
val offset = Vec3d(it.offset) * { random.nextGaussian() }
|
||||
val velocity = Vec3d(it.speed) * { random.nextGaussian() }
|
||||
|
||||
spawn(it.position + offset, velocity)
|
||||
spawn(it.position + offset, velocity)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.sound
|
||||
|
||||
import de.bixilon.kutil.collections.CollectionUtil.synchronizedListOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedList
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.queue.Queue
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatch
|
||||
@ -125,7 +126,7 @@ class AudioPlayer(
|
||||
if (!initialized) {
|
||||
return
|
||||
}
|
||||
playSound(soundManager[sound] ?: return, position, volume, pitch)
|
||||
DefaultThreadPool += add@{ playSound(soundManager[sound] ?: return@add, position, volume, pitch) }
|
||||
}
|
||||
|
||||
override fun play2DSound(sound: ResourceLocation, volume: Float, pitch: Float) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user