mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 09:26:11 -04:00
bump kutil
This should reduce memory usage quite a bit and (thus/generally) improve performance. ThreadPoolRunnables and latches got refactored, so heavy changes are required
This commit is contained in:
parent
18f77e89c1
commit
85f8be3331
@ -57,7 +57,7 @@ logger.info("Building for ${os.name.lowercase()}, ${architecture.name.lowercase(
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots")
|
||||
maven(url = "https://s01.oss.sonatype.org/content/repositories/releases/")
|
||||
}
|
||||
|
||||
buildscript {
|
||||
|
@ -17,5 +17,5 @@ lwjgl.version=3.3.2
|
||||
ikonli.version=12.3.1
|
||||
netty.version=4.1.93.Final
|
||||
jackson.version=2.14.2
|
||||
kutil.version=1.21
|
||||
kutil.version=1.22.1
|
||||
glm.version=0.9.9.1-8
|
||||
|
@ -16,7 +16,6 @@ rootProject.name = "minosoft"
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven(url = "https://s01.oss.sonatype.org/content/repositories/releases/")
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.minosoft.assets.properties.version.AssetsVersionProperties
|
||||
import de.bixilon.minosoft.data.registries.fallback.FallbackRegistries
|
||||
import de.bixilon.minosoft.data.registries.fallback.tags.FallbackTags
|
||||
@ -59,19 +59,19 @@ internal object MinosoftSIT {
|
||||
}
|
||||
|
||||
fun initAssetsManager() {
|
||||
Minosoft.MINOSOFT_ASSETS_MANAGER.load(CountUpAndDownLatch(0))
|
||||
Minosoft.MINOSOFT_ASSETS_MANAGER.load()
|
||||
}
|
||||
|
||||
fun setupPacketRegistry() {
|
||||
PacketTypeRegistry.init(CountUpAndDownLatch(0))
|
||||
PacketTypeRegistry.init(null)
|
||||
}
|
||||
|
||||
fun loadVersionsJson() {
|
||||
Versions.load(CountUpAndDownLatch(0))
|
||||
Versions.load(SimpleLatch(0))
|
||||
}
|
||||
|
||||
fun loadAssetsProperties() {
|
||||
AssetsVersionProperties.load(CountUpAndDownLatch(0))
|
||||
AssetsVersionProperties.load(SimpleLatch(0))
|
||||
}
|
||||
|
||||
fun loadDefaultRegistries() {
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.assets
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.InputStream
|
||||
@ -30,7 +30,7 @@ object TestAssetsManager : AssetsManager {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
}
|
||||
|
||||
override fun unload() {
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.data.accounts.types.test
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.uuid.UUIDUtil.toUUID
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.data.accounts.AccountStates
|
||||
@ -36,5 +36,5 @@ object TestAccount : Account("Bixilon") {
|
||||
|
||||
override fun logout(clientToken: String) = Unit
|
||||
|
||||
override fun check(latch: CountUpAndDownLatch?, clientToken: String) = Unit
|
||||
override fun check(latch: AbstractLatch?, clientToken: String) = Unit
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
import de.bixilon.minosoft.assets.AssetsLoader
|
||||
import de.bixilon.minosoft.gui.rendering.font.FontLoader
|
||||
@ -29,7 +29,7 @@ class RenderTestLoader {
|
||||
|
||||
fun init() {
|
||||
val connection = createConnection(5)
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
connection::assetsManager.forceSet(AssetsLoader.create(connection.profiles.resources, connection.version, latch))
|
||||
FontLoader.remove(BitmapFontProvider) // TODO: remove
|
||||
connection.assetsManager.load(latch)
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.system.dummy.texture
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureData
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.dynamic.DynamicTexture
|
||||
@ -27,7 +27,7 @@ class DummyDynamicTextureArray : DynamicTextureArray {
|
||||
return DummyDynamicTexture
|
||||
}
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
}
|
||||
|
||||
override fun activate() {
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.system.dummy.texture
|
||||
|
||||
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
|
||||
@ -33,13 +33,13 @@ class DummyStaticTextureArray(renderSystem: RenderSystem) : StaticTextureArray {
|
||||
return textures.getOrPut(resourceLocation) { DummyTexture(resourceLocation) }
|
||||
}
|
||||
|
||||
override fun preLoad(latch: CountUpAndDownLatch) {
|
||||
override fun preLoad(latch: AbstractLatch) {
|
||||
for (texture in textures.values) {
|
||||
(texture as DummyTexture).state = TextureStates.LOADED
|
||||
}
|
||||
}
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
animator.init()
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.world
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.stone.StoneTest0
|
||||
import de.bixilon.minosoft.gui.rendering.RenderTestUtil
|
||||
import de.bixilon.minosoft.gui.rendering.RenderTestUtil.frame
|
||||
@ -43,7 +43,7 @@ class WorldRendererTest {
|
||||
|
||||
@Test(priority = -1)
|
||||
fun loadModels() {
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
RenderTestUtil.context.modelLoader.load(latch)
|
||||
latch.dec()
|
||||
latch.await()
|
||||
@ -54,7 +54,7 @@ class WorldRendererTest {
|
||||
}
|
||||
|
||||
fun queueEmptyChunk() {
|
||||
val chunk = RenderTestUtil.context.connection.world[Vec2i(0, 0)]!!
|
||||
val chunk = RenderTestUtil.context.connection.world.chunks[Vec2i(0, 0)]!!
|
||||
val renderer = create()
|
||||
renderer.master.tryQueue(chunk, ignoreLoaded = true, force = true)
|
||||
Thread.sleep(50)
|
||||
@ -64,7 +64,7 @@ class WorldRendererTest {
|
||||
}
|
||||
|
||||
fun queueSingleChunk() {
|
||||
val chunk = RenderTestUtil.context.connection.world[Vec2i(0, 0)]!!
|
||||
val chunk = RenderTestUtil.context.connection.world.chunks[Vec2i(0, 0)]!!
|
||||
chunk[Vec3i(0, 0, 0)] = StoneTest0.state
|
||||
val renderer = create()
|
||||
renderer.master.tryQueue(chunk, ignoreLoaded = true, force = true)
|
||||
@ -76,10 +76,10 @@ class WorldRendererTest {
|
||||
@Test(invocationCount = 10)
|
||||
fun queueMultipleChunks() {
|
||||
val chunks = setOf(
|
||||
RenderTestUtil.context.connection.world[Vec2i(0, 0)]!!,
|
||||
RenderTestUtil.context.connection.world[Vec2i(0, 1)]!!,
|
||||
RenderTestUtil.context.connection.world[Vec2i(1, 1)]!!,
|
||||
RenderTestUtil.context.connection.world[Vec2i(3, 1)]!!,
|
||||
RenderTestUtil.context.connection.world.chunks[Vec2i(0, 0)]!!,
|
||||
RenderTestUtil.context.connection.world.chunks[Vec2i(0, 1)]!!,
|
||||
RenderTestUtil.context.connection.world.chunks[Vec2i(1, 1)]!!,
|
||||
RenderTestUtil.context.connection.world.chunks[Vec2i(3, 1)]!!,
|
||||
)
|
||||
for (chunk in chunks) {
|
||||
chunk[Vec3i(0, 0, 0)] = StoneTest0.state
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.test
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
|
||||
import de.bixilon.minosoft.data.registries.VersionRegistry
|
||||
import de.bixilon.minosoft.data.registries.registries.PixLyzerUtil
|
||||
@ -40,7 +40,7 @@ object ITUtil {
|
||||
|
||||
val data = PixLyzerUtil.loadPixlyzerData(version, profile)
|
||||
|
||||
registries.load(version, data, CountUpAndDownLatch(0))
|
||||
registries.load(version, data, SimpleLatch(0))
|
||||
|
||||
return registries
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.worker.task.TaskWorker
|
||||
import de.bixilon.kutil.concurrent.worker.task.WorkerTask
|
||||
import de.bixilon.kutil.file.watcher.FileWatcherService
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.os.OSTypes
|
||||
import de.bixilon.kutil.os.PlatformInfo
|
||||
@ -67,7 +68,7 @@ object Minosoft {
|
||||
val MINOSOFT_ASSETS_MANAGER = ResourcesAssetsUtil.create(Minosoft::class.java, canUnload = false)
|
||||
val OVERRIDE_ASSETS_MANAGER = ResourcesAssetsUtil.create(Minosoft::class.java, canUnload = false, prefix = "assets_override")
|
||||
val LANGUAGE_MANAGER = MultiLanguageManager()
|
||||
val BOOT_LATCH = CountUpAndDownLatch(1)
|
||||
val BOOT_LATCH = CallbackLatch(1)
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
@ -80,10 +81,10 @@ object Minosoft {
|
||||
KUtil.initUtilClasses()
|
||||
KUtil.init()
|
||||
ModLoader.initModLoading()
|
||||
ModLoader.load(LoadingPhases.PRE_BOOT, CountUpAndDownLatch(0))
|
||||
ModLoader.load(LoadingPhases.PRE_BOOT)
|
||||
ModLoader.await(LoadingPhases.PRE_BOOT)
|
||||
|
||||
MINOSOFT_ASSETS_MANAGER.load(CountUpAndDownLatch(0))
|
||||
MINOSOFT_ASSETS_MANAGER.load()
|
||||
|
||||
if (PlatformInfo.OS == OSTypes.MAC) {
|
||||
checkMacOS()
|
||||
@ -131,19 +132,19 @@ object Minosoft {
|
||||
val end = nanos()
|
||||
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "Minosoft boot sequence finished in ${(end - start).formatNanos()}!" }
|
||||
GlobalEventMaster.fire(FinishBootEvent())
|
||||
DefaultThreadPool += { ModLoader.load(LoadingPhases.POST_BOOT, CountUpAndDownLatch(0)) }
|
||||
DefaultThreadPool += { ModLoader.load(LoadingPhases.POST_BOOT) }
|
||||
|
||||
|
||||
RunConfiguration.AUTO_CONNECT_TO?.let { AutoConnect.autoConnect(it) }
|
||||
}
|
||||
|
||||
private fun startFileWatcherService(latch: CountUpAndDownLatch) {
|
||||
private fun startFileWatcherService(latch: AbstractLatch) {
|
||||
Log.log(LogMessageType.GENERAL, LogLevels.VERBOSE) { "Starting file watcher service..." }
|
||||
FileWatcherService.start()
|
||||
Log.log(LogMessageType.GENERAL, LogLevels.VERBOSE) { "File watcher service started!" }
|
||||
}
|
||||
|
||||
private fun loadLanguageFiles(latch: CountUpAndDownLatch) {
|
||||
private fun loadLanguageFiles(latch: AbstractLatch) {
|
||||
val language = ErosProfileManager.selected.general.language
|
||||
ErosProfileManager.selected.general::language.observe(this, true) {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Loading language files (${language})" }
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.assets
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.assets.minecraft.JarAssetsManager
|
||||
import de.bixilon.minosoft.assets.minecraft.index.IndexAssetsManager
|
||||
@ -25,7 +25,7 @@ import de.bixilon.minosoft.protocol.versions.Version
|
||||
|
||||
object AssetsLoader {
|
||||
|
||||
fun create(profile: ResourcesProfile, version: Version, latch: CountUpAndDownLatch, property: AssetsVersionProperty = AssetsVersionProperties[version] ?: throw IllegalAccessException("$version has no assets!")): AssetsManager {
|
||||
fun create(profile: ResourcesProfile, version: Version, latch: AbstractLatch, property: AssetsVersionProperty = AssetsVersionProperties[version] ?: throw IllegalAccessException("$version has no assets!")): AssetsManager {
|
||||
val assetsManager = PriorityAssetsManager()
|
||||
|
||||
assetsManager += Minosoft.OVERRIDE_ASSETS_MANAGER
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.assets
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.assets.properties.manager.AssetsManagerProperties
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import java.io.FileNotFoundException
|
||||
@ -72,7 +72,7 @@ interface AssetsManager {
|
||||
/**
|
||||
* Loads all assets
|
||||
*/
|
||||
fun load(latch: CountUpAndDownLatch)
|
||||
fun load(latch: AbstractLatch? = null)
|
||||
|
||||
/**
|
||||
* Deletes all assets from memory
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.assets.directory
|
||||
|
||||
import de.bixilon.kutil.file.FileUtil.slashPath
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.assets.AssetsManager
|
||||
import de.bixilon.minosoft.assets.properties.manager.AssetsManagerProperties
|
||||
import de.bixilon.minosoft.assets.util.FileAssetsUtil.toAssetName
|
||||
@ -63,7 +63,7 @@ class DirectoryAssetsManager(
|
||||
}
|
||||
}
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
check(!loaded) { "Already loaded!" }
|
||||
scanDirectory(File(basePath))
|
||||
File("$rootPath/pack.png").let { if (it.exists() && it.isFile) image = FileInputStream(it).readAllBytes() }
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.assets.file
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.assets.AssetsManager
|
||||
import de.bixilon.minosoft.assets.util.FileAssetsUtil.toAssetName
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJson
|
||||
@ -36,7 +36,7 @@ class ZipAssetsManager(
|
||||
constructor(file: File, canUnload: Boolean = true, prefix: String = AssetsManager.DEFAULT_ASSETS_PREFIX) : this(ZipInputStream(FileInputStream(file)), canUnload, prefix)
|
||||
constructor(path: String, canUnload: Boolean = true, prefix: String = AssetsManager.DEFAULT_ASSETS_PREFIX) : this(File(path), canUnload, prefix)
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
check(!loaded) { "Already loaded!" }
|
||||
|
||||
val namespaces: MutableSet<String> = ObjectOpenHashSet()
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.assets.minecraft
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.string.StringUtil.formatPlaceholder
|
||||
import de.bixilon.kutil.url.URLUtil.toURL
|
||||
import de.bixilon.minosoft.assets.InvalidAssetException
|
||||
@ -87,7 +87,7 @@ class JarAssetsManager(
|
||||
return ByteArrayInputStream(downloaded.data).readZipArchive()
|
||||
}
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
check(!loaded) { "Already loaded!" }
|
||||
|
||||
if (tryLoadAssets()) {
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalTask
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.primitive.LongUtil.toLong
|
||||
import de.bixilon.kutil.string.StringUtil.formatPlaceholder
|
||||
import de.bixilon.kutil.url.URLUtil.toURL
|
||||
@ -88,7 +88,7 @@ class IndexAssetsManager(
|
||||
}
|
||||
}
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
check(!loaded) { "Already loaded!" }
|
||||
|
||||
var assets = readAssetsIndex()
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.assets.multi
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.assets.AssetsManager
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import java.io.FileNotFoundException
|
||||
@ -82,7 +82,7 @@ class PriorityAssetsManager(
|
||||
}
|
||||
}
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
for ((_, managers) in managers) {
|
||||
for (manager in managers) {
|
||||
if (manager.loaded) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.assets.properties.version
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJson
|
||||
import de.bixilon.minosoft.protocol.versions.Version
|
||||
@ -27,7 +27,7 @@ object AssetsVersionProperties {
|
||||
private val ASSETS_PROPERTIES_FILE = "minosoft:mapping/assets_properties.json".toResourceLocation()
|
||||
private val PROPERTIES: MutableMap<Version, AssetsVersionProperty> = mutableMapOf()
|
||||
|
||||
fun load(latch: CountUpAndDownLatch) {
|
||||
fun load(latch: AbstractLatch?) {
|
||||
if (PROPERTIES.isNotEmpty()) {
|
||||
throw IllegalStateException("Already loaded!")
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
package de.bixilon.minosoft.assets.properties.version.generator
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceInit
|
||||
import de.bixilon.minosoft.assets.InvalidAssetException
|
||||
import de.bixilon.minosoft.assets.minecraft.JarAssetsManager
|
||||
@ -39,7 +38,7 @@ object AssetsPropertiesGenerator {
|
||||
|
||||
val assetsManager = JarAssetsManager("829c3804401b0727f70f73d4415e162400cbe57b", clientJarHash, profile, Version(versionId, -1, -1, VersionTypes.APRIL_FOOL, emptyMap(), emptyMap()))
|
||||
try {
|
||||
assetsManager.load(CountUpAndDownLatch(1))
|
||||
assetsManager.load()
|
||||
} catch (exception: InvalidAssetException) {
|
||||
// this exception is thrown, because our initial hash is "dummy"
|
||||
stream.print(exception.hash + ":" + exception.tarBytes)
|
||||
|
@ -22,7 +22,7 @@ import de.bixilon.kutil.concurrent.schedule.RepeatedTask
|
||||
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
|
||||
import de.bixilon.kutil.file.FileUtil
|
||||
import de.bixilon.kutil.file.FileUtil.read
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.config.profile.profiles.Profile
|
||||
import de.bixilon.minosoft.config.profile.profiles.account.AccountProfileManager
|
||||
import de.bixilon.minosoft.config.profile.profiles.audio.AudioProfileManager
|
||||
@ -39,6 +39,7 @@ import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileMan
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport.Companion.crash
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
import de.bixilon.minosoft.util.KUtil.child
|
||||
import de.bixilon.minosoft.util.json.Jackson
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
@ -117,13 +118,13 @@ object GlobalProfileManager {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun initialize(latch: CountUpAndDownLatch) {
|
||||
fun initialize(latch: AbstractLatch?) {
|
||||
if (initialized) {
|
||||
throw IllegalStateException("Already initialized!")
|
||||
}
|
||||
Log.log(LogMessageType.PROFILES, LogLevels.VERBOSE) { "Loading profiles..." }
|
||||
loadSelectedProfiles()
|
||||
val innerLatch = CountUpAndDownLatch(1, latch)
|
||||
val innerLatch = latch.child(1)
|
||||
for ((namespace, manager) in DEFAULT_MANAGERS) {
|
||||
innerLatch.inc()
|
||||
DefaultThreadPool += { manager.load(selectedProfiles[namespace]);innerLatch.dec() }
|
||||
|
@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo
|
||||
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.minosoft.config.profile.profiles.account.AccountProfileManager
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.server.entries.AbstractServer
|
||||
@ -57,10 +57,10 @@ abstract class Account(
|
||||
abstract fun join(serverId: String)
|
||||
|
||||
abstract fun logout(clientToken: String)
|
||||
abstract fun check(latch: CountUpAndDownLatch?, clientToken: String)
|
||||
abstract fun check(latch: AbstractLatch?, clientToken: String)
|
||||
|
||||
@Synchronized
|
||||
open fun tryCheck(latch: CountUpAndDownLatch?, clientToken: String) {
|
||||
open fun tryCheck(latch: AbstractLatch?, clientToken: String) {
|
||||
if (state == AccountStates.CHECKING || state == AccountStates.REFRESHING) {
|
||||
// already checking
|
||||
return
|
||||
@ -84,5 +84,5 @@ abstract class Account(
|
||||
}
|
||||
}
|
||||
|
||||
open fun fetchKey(latch: CountUpAndDownLatch?): MinecraftPrivateKey? = null
|
||||
open fun fetchKey(latch: AbstractLatch?): MinecraftPrivateKey? = null
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import de.bixilon.kutil.concurrent.lock.simple.SimpleLock
|
||||
import de.bixilon.kutil.exception.Broken
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.config.profile.profiles.account.AccountProfileManager
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
@ -25,6 +25,7 @@ import de.bixilon.minosoft.data.accounts.AccountStates
|
||||
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
|
||||
import de.bixilon.minosoft.data.registries.identified.Identified
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.util.KUtil.child
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.account.AccountUtil
|
||||
import de.bixilon.minosoft.util.account.microsoft.MicrosoftOAuthUtils
|
||||
@ -60,20 +61,20 @@ class MicrosoftAccount(
|
||||
override fun logout(clientToken: String) = Unit
|
||||
|
||||
@Synchronized
|
||||
override fun check(latch: CountUpAndDownLatch?, @Nullable clientToken: String) {
|
||||
val innerLatch = CountUpAndDownLatch(1, latch)
|
||||
override fun check(latch: AbstractLatch?, @Nullable clientToken: String) {
|
||||
val innerLatch = latch?.child(1)
|
||||
try {
|
||||
this.error = null
|
||||
checkMinecraftToken(innerLatch)
|
||||
innerLatch.dec()
|
||||
innerLatch?.dec()
|
||||
state = AccountStates.WORKING
|
||||
} catch (exception: ConnectException) {
|
||||
innerLatch.count = 0
|
||||
innerLatch?.count = 0
|
||||
Log.log(LogMessageType.AUTHENTICATION, LogLevels.INFO) { "Could not check account ($this), we are probably offline" }
|
||||
Log.log(LogMessageType.AUTHENTICATION, LogLevels.VERBOSE) { exception }
|
||||
this.state = AccountStates.OFFLINE
|
||||
} catch (exception: Throwable) {
|
||||
innerLatch.count = 0
|
||||
innerLatch?.count = 0
|
||||
this.error = exception
|
||||
this.state = AccountStates.ERRORED
|
||||
Log.log(LogMessageType.AUTHENTICATION, LogLevels.VERBOSE) { exception }
|
||||
@ -81,7 +82,7 @@ class MicrosoftAccount(
|
||||
}
|
||||
}
|
||||
|
||||
override fun tryCheck(latch: CountUpAndDownLatch?, clientToken: String) {
|
||||
override fun tryCheck(latch: AbstractLatch?, clientToken: String) {
|
||||
if (state == AccountStates.CHECKING || state == AccountStates.REFRESHING) {
|
||||
// already checking
|
||||
return
|
||||
@ -96,14 +97,14 @@ class MicrosoftAccount(
|
||||
check(latch, clientToken)
|
||||
}
|
||||
|
||||
private fun refreshMicrosoftToken(latch: CountUpAndDownLatch?) {
|
||||
private fun refreshMicrosoftToken(latch: AbstractLatch?) {
|
||||
state = AccountStates.REFRESHING
|
||||
latch?.inc()
|
||||
msa = MicrosoftOAuthUtils.refreshToken(msa).saveTokens()
|
||||
latch?.dec()
|
||||
}
|
||||
|
||||
private fun refreshMinecraftToken(latch: CountUpAndDownLatch?) {
|
||||
private fun refreshMinecraftToken(latch: AbstractLatch?) {
|
||||
state = AccountStates.REFRESHING
|
||||
val time = millis() / 1000
|
||||
if (time >= msa.expires) {
|
||||
@ -127,7 +128,7 @@ class MicrosoftAccount(
|
||||
save()
|
||||
}
|
||||
|
||||
private fun checkMinecraftToken(latch: CountUpAndDownLatch?) {
|
||||
private fun checkMinecraftToken(latch: AbstractLatch?) {
|
||||
state = AccountStates.CHECKING
|
||||
val time = millis() / 1000
|
||||
if (time >= minecraft.expires) {
|
||||
@ -147,7 +148,7 @@ class MicrosoftAccount(
|
||||
}
|
||||
}
|
||||
|
||||
override fun fetchKey(latch: CountUpAndDownLatch?): MinecraftPrivateKey {
|
||||
override fun fetchKey(latch: AbstractLatch?): MinecraftPrivateKey {
|
||||
var key = key
|
||||
if (key == null || key.shouldRefresh() || key.signatureV2 == null) {
|
||||
keyLock.lock()
|
||||
|
@ -17,7 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.uuid.UUIDUtil.toUUID
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.data.accounts.AccountStates
|
||||
@ -65,7 +65,7 @@ class MojangAccount(
|
||||
Log.log(LogMessageType.AUTHENTICATION, LogLevels.VERBOSE) { "Mojang account login successful (username=$username)" }
|
||||
}
|
||||
|
||||
override fun check(latch: CountUpAndDownLatch?, clientToken: String) {
|
||||
override fun check(latch: AbstractLatch?, clientToken: String) {
|
||||
if (refreshed) {
|
||||
return
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.data.accounts.types.offline
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.data.accounts.AccountStates
|
||||
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
|
||||
@ -41,7 +41,7 @@ class OfflineAccount(username: String) : Account(username) {
|
||||
|
||||
override fun logout(clientToken: String) = Unit
|
||||
|
||||
override fun check(latch: CountUpAndDownLatch?, clientToken: String) = Unit
|
||||
override fun check(latch: AbstractLatch?, clientToken: String) = Unit
|
||||
|
||||
override fun toString(): String {
|
||||
return "OfflineAccount{$username}"
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.entities.entities.player.local
|
||||
|
||||
import de.bixilon.kutil.concurrent.lock.simple.SimpleLock
|
||||
import de.bixilon.kutil.concurrent.schedule.TaskScheduler.runLater
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.data.accounts.Account
|
||||
import de.bixilon.minosoft.data.chat.message.internal.InternalChatMessage
|
||||
@ -39,7 +39,7 @@ class SignatureKeyManagement(
|
||||
var key: PlayerPrivateKey? = null
|
||||
private set
|
||||
|
||||
fun init(latch: CountUpAndDownLatch?) {
|
||||
fun init(latch: AbstractLatch?) {
|
||||
if (key != null) throw IllegalStateException("Already initialized!")
|
||||
fetchKey(latch)
|
||||
}
|
||||
@ -71,7 +71,7 @@ class SignatureKeyManagement(
|
||||
sendSession()
|
||||
}
|
||||
|
||||
private fun fetchKey(latch: CountUpAndDownLatch?) {
|
||||
private fun fetchKey(latch: AbstractLatch?) {
|
||||
lock.lock()
|
||||
try {
|
||||
account.fetchKey(latch)?.let { updateKey(it) }
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.registries.registries
|
||||
|
||||
import de.bixilon.kutil.json.JsonObject
|
||||
import de.bixilon.kutil.json.JsonUtil.toJsonObject
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.string.StringUtil.formatPlaceholder
|
||||
import de.bixilon.kutil.url.URLUtil.toURL
|
||||
import de.bixilon.minosoft.assets.properties.version.AssetsVersionProperties
|
||||
@ -55,7 +55,7 @@ object PixLyzerUtil {
|
||||
return verify(profile.source.pixlyzer, pixlyzerHash)
|
||||
}
|
||||
|
||||
fun loadRegistry(version: Version, profile: ResourcesProfile, latch: CountUpAndDownLatch): Registries {
|
||||
fun loadRegistry(version: Version, profile: ResourcesProfile, latch: AbstractLatch): Registries {
|
||||
val registries = Registries()
|
||||
val data = loadPixlyzerData(version, profile)
|
||||
|
||||
|
@ -18,7 +18,8 @@ import de.bixilon.kutil.concurrent.worker.task.WorkerTask
|
||||
import de.bixilon.kutil.json.JsonObject
|
||||
import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||
import de.bixilon.kutil.json.JsonUtil.toJsonObject
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.minosoft.data.container.equipment.EquipmentSlots
|
||||
import de.bixilon.minosoft.data.entities.EntityAnimations
|
||||
import de.bixilon.minosoft.data.entities.block.BlockDataDataType
|
||||
@ -146,7 +147,7 @@ class Registries(
|
||||
return entityDataIndexMap[field] ?: parent?.getEntityDataIndex(field)
|
||||
}
|
||||
|
||||
fun load(version: Version, pixlyzerData: Map<String, Any>, latch: CountUpAndDownLatch) {
|
||||
fun load(version: Version, pixlyzerData: Map<String, Any>, latch: AbstractLatch) {
|
||||
isFlattened = version.flattened
|
||||
block.flattened = isFlattened
|
||||
blockState.flattened = isFlattened
|
||||
@ -207,7 +208,7 @@ class Registries(
|
||||
worker += WorkerTask(this::statistic) { statistic.rawUpdate(pixlyzerData["statistics"]?.toJsonObject(), this) }
|
||||
worker += WorkerTask(this::misc, dependencies = arrayOf(this::item)) { misc.rawUpdate(pixlyzerData["misc"]?.toJsonObject(), this) }
|
||||
|
||||
val inner = CountUpAndDownLatch(1, latch)
|
||||
val inner = ParentLatch(1, latch)
|
||||
worker.work(inner)
|
||||
inner.dec()
|
||||
while (inner.count > 0) {
|
||||
|
@ -13,14 +13,14 @@
|
||||
|
||||
package de.bixilon.minosoft.data.registries.registries
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
|
||||
import de.bixilon.minosoft.data.registries.fallback.FallbackRegistries
|
||||
import de.bixilon.minosoft.protocol.versions.Version
|
||||
|
||||
object RegistriesLoader {
|
||||
|
||||
fun load(profile: ResourcesProfile, version: Version, latch: CountUpAndDownLatch): Registries {
|
||||
fun load(profile: ResourcesProfile, version: Version, latch: AbstractLatch): Registries {
|
||||
if (!version.flattened) {
|
||||
// ToDo: Pre flattening support
|
||||
throw PreFlatteningLoadingError()
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.dialog
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.kutil.shutdown.AbstractShutdownReason
|
||||
import de.bixilon.kutil.shutdown.ShutdownManager
|
||||
import de.bixilon.minosoft.data.text.TranslatableComponents
|
||||
@ -28,7 +28,7 @@ import javafx.scene.control.ProgressBar
|
||||
import javafx.scene.text.TextFlow
|
||||
|
||||
class StartingDialog(
|
||||
val latch: CountUpAndDownLatch,
|
||||
val latch: CallbackLatch,
|
||||
) : DialogController() {
|
||||
@FXML private lateinit var headerFX: TextFlow
|
||||
@FXML private lateinit var countTextFX: TextFlow
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.dialog.connection
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.minosoft.gui.eros.dialog.progress.ProgressDialog
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
||||
@ -22,7 +22,7 @@ import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import de.bixilon.minosoft.util.delegate.JavaFXDelegate.observeFX
|
||||
|
||||
class LoadingDialog(
|
||||
latch: CountUpAndDownLatch,
|
||||
latch: CallbackLatch,
|
||||
connection: PlayConnection,
|
||||
) : ProgressDialog(title = TITLE, header = HEADER, latch = latch) {
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.dialog.connection
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.minosoft.gui.eros.dialog.progress.ProgressDialog
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
@ -21,7 +21,7 @@ import javafx.fxml.FXML
|
||||
import javafx.scene.text.TextFlow
|
||||
|
||||
class VerifyAssetsDialog(
|
||||
latch: CountUpAndDownLatch,
|
||||
latch: CallbackLatch,
|
||||
) : ProgressDialog(title = TITLE, header = HEADER, latch = latch, layout = LAYOUT) {
|
||||
@FXML private lateinit var mibTextFX: TextFlow
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.eros.dialog.progress
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.eros.controller.DialogController
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
@ -29,7 +29,7 @@ import javafx.scene.text.TextFlow
|
||||
open class ProgressDialog(
|
||||
private val title: ResourceLocation,
|
||||
private val header: ResourceLocation,
|
||||
val latch: CountUpAndDownLatch,
|
||||
val latch: CallbackLatch,
|
||||
private val onCancel: (() -> Unit)? = null,
|
||||
private val layout: ResourceLocation = LAYOUT,
|
||||
) : DialogController() {
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.eros.main.account
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.CollectionUtil.extend
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.kutil.observer.map.MapChange.Companion.values
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
@ -132,7 +132,7 @@ class AccountController : EmbeddedJavaFXController<Pane>() {
|
||||
return
|
||||
}
|
||||
Log.log(LogMessageType.AUTHENTICATION, LogLevels.INFO) { "Checking account $account" }
|
||||
val latch = CountUpAndDownLatch(2)
|
||||
val latch = CallbackLatch(2)
|
||||
val dialog = CheckingDialog(latch)
|
||||
dialog.show()
|
||||
DefaultThreadPool += {
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.main.account
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.minosoft.gui.eros.controller.DialogController
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil
|
||||
import de.bixilon.minosoft.gui.eros.util.JavaFXUtil.text
|
||||
@ -24,7 +24,7 @@ import javafx.scene.control.ProgressBar
|
||||
import javafx.scene.text.TextFlow
|
||||
|
||||
class CheckingDialog(
|
||||
val latch: CountUpAndDownLatch,
|
||||
val latch: CallbackLatch,
|
||||
) : DialogController() {
|
||||
@FXML private lateinit var headerFX: TextFlow
|
||||
@FXML private lateinit var progressFX: ProgressBar
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.eros.main.account.add
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
|
||||
import de.bixilon.minosoft.data.accounts.types.microsoft.MicrosoftAccount
|
||||
@ -72,7 +72,7 @@ class MicrosoftAddController(
|
||||
|
||||
private fun successCallback(response: AuthenticationResponse) {
|
||||
JavaFXUtil.runLater { close() }
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = CallbackLatch(1)
|
||||
val checkingDialog = CheckingDialog(latch)
|
||||
checkingDialog.show()
|
||||
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.eros.main.play.server
|
||||
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool.async
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.CallbackLatch
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.primitive.IntUtil.thousands
|
||||
import de.bixilon.kutil.unit.UnitFormatter.formatNanos
|
||||
@ -178,7 +178,7 @@ class ServerListController : EmbeddedJavaFXController<Pane>(), Refreshable {
|
||||
reason = event.reason,
|
||||
).show()
|
||||
})
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = CallbackLatch(1)
|
||||
val assetsDialog = VerifyAssetsDialog(latch = latch).apply { show() }
|
||||
connection::state.observeFX(serverCard) {
|
||||
if (it == PlayConnectionStates.LOADING || it.disconnected) {
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.eros.util
|
||||
import afester.javafx.svg.SvgLoader
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.exception.ExceptionUtil.catchAll
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.shutdown.ShutdownManager
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport.Companion.crash
|
||||
@ -49,7 +49,7 @@ class JavaFXInitializer internal constructor() : Application() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LATCH = CountUpAndDownLatch(2)
|
||||
private val LATCH = SimpleLatch(2)
|
||||
|
||||
val initialized: Boolean
|
||||
get() = LATCH.count == 0
|
||||
|
@ -15,7 +15,9 @@ package de.bixilon.minosoft.gui.rendering
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
@ -48,7 +50,7 @@ object RenderLoader {
|
||||
}
|
||||
}
|
||||
|
||||
fun RenderContext.load(latch: CountUpAndDownLatch) {
|
||||
fun RenderContext.load(latch: AbstractLatch) {
|
||||
setThread()
|
||||
Log.log(LogMessageType.RENDERING_LOADING) { "Creating window..." }
|
||||
val stopwatch = Stopwatch()
|
||||
@ -71,7 +73,7 @@ object RenderLoader {
|
||||
renderSystem.reset()
|
||||
|
||||
// Init stage
|
||||
val initLatch = CountUpAndDownLatch(1, latch)
|
||||
val initLatch = ParentLatch(1, latch)
|
||||
Log.log(LogMessageType.RENDERING_LOADING, LogLevels.VERBOSE) { "Generating font and gathering textures (after ${stopwatch.labTime()})..." }
|
||||
textureManager.dynamicTextures.load(initLatch)
|
||||
textureManager.initializeSkins(connection)
|
||||
@ -141,7 +143,7 @@ object RenderLoader {
|
||||
fun RenderContext.awaitPlaying() {
|
||||
state = RenderingStates.AWAITING
|
||||
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
|
||||
connection::state.observe(this) {
|
||||
if (it == PlayConnectionStates.PLAYING && latch.count > 0) {
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
|
||||
import de.bixilon.kutil.concurrent.pool.runnable.SimplePoolRunnable
|
||||
import de.bixilon.minosoft.gui.eros.crash.ErosCrashReport.Companion.crash
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
|
||||
@ -31,7 +31,7 @@ object RenderUtil {
|
||||
}
|
||||
|
||||
fun RenderContext.runAsync(runnable: () -> Unit) {
|
||||
DefaultThreadPool += ThreadPoolRunnable(ThreadPool.HIGHER, forcePool = false) {
|
||||
DefaultThreadPool += SimplePoolRunnable(ThreadPool.HIGHER) {
|
||||
try {
|
||||
runnable()
|
||||
} catch (error: Throwable) {
|
||||
|
@ -13,7 +13,8 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.minosoft.gui.RenderLoop
|
||||
import de.bixilon.minosoft.gui.rendering.RenderLoader.awaitPlaying
|
||||
import de.bixilon.minosoft.gui.rendering.RenderLoader.load
|
||||
@ -29,18 +30,18 @@ class Rendering(private val connection: PlayConnection) {
|
||||
val context: RenderContext = RenderContext(connection, this)
|
||||
val audioPlayer: AudioPlayer = AudioPlayer(connection, this)
|
||||
|
||||
fun start(latch: CountUpAndDownLatch, render: Boolean = true, audio: Boolean = true) {
|
||||
fun start(latch: AbstractLatch, render: Boolean = true, audio: Boolean = true) {
|
||||
Log.log(LogMessageType.RENDERING_GENERAL, LogLevels.INFO) { "Hello LWJGL ${Version.getVersion()}!" }
|
||||
latch.inc()
|
||||
if (audio) startAudioPlayerThread(latch)
|
||||
if (render) startRenderWindowThread(latch)
|
||||
}
|
||||
|
||||
private fun startAudioPlayerThread(latch: CountUpAndDownLatch) {
|
||||
private fun startAudioPlayerThread(latch: AbstractLatch) {
|
||||
if (connection.profiles.audio.skipLoading) {
|
||||
return
|
||||
}
|
||||
val audioLatch = CountUpAndDownLatch(1, latch)
|
||||
val audioLatch = ParentLatch(1, latch)
|
||||
Thread({
|
||||
try {
|
||||
Thread.currentThread().priority = Thread.MAX_PRIORITY
|
||||
@ -60,11 +61,11 @@ class Rendering(private val connection: PlayConnection) {
|
||||
}, "Audio#${connection.connectionId}").start()
|
||||
}
|
||||
|
||||
private fun startRenderWindowThread(latch: CountUpAndDownLatch) {
|
||||
private fun startRenderWindowThread(latch: AbstractLatch) {
|
||||
Thread({ startRenderWindow(latch) }, "Rendering#${connection.connectionId}").start()
|
||||
}
|
||||
|
||||
private fun startRenderWindow(latch: CountUpAndDownLatch) {
|
||||
private fun startRenderWindow(latch: AbstractLatch) {
|
||||
try {
|
||||
Thread.currentThread().priority = Thread.MAX_PRIORITY
|
||||
CONTEXT_MAP[Thread.currentThread()] = context
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.camera
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.data.entities.entities.player.local.LocalPlayerEntity
|
||||
@ -47,7 +47,7 @@ class Camera(
|
||||
}
|
||||
view.draw()
|
||||
matrixHandler.draw()
|
||||
val latch = CountUpAndDownLatch(2)
|
||||
val latch = SimpleLatch(2)
|
||||
context.runAsync { visibilityGraph.draw(); latch.dec() }
|
||||
context.runAsync { context.connection.camera.target.update(); latch.dec() }
|
||||
fogManager.draw()
|
||||
|
@ -20,7 +20,7 @@ import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalTask
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
@ -63,7 +63,7 @@ class EntityRenderer(
|
||||
|
||||
private var reset = false
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
override fun init(latch: AbstractLatch) {
|
||||
connection.events.listen<EntitySpawnEvent> { event ->
|
||||
if (event.entity is LocalPlayerEntity) return@listen
|
||||
DefaultThreadPool += { event.entity.createModel(this)?.let { models[event.entity] = it } }
|
||||
@ -92,7 +92,7 @@ class EntityRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
override fun postAsyncInit(latch: CountUpAndDownLatch) {
|
||||
override fun postAsyncInit(latch: AbstractLatch) {
|
||||
localModel = context.connection.player.createModel(this)
|
||||
|
||||
models[connection.player] = localModel
|
||||
|
@ -14,15 +14,16 @@
|
||||
package de.bixilon.minosoft.gui.rendering.font
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.minosoft.gui.rendering.font.provider.FontProvider
|
||||
|
||||
class Font(
|
||||
val providers: Array<FontProvider>,
|
||||
) : FontProvider {
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
val fontLatch = CountUpAndDownLatch(1, latch)
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
val fontLatch = ParentLatch(1, latch)
|
||||
for (provider in providers) {
|
||||
fontLatch.inc()
|
||||
DefaultThreadPool += {
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.font
|
||||
|
||||
import de.bixilon.kutil.array.ArrayUtil.trim
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJsonObject
|
||||
import de.bixilon.minosoft.data.registries.factory.DefaultFactory
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
@ -35,7 +35,7 @@ object FontLoader : DefaultFactory<FontProviderFactory<*>>(
|
||||
private val FONT_INDEX = "font/default.json".toResourceLocation()
|
||||
|
||||
|
||||
fun load(context: RenderContext, latch: CountUpAndDownLatch): Font {
|
||||
fun load(context: RenderContext, latch: AbstractLatch): Font {
|
||||
val fontIndex = context.connection.assetsManager.getOrNull(FONT_INDEX)?.readJsonObject() ?: return Font(arrayOf())
|
||||
|
||||
val providersRaw = fontIndex["providers"].listCast<Map<String, Any>>()!!
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.font.provider
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.json.JsonUtil.asJsonList
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.primitive.DoubleUtil.toDouble
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
||||
@ -113,7 +113,7 @@ class BitmapFontProvider(
|
||||
textureData.rewind()
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
latch.inc()
|
||||
for (char in chars.values) {
|
||||
char.postInit()
|
||||
|
@ -13,12 +13,12 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.font.provider
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.gui.rendering.font.CharData
|
||||
|
||||
interface FontProvider {
|
||||
|
||||
fun postInit(latch: CountUpAndDownLatch)
|
||||
fun postInit(latch: AbstractLatch)
|
||||
|
||||
|
||||
operator fun get(char: Int): CharData?
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.font.provider
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.primitive.IntUtil.toHex
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
@ -84,7 +84,7 @@ class LegacyUnicodeFontProvider(
|
||||
}
|
||||
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
for (char in chars) {
|
||||
char?.postInit()
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.font.provider
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kutil.json.JsonUtil.toJsonObject
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
@ -38,7 +38,7 @@ class SpaceFontProvider(
|
||||
}
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) = Unit
|
||||
override fun postInit(latch: AbstractLatch) = Unit
|
||||
|
||||
override fun get(char: Int): CharData? {
|
||||
return chars[char]
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.gui
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.gui.rendering.RenderUtil.runAsync
|
||||
import de.bixilon.minosoft.gui.rendering.gui.elements.Pollable
|
||||
@ -28,7 +28,7 @@ interface GUIElementDrawer {
|
||||
|
||||
fun tickElements(elements: Collection<GUIElement>) {
|
||||
val time = millis()
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
if (time - lastTickTime > ProtocolDefinition.TICK_TIME) {
|
||||
for (element in elements) {
|
||||
if (!element.enabled) {
|
||||
@ -53,7 +53,7 @@ interface GUIElementDrawer {
|
||||
}
|
||||
|
||||
fun prepareElements(elements: Collection<GUIElement>) {
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
for (element in elements) {
|
||||
if (!element.enabled) {
|
||||
continue
|
||||
@ -77,7 +77,7 @@ interface GUIElementDrawer {
|
||||
}
|
||||
|
||||
fun drawElements(elements: Collection<GUIElement>) {
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
for (element in elements) {
|
||||
if (!element.enabled) {
|
||||
continue
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.gui
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec2.Vec2d
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
@ -66,7 +66,7 @@ class GUIRenderer(
|
||||
var currentMousePosition: Vec2i by observed(Vec2i.EMPTY)
|
||||
private set
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
override fun init(latch: AbstractLatch) {
|
||||
atlasManager.init()
|
||||
gui.init()
|
||||
hud.init()
|
||||
@ -74,7 +74,7 @@ class GUIRenderer(
|
||||
dragged.init()
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
atlasManager.postInit()
|
||||
shader.load()
|
||||
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.concurrent.lock.simple.SimpleLock
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
@ -116,7 +116,7 @@ class GUIManager(
|
||||
if (tick) {
|
||||
lastTickTime = time
|
||||
}
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
for ((index, element) in order.withIndex()) {
|
||||
if (!element.enabled) {
|
||||
continue
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.gui.gui.popper
|
||||
import de.bixilon.kotlinglm.vec2.Vec2d
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||
@ -48,7 +48,7 @@ class PopperManager(
|
||||
lastTickTime = time
|
||||
}
|
||||
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
for (popper in poppers) {
|
||||
if (popper.layout.dead) {
|
||||
toRemove += popper
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.kutil.collections.CollectionUtil.lockMapOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedMap
|
||||
import de.bixilon.kutil.collections.map.LockMap
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
@ -65,7 +65,7 @@ class HUDManager(
|
||||
}
|
||||
|
||||
private fun registerDefaultElements() {
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
|
||||
for (builder in DEFAULT_ELEMENTS) {
|
||||
latch.inc()
|
||||
|
@ -17,7 +17,8 @@ import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedMap
|
||||
import de.bixilon.kutil.collections.map.SynchronizedMap
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJsonObject
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||
import de.bixilon.minosoft.data.registries.fluid.Fluid
|
||||
@ -101,8 +102,8 @@ class ModelLoader(
|
||||
return model
|
||||
}
|
||||
|
||||
private fun loadBlockModels(latch: CountUpAndDownLatch) {
|
||||
val blockLatch = CountUpAndDownLatch(1, latch)
|
||||
private fun loadBlockModels(latch: AbstractLatch) {
|
||||
val blockLatch = ParentLatch(1, latch)
|
||||
// ToDo: Optimize performance
|
||||
Log.log(LogMessageType.VERSION_LOADING, LogLevels.VERBOSE) { "Loading block models..." }
|
||||
|
||||
@ -122,9 +123,9 @@ class ModelLoader(
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadItemModels(latch: CountUpAndDownLatch) {
|
||||
private fun loadItemModels(latch: AbstractLatch) {
|
||||
Log.log(LogMessageType.VERSION_LOADING, LogLevels.VERBOSE) { "Loading item models..." }
|
||||
val itemLatch = CountUpAndDownLatch(1, latch)
|
||||
val itemLatch = ParentLatch(1, latch)
|
||||
|
||||
|
||||
for (item in registry.item) {
|
||||
@ -135,9 +136,9 @@ class ModelLoader(
|
||||
itemLatch.await()
|
||||
}
|
||||
|
||||
private fun loadEntityModels(latch: CountUpAndDownLatch) {
|
||||
private fun loadEntityModels(latch: AbstractLatch) {
|
||||
Log.log(LogMessageType.VERSION_LOADING, LogLevels.VERBOSE) { "Loading entity models..." }
|
||||
val innerLatch = CountUpAndDownLatch(DefaultEntityModels.MODELS.size, latch)
|
||||
val innerLatch = ParentLatch(DefaultEntityModels.MODELS.size, latch)
|
||||
|
||||
for (register in DefaultEntityModels.MODELS) {
|
||||
DefaultThreadPool += { register.register(context, this); innerLatch.dec() }
|
||||
@ -145,7 +146,7 @@ class ModelLoader(
|
||||
innerLatch.await()
|
||||
}
|
||||
|
||||
fun load(latch: CountUpAndDownLatch) {
|
||||
fun load(latch: AbstractLatch) {
|
||||
loadBlockModels(latch)
|
||||
loadFluidModels()
|
||||
loadItemModels(latch)
|
||||
|
@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kutil.concurrent.lock.simple.SimpleLock
|
||||
import de.bixilon.kutil.concurrent.schedule.RepeatedTask
|
||||
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||
@ -99,7 +99,7 @@ class ParticleRenderer(
|
||||
val size: Int
|
||||
get() = particles.size
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
override fun init(latch: AbstractLatch) {
|
||||
profile::maxAmount.observe(this, true) { maxAmount = minOf(it, MAXIMUM_AMOUNT) }
|
||||
profile::enabled.observe(this, true) { enabled = it }
|
||||
|
||||
@ -118,7 +118,7 @@ class ParticleRenderer(
|
||||
DefaultParticleBehavior.register(connection, this)
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
transparentShader.load()
|
||||
translucentShader.load()
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.renderer.renderer
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.PolygonModes
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem
|
||||
@ -27,11 +27,11 @@ interface Renderer {
|
||||
val polygonMode: PolygonModes
|
||||
get() = context.framebufferManager.world.polygonMode
|
||||
|
||||
fun preAsyncInit(latch: CountUpAndDownLatch) = Unit
|
||||
fun init(latch: CountUpAndDownLatch) = Unit
|
||||
fun asyncInit(latch: CountUpAndDownLatch) = Unit
|
||||
fun postInit(latch: CountUpAndDownLatch) = Unit
|
||||
fun postAsyncInit(latch: CountUpAndDownLatch) = Unit
|
||||
fun preAsyncInit(latch: AbstractLatch) = Unit
|
||||
fun init(latch: AbstractLatch) = Unit
|
||||
fun asyncInit(latch: AbstractLatch) = Unit
|
||||
fun postInit(latch: AbstractLatch) = Unit
|
||||
fun postAsyncInit(latch: AbstractLatch) = Unit
|
||||
|
||||
fun prePrepareDraw() = Unit
|
||||
fun postPrepareDraw() = Unit
|
||||
|
@ -18,7 +18,9 @@ import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalTask
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.PostDrawable
|
||||
@ -64,8 +66,8 @@ class RendererManager(
|
||||
return renderers[resourceLocation]
|
||||
}
|
||||
|
||||
fun init(latch: CountUpAndDownLatch) {
|
||||
val inner = CountUpAndDownLatch(0, latch)
|
||||
fun init(latch: AbstractLatch) {
|
||||
val inner = ParentLatch(0, latch)
|
||||
var worker = UnconditionalWorker()
|
||||
for (renderer in renderers.values) {
|
||||
worker += { renderer.preAsyncInit(inner) }
|
||||
@ -83,11 +85,11 @@ class RendererManager(
|
||||
worker.work(inner)
|
||||
}
|
||||
|
||||
fun postInit(latch: CountUpAndDownLatch) {
|
||||
fun postInit(latch: AbstractLatch) {
|
||||
for (renderer in renderers.values) {
|
||||
renderer.postInit(latch)
|
||||
}
|
||||
val inner = CountUpAndDownLatch(0, latch)
|
||||
val inner = ParentLatch(0, latch)
|
||||
val worker = UnconditionalWorker()
|
||||
for (renderer in renderers.values) {
|
||||
worker += { renderer.postAsyncInit(inner) }
|
||||
@ -120,7 +122,7 @@ class RendererManager(
|
||||
renderer.prePrepareDraw()
|
||||
}
|
||||
|
||||
val latch = CountUpAndDownLatch(0)
|
||||
val latch = SimpleLatch(0)
|
||||
val worker = UnconditionalWorker()
|
||||
for (renderer in rendererList) {
|
||||
if (renderer !is AsyncRenderer) {
|
||||
|
@ -14,10 +14,9 @@
|
||||
package de.bixilon.minosoft.gui.rendering.sky
|
||||
|
||||
import de.bixilon.kotlinglm.mat4x4.Mat4
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.minosoft.data.registries.dimension.effects.OverworldEffects
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.events.CameraMatrixChangeEvent
|
||||
@ -35,7 +34,6 @@ import de.bixilon.minosoft.gui.rendering.system.base.buffer.frame.Framebuffer
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.phases.PreDrawable
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
|
||||
class SkyRenderer(
|
||||
val connection: PlayConnection,
|
||||
@ -57,7 +55,7 @@ class SkyRenderer(
|
||||
val sunScatter = SunScatterRenderer(this, sun)
|
||||
val moon = MoonRenderer(this)
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
override fun init(latch: AbstractLatch) {
|
||||
box.register()
|
||||
sunScatter.register()
|
||||
sun.register()
|
||||
@ -68,7 +66,7 @@ class SkyRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
for (renderer in renderer) {
|
||||
renderer.postInit()
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.sky.clouds
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kotlinglm.vec4.Vec4
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||
@ -69,7 +69,7 @@ class CloudRenderer(
|
||||
get() = !sky.effects.clouds || !sky.profile.clouds.enabled || connection.profiles.block.viewDistance < 3 || layers.isEmpty()
|
||||
|
||||
|
||||
override fun asyncInit(latch: CountUpAndDownLatch) {
|
||||
override fun asyncInit(latch: AbstractLatch) {
|
||||
matrix.load(connection.assetsManager)
|
||||
|
||||
context.camera.offset::offset.observe(this) { reset() }
|
||||
@ -83,7 +83,7 @@ class CloudRenderer(
|
||||
return IntRange(baseHeight + index * cloudHeight, baseHeight + (index + 1) * cloudHeight)
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
shader.load()
|
||||
sky.profile.clouds::movement.observe(this, instant = true) {
|
||||
for (layer in layers) {
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.kutil.collections.CollectionUtil.synchronizedListOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedList
|
||||
import de.bixilon.kutil.concurrent.queue.Queue
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.world.audio.AbstractAudioPlayer
|
||||
@ -67,7 +67,7 @@ class AudioPlayer(
|
||||
private var enabled = profile.enabled
|
||||
|
||||
|
||||
fun init(latch: CountUpAndDownLatch) {
|
||||
fun init(latch: AbstractLatch) {
|
||||
Log.log(LogMessageType.AUDIO, LogLevels.INFO) { "Loading OpenAL..." }
|
||||
|
||||
soundManager.load()
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.system.base.texture
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.PNGTexture
|
||||
@ -29,5 +29,5 @@ interface StaticTextureArray : TextureArray {
|
||||
|
||||
fun createTexture(resourceLocation: ResourceLocation, mipmaps: Boolean = true, default: () -> AbstractTexture = { PNGTexture(resourceLocation, generateMipMaps = mipmaps) }): AbstractTexture
|
||||
|
||||
fun preLoad(latch: CountUpAndDownLatch)
|
||||
fun preLoad(latch: AbstractLatch)
|
||||
}
|
||||
|
@ -13,13 +13,13 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.system.base.texture
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.gui.rendering.shader.Shader
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.ShaderUniforms
|
||||
|
||||
interface TextureArray {
|
||||
fun load(latch: CountUpAndDownLatch)
|
||||
fun load(latch: AbstractLatch?)
|
||||
|
||||
fun activate()
|
||||
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.system.opengl.texture
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readAsString
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
@ -86,7 +86,7 @@ class OpenGLTextureArray(
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun preLoad(latch: CountUpAndDownLatch) {
|
||||
override fun preLoad(latch: AbstractLatch) {
|
||||
if (state == TextureArrayStates.LOADED || state == TextureArrayStates.PRE_LOADED) {
|
||||
return
|
||||
}
|
||||
@ -172,7 +172,7 @@ class OpenGLTextureArray(
|
||||
|
||||
|
||||
@Synchronized
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
var totalLayers = 0
|
||||
for ((index, textures) in texturesByResolution.withIndex()) {
|
||||
if (textures.isEmpty()) {
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.system.opengl.texture.dynamic
|
||||
|
||||
import de.bixilon.kutil.concurrent.lock.thread.ThreadLock
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.ShaderUniforms
|
||||
@ -122,7 +122,7 @@ class OpenGLDynamicTextureArray(
|
||||
}
|
||||
|
||||
|
||||
override fun load(latch: CountUpAndDownLatch) {
|
||||
override fun load(latch: AbstractLatch?) {
|
||||
val textureId = OpenGLTextureUtil.createTextureArray()
|
||||
this.textureId = textureId
|
||||
|
||||
@ -169,7 +169,7 @@ class OpenGLDynamicTextureArray(
|
||||
private fun reload() {
|
||||
lock.lock()
|
||||
glDeleteTextures(textureId)
|
||||
load(CountUpAndDownLatch(0))
|
||||
load(null)
|
||||
|
||||
for ((index, textureReference) in textures.withIndex()) {
|
||||
val texture = textureReference?.get() ?: continue
|
||||
|
@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2
|
||||
import de.bixilon.kotlinglm.vec2.Vec2d
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.kutil.os.OSTypes
|
||||
import de.bixilon.kutil.os.PlatformInfo
|
||||
@ -430,7 +430,7 @@ class GLFWWindow(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val initLatch = CountUpAndDownLatch(1)
|
||||
private val initLatch = SimpleLatch(1)
|
||||
|
||||
init {
|
||||
if (PlatformInfo.OS == OSTypes.MAC) {
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.util
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
|
||||
import de.bixilon.kutil.concurrent.pool.runnable.ForcePooledRunnable
|
||||
import de.bixilon.kutil.file.FileUtil.createParent
|
||||
import de.bixilon.kutil.file.FileUtil.slashPath
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
@ -58,7 +58,7 @@ class ScreenshotTaker(
|
||||
}
|
||||
}
|
||||
|
||||
DefaultThreadPool += ThreadPoolRunnable(priority = ThreadPool.HIGHER) {
|
||||
DefaultThreadPool += ForcePooledRunnable(priority = ThreadPool.HIGHER) {
|
||||
try {
|
||||
val bufferedImage = BufferedImage(width, height, BufferedImage.TYPE_INT_RGB)
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.world
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
|
||||
import de.bixilon.kutil.concurrent.pool.runnable.InterruptableRunnable
|
||||
import de.bixilon.minosoft.gui.rendering.world.mesh.WorldMesh
|
||||
import de.bixilon.minosoft.gui.rendering.world.preparer.FluidSectionPreparer
|
||||
import de.bixilon.minosoft.gui.rendering.world.preparer.SolidSectionPreparer
|
||||
@ -50,7 +50,7 @@ class ChunkMesher(
|
||||
return mesh
|
||||
}
|
||||
|
||||
private fun mesh(item: WorldQueueItem, runnable: ThreadPoolRunnable) {
|
||||
private fun mesh(item: WorldQueueItem, runnable: InterruptableRunnable) {
|
||||
val mesh = mesh(item) ?: return
|
||||
runnable.interruptable = false
|
||||
if (Thread.interrupted()) return
|
||||
@ -62,7 +62,7 @@ class ChunkMesher(
|
||||
renderer.loadingQueue.queue(mesh)
|
||||
}
|
||||
|
||||
fun tryMesh(item: WorldQueueItem, task: MeshPrepareTask, runnable: ThreadPoolRunnable) {
|
||||
fun tryMesh(item: WorldQueueItem, task: MeshPrepareTask, runnable: InterruptableRunnable) {
|
||||
try {
|
||||
mesh(item, runnable)
|
||||
} catch (ignored: InterruptedException) {
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.world
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kutil.concurrent.lock.simple.SimpleLock
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
@ -89,11 +89,11 @@ class WorldRenderer(
|
||||
var cameraSectionHeight = 0
|
||||
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
override fun init(latch: AbstractLatch) {
|
||||
context.modelLoader.load(latch)
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
shader.load()
|
||||
transparentShader.load()
|
||||
textShader.load()
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.world.border
|
||||
|
||||
import de.bixilon.kotlinglm.func.common.clamp
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||
@ -48,7 +48,7 @@ class WorldBorderRenderer(
|
||||
get() = border.getDistanceTo(context.connection.player.physics.position) > MAX_DISTANCE
|
||||
private var reload = false
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
override fun init(latch: AbstractLatch) {
|
||||
shader.native.defines["MAX_DISTANCE"] = MAX_DISTANCE
|
||||
shader.load()
|
||||
|
||||
@ -56,7 +56,7 @@ class WorldBorderRenderer(
|
||||
context.camera.offset::offset.observe(this) { reload = true }
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
override fun postInit(latch: AbstractLatch) {
|
||||
context.textureManager.staticTextures.use(shader)
|
||||
shader.textureIndexLayer = texture.renderData.shaderTextureId
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.world.chunk
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
@ -58,7 +58,7 @@ class ChunkBorderRenderer(
|
||||
override val skipOpaque: Boolean
|
||||
get() = mesh == null || !profile.chunkBorder.enabled
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
override fun init(latch: AbstractLatch) {
|
||||
context.inputHandler.registerKeyCallback(
|
||||
CHUNK_BORDER_TOGGLE_KEY_COMBINATION,
|
||||
KeyBinding(
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.gui.rendering.world.entities
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJson
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||
@ -41,7 +41,7 @@ class EntityModels(val context: RenderContext) {
|
||||
}
|
||||
|
||||
fun loadSkeletal() {
|
||||
val latch = CountUpAndDownLatch(1)
|
||||
val latch = SimpleLatch(1)
|
||||
for (model in skeletal.values) {
|
||||
latch.inc()
|
||||
DefaultThreadPool += { model.preload(context); latch.dec() }
|
||||
|
@ -15,7 +15,7 @@ package de.bixilon.minosoft.gui.rendering.world.outline
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.minosoft.camera.target.targets.BlockTarget
|
||||
import de.bixilon.minosoft.data.abilities.Gamemodes
|
||||
@ -62,7 +62,7 @@ class BlockOutlineRenderer(
|
||||
override var nextMesh: LineMesh? = null
|
||||
override var unload: Boolean = false
|
||||
|
||||
override fun init(latch: CountUpAndDownLatch) {
|
||||
override fun init(latch: AbstractLatch) {
|
||||
this.profile::enabled.observe(this) { reload = true }
|
||||
this.profile::collisions.observe(this) { reload = true }
|
||||
this.profile::outlineColor.observe(this) { reload = true }
|
||||
|
@ -17,9 +17,8 @@ import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.concurrent.lock.simple.SimpleLock
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
|
||||
import de.bixilon.kutil.concurrent.pool.runnable.HeavyPoolRunnable
|
||||
import de.bixilon.minosoft.data.world.positions.ChunkPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.length2
|
||||
import de.bixilon.minosoft.gui.rendering.world.WorldQueueItem
|
||||
import de.bixilon.minosoft.gui.rendering.world.WorldRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.world.queue.QueuePosition
|
||||
@ -81,7 +80,7 @@ class ChunkMeshingQueue(
|
||||
}
|
||||
unlock()
|
||||
for (item in items) {
|
||||
val runnable = ThreadPoolRunnable(if (item.chunkPosition == renderer.cameraChunkPosition) ThreadPool.HIGH else ThreadPool.LOW, interruptable = true) // ToDo: Also make neighbour chunks important
|
||||
val runnable = HeavyPoolRunnable(if (item.chunkPosition == renderer.cameraChunkPosition) ThreadPool.HIGH else ThreadPool.LOW, interruptable = true) // ToDo: Also make neighbour chunks important
|
||||
val task = MeshPrepareTask(item.chunkPosition, item.sectionHeight, runnable)
|
||||
task.runnable.runnable = Runnable { renderer.mesher.tryMesh(item, task, task.runnable) }
|
||||
tasks += task
|
||||
|
@ -14,10 +14,10 @@
|
||||
package de.bixilon.minosoft.gui.rendering.world.queue.meshing.tasks
|
||||
|
||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
|
||||
import de.bixilon.kutil.concurrent.pool.runnable.HeavyPoolRunnable
|
||||
|
||||
class MeshPrepareTask(
|
||||
val chunkPosition: Vec2i,
|
||||
val sectionHeight: Int,
|
||||
val runnable: ThreadPoolRunnable,
|
||||
val runnable: HeavyPoolRunnable,
|
||||
)
|
||||
|
@ -16,7 +16,6 @@ package de.bixilon.minosoft.modding.event.master
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedList
|
||||
import de.bixilon.kutil.concurrent.lock.simple.SimpleLock
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.modding.event.events.AsyncEvent
|
||||
import de.bixilon.minosoft.modding.event.events.CancelableEvent
|
||||
import de.bixilon.minosoft.modding.event.events.Event
|
||||
@ -79,7 +78,7 @@ open class EventMaster(vararg parents: AbstractEventMaster) : AbstractEventMaste
|
||||
}
|
||||
eventInvokerLock.release()
|
||||
if (event is AsyncEvent) {
|
||||
worker.work(CountUpAndDownLatch(0))
|
||||
worker.work()
|
||||
}
|
||||
if (toRemove.isNotEmpty()) {
|
||||
eventInvokerLock.lock()
|
||||
|
@ -15,7 +15,8 @@ package de.bixilon.minosoft.modding.loader
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.minosoft.modding.loader.error.*
|
||||
import de.bixilon.minosoft.modding.loader.mod.MinosoftMod
|
||||
@ -23,6 +24,7 @@ import de.bixilon.minosoft.modding.loader.mod.ModMain
|
||||
import de.bixilon.minosoft.modding.loader.mod.logger.ModLogger
|
||||
import de.bixilon.minosoft.modding.loader.mod.source.ModSource
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
import de.bixilon.minosoft.util.KUtil.child
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
@ -32,7 +34,7 @@ import kotlin.reflect.jvm.javaField
|
||||
|
||||
object ModLoader {
|
||||
private val BASE_PATH = RunConfiguration.HOME_DIRECTORY.resolve("mods")
|
||||
private var latch: CountUpAndDownLatch? = null
|
||||
private var latch: AbstractLatch? = null
|
||||
val mods = ModList()
|
||||
var currentPhase by observed(LoadingPhases.PRE_BOOT)
|
||||
private set
|
||||
@ -77,8 +79,8 @@ object ModLoader {
|
||||
main!!.postInit()
|
||||
}
|
||||
|
||||
private fun inject(list: ModList, source: ModSource, phase: LoadingPhases, latch: CountUpAndDownLatch) {
|
||||
val mod = MinosoftMod(source, phase, CountUpAndDownLatch(4, latch))
|
||||
private fun inject(list: ModList, source: ModSource, phase: LoadingPhases, latch: AbstractLatch) {
|
||||
val mod = MinosoftMod(source, phase, ParentLatch(4, latch))
|
||||
Log.log(LogMessageType.MOD_LOADING, LogLevels.VERBOSE) { "Injecting $source" }
|
||||
try {
|
||||
source.process(mod)
|
||||
@ -119,7 +121,7 @@ object ModLoader {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun load(phase: LoadingPhases, latch: CountUpAndDownLatch) {
|
||||
fun load(phase: LoadingPhases, latch: AbstractLatch? = null) {
|
||||
if (RunConfiguration.IGNORE_MODS || phase in RunConfiguration.MOD_PARAMETERS.ignorePhases) {
|
||||
return
|
||||
}
|
||||
@ -127,7 +129,7 @@ object ModLoader {
|
||||
// ToDo: check phase
|
||||
this.currentPhase = phase
|
||||
|
||||
val inner = CountUpAndDownLatch(1, latch)
|
||||
val inner = latch.child(1)
|
||||
this.latch = inner
|
||||
this.state = PhaseStates.LISTING
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.modding.loader.mod
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.minosoft.assets.AssetsManager
|
||||
import de.bixilon.minosoft.modding.loader.LoaderUtil.unloadAll
|
||||
import de.bixilon.minosoft.modding.loader.LoadingPhases
|
||||
@ -24,7 +24,7 @@ import org.xeustechnologies.jcl.JarClassLoader
|
||||
class MinosoftMod(
|
||||
val source: ModSource,
|
||||
val phase: LoadingPhases,
|
||||
val latch: CountUpAndDownLatch,
|
||||
val latch: AbstractLatch,
|
||||
) : Comparable<MinosoftMod> {
|
||||
val classLoader = JarClassLoader()
|
||||
var manifest: ModManifest? = null
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
package de.bixilon.minosoft.modding.loader.mod.source
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.minosoft.assets.directory.DirectoryAssetsManager
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJson
|
||||
import de.bixilon.minosoft.data.text.BaseComponent
|
||||
@ -33,7 +32,7 @@ class DirectorySource(
|
||||
override fun process(mod: MinosoftMod) {
|
||||
val files = directory.listFiles()!!
|
||||
val assets = DirectoryAssetsManager(directory.path)
|
||||
assets.load(CountUpAndDownLatch(0))
|
||||
assets.load()
|
||||
|
||||
for (sub in files) {
|
||||
if (sub.isDirectory && sub.name == "assets") {
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.modding.loader.mod.source
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.minosoft.assets.directory.DirectoryAssetsManager
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJson
|
||||
import de.bixilon.minosoft.data.text.BaseComponent
|
||||
@ -50,7 +50,7 @@ class SplitDirectorySource(
|
||||
|
||||
private fun processResources(mod: MinosoftMod) {
|
||||
val assets = DirectoryAssetsManager(resources.path)
|
||||
assets.load(CountUpAndDownLatch(0, mod.latch))
|
||||
assets.load(ParentLatch(0, mod.latch))
|
||||
mod.assetsManager = assets
|
||||
|
||||
val manifestPath = File(resources.path + "/" + LoaderUtil.MANIFEST)
|
||||
|
@ -18,7 +18,7 @@ import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
|
||||
import de.bixilon.kutil.concurrent.worker.task.TaskWorker
|
||||
import de.bixilon.kutil.concurrent.worker.task.WorkerTask
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.forceSet
|
||||
@ -65,6 +65,7 @@ import de.bixilon.minosoft.tags.TagManager
|
||||
import de.bixilon.minosoft.terminal.RunConfiguration
|
||||
import de.bixilon.minosoft.terminal.cli.CLI
|
||||
import de.bixilon.minosoft.util.KUtil
|
||||
import de.bixilon.minosoft.util.KUtil.child
|
||||
import de.bixilon.minosoft.util.KUtil.startInit
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
@ -175,8 +176,8 @@ class PlayConnection(
|
||||
}
|
||||
|
||||
|
||||
fun connect(latch: CountUpAndDownLatch = CountUpAndDownLatch(1)) {
|
||||
val count = latch.count
|
||||
fun connect(latch: AbstractLatch? = null) {
|
||||
val count = latch?.count ?: 0
|
||||
check(!wasConnected) { "Connection was already connected!" }
|
||||
try {
|
||||
state = PlayConnectionStates.WAITING_MODS
|
||||
@ -187,14 +188,14 @@ class PlayConnection(
|
||||
val taskWorker = TaskWorker(errorHandler = { _, exception -> if (error == null) error = exception })
|
||||
taskWorker += {
|
||||
events.fire(RegistriesLoadEvent(this, registries, RegistriesLoadEvent.States.PRE))
|
||||
registries.parent = version.load(profiles.resources, latch)
|
||||
registries.parent = version.load(profiles.resources, latch.child(0))
|
||||
events.fire(RegistriesLoadEvent(this, registries, RegistriesLoadEvent.States.POST))
|
||||
this::legacyTags.forceSet(FallbackTags.map(registries))
|
||||
}
|
||||
|
||||
taskWorker += {
|
||||
Log.log(LogMessageType.ASSETS, LogLevels.INFO) { "Downloading and verifying assets. This might take a while..." }
|
||||
assetsManager = AssetsLoader.create(profiles.resources, version, latch)
|
||||
assetsManager = AssetsLoader.create(profiles.resources, version, latch.child(0))
|
||||
assetsManager.load(latch)
|
||||
Log.log(LogMessageType.ASSETS, LogLevels.INFO) { "Assets verified!" }
|
||||
}
|
||||
@ -220,11 +221,11 @@ class PlayConnection(
|
||||
if (!RunConfiguration.DISABLE_RENDERING) {
|
||||
val rendering = Rendering(this)
|
||||
this.rendering = rendering
|
||||
val renderLatch = CountUpAndDownLatch(0, latch)
|
||||
val renderLatch = latch.child(0)
|
||||
rendering.start(renderLatch)
|
||||
renderLatch.awaitWithChange()
|
||||
}
|
||||
latch.dec() // remove initial value
|
||||
latch?.dec() // remove initial value
|
||||
Log.log(LogMessageType.NETWORK_STATUS, level = LogLevels.INFO) { "Connecting to server: $address" }
|
||||
network.connect(address, profiles.other.nativeNetwork)
|
||||
state = PlayConnectionStates.ESTABLISHING
|
||||
@ -236,7 +237,7 @@ class PlayConnection(
|
||||
error = exception
|
||||
retry = false
|
||||
}
|
||||
latch.count = count
|
||||
latch?.count = count
|
||||
}
|
||||
|
||||
override fun disconnect() {
|
||||
|
@ -14,12 +14,9 @@
|
||||
package de.bixilon.minosoft.protocol.network.network.client.netty.pipeline
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.nullCast
|
||||
import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedList
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPool
|
||||
import de.bixilon.kutil.concurrent.pool.ThreadPoolRunnable
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.concurrent.pool.runnable.SimplePoolRunnable
|
||||
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
||||
import de.bixilon.minosoft.modding.event.events.PacketReceiveEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.Connection
|
||||
@ -40,23 +37,11 @@ class ClientPacketHandler(
|
||||
private val client: NettyClient,
|
||||
) : SimpleChannelInboundHandler<QueuedS2CP<*>>() {
|
||||
private val connection: Connection = client.connection
|
||||
private val handlers: MutableSet<ThreadPoolRunnable> = synchronizedSetOf()
|
||||
|
||||
init {
|
||||
client::connected.observe(this) {
|
||||
if (!it) {
|
||||
for (handler in handlers.toSynchronizedList()) {
|
||||
handler.interrupt()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun channelRead0(context: ChannelHandlerContext, queued: QueuedS2CP<*>) {
|
||||
if (queued.type.threadSafe && (DefaultThreadPool.queueSize < DefaultThreadPool.threadCount - 1 || queued.type.lowPriority)) { // only handle async when thread pool not busy
|
||||
val runnable = ThreadPoolRunnable(priority = if (queued.type.lowPriority) ThreadPool.Priorities.HIGH else ThreadPool.Priorities.HIGHER)
|
||||
runnable.runnable = Runnable { tryHandle(context, queued.type, queued.packet);handlers -= runnable }
|
||||
handlers += runnable
|
||||
val runnable = SimplePoolRunnable(priority = if (queued.type.lowPriority) ThreadPool.Priorities.HIGH else ThreadPool.Priorities.HIGHER)
|
||||
runnable.runnable = Runnable { tryHandle(context, queued.type, queued.packet) }
|
||||
DefaultThreadPool += runnable
|
||||
} else {
|
||||
tryHandle(context, queued.type, queued.packet)
|
||||
|
@ -19,7 +19,7 @@ import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.CollectionUtil.synchronizedMapOf
|
||||
import de.bixilon.kutil.collections.map.SynchronizedMap
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.reflection.KotlinReflection.kClass
|
||||
import de.bixilon.kutil.reflection.ReflectionUtil.realName
|
||||
import de.bixilon.kutil.string.StringUtil.toSnakeCase
|
||||
@ -78,7 +78,7 @@ object PacketTypeRegistry {
|
||||
}
|
||||
|
||||
|
||||
fun init(latch: CountUpAndDownLatch) {
|
||||
fun init(latch: AbstractLatch?) {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Initializing packets..." }
|
||||
val classLoader = Thread.currentThread().contextClassLoader
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
package de.bixilon.minosoft.protocol.protocol
|
||||
|
||||
import com.google.common.collect.HashBiMap
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.string.StringUtil.getBetween
|
||||
import de.bixilon.minosoft.config.profile.profiles.eros.server.entries.AbstractServer
|
||||
@ -22,6 +22,7 @@ import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
||||
import de.bixilon.minosoft.data.text.BaseComponent
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.gui.eros.main.play.server.type.types.LANServerType
|
||||
import de.bixilon.minosoft.util.KUtil.child
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
@ -45,7 +46,7 @@ object LANServerListener {
|
||||
val listening: Boolean
|
||||
get() = listeningThread != null
|
||||
|
||||
fun listen(latch: CountUpAndDownLatch?) {
|
||||
fun listen(latch: AbstractLatch?) {
|
||||
OtherProfileManager.selected::listenLAN.observe(this) {
|
||||
if (it && listeningThread == null) {
|
||||
startListener()
|
||||
@ -54,9 +55,9 @@ object LANServerListener {
|
||||
}
|
||||
}
|
||||
if (OtherProfileManager.selected.listenLAN) {
|
||||
val innerLatch = CountUpAndDownLatch(1, latch)
|
||||
val innerLatch = latch?.child(1)
|
||||
startListener(innerLatch)
|
||||
innerLatch.await()
|
||||
innerLatch?.await()
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +67,7 @@ object LANServerListener {
|
||||
listeningThread.interrupt()
|
||||
}
|
||||
|
||||
private fun startListener(latch: CountUpAndDownLatch? = null) {
|
||||
private fun startListener(latch: AbstractLatch? = null) {
|
||||
stop = false
|
||||
val thread = Thread({
|
||||
try {
|
||||
|
@ -14,7 +14,7 @@
|
||||
package de.bixilon.minosoft.protocol.versions
|
||||
|
||||
import de.bixilon.kutil.collections.map.bi.AbstractBiMap
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
@ -36,7 +36,7 @@ class Version(
|
||||
val sortingId: Int = (versionId == -1).decide(Int.MAX_VALUE, versionId)
|
||||
|
||||
|
||||
fun load(profile: ResourcesProfile, latch: CountUpAndDownLatch): Registries {
|
||||
fun load(profile: ResourcesProfile, latch: AbstractLatch): Registries {
|
||||
return RegistriesLoader.load(profile, this, latch)
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.CollectionUtil.mutableBiMapOf
|
||||
import de.bixilon.kutil.collections.map.bi.AbstractBiMap
|
||||
import de.bixilon.kutil.collections.map.bi.MutableBiMap
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.Minosoft
|
||||
import de.bixilon.minosoft.assets.util.InputStreamUtil.readJson
|
||||
@ -45,7 +45,7 @@ object Versions : Iterable<Version> {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun load(latch: CountUpAndDownLatch) {
|
||||
fun load(latch: AbstractLatch) {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Loading versions..." }
|
||||
val index: Map<String, Map<String, Any>> = Minosoft.MINOSOFT_ASSETS_MANAGER[VERSIONS_INDEX].readJson()
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
package de.bixilon.minosoft.terminal
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.shutdown.AbstractShutdownReason
|
||||
import de.bixilon.kutil.shutdown.ShutdownManager
|
||||
@ -62,7 +61,7 @@ object AutoConnect {
|
||||
val account = accountProfile.entries[split.getOrNull(2)] ?: accountProfile.selected ?: throw RuntimeException("Auto connect: Account not found! Have you started normal before or added an account?")
|
||||
|
||||
Log.log(LogMessageType.AUTO_CONNECT, LogLevels.INFO) { "Checking account..." }
|
||||
account.tryCheck(CountUpAndDownLatch(0), accountProfile.clientToken)
|
||||
account.tryCheck(null, accountProfile.clientToken)
|
||||
|
||||
if (version == Versions.AUTOMATIC) {
|
||||
Log.log(LogMessageType.AUTO_CONNECT, LogLevels.INFO) { "Pinging server to get version..." }
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.terminal.cli
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
||||
import de.bixilon.kutil.observer.DataObserver.Companion.observed
|
||||
import de.bixilon.kutil.shutdown.AbstractShutdownReason
|
||||
@ -53,7 +53,7 @@ object CLI {
|
||||
}
|
||||
|
||||
|
||||
fun startThread(latch: CountUpAndDownLatch) {
|
||||
fun startThread(latch: AbstractLatch) {
|
||||
latch.inc()
|
||||
Thread({ latch.dec(); startLoop() }, "CLI").start()
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ import de.bixilon.kutil.collections.CollectionUtil.synchronizedSetOf
|
||||
import de.bixilon.kutil.collections.CollectionUtil.toSynchronizedSet
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.latch.ParentLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||
import de.bixilon.kutil.primitive.DoubleUtil
|
||||
import de.bixilon.kutil.primitive.DoubleUtil.matches
|
||||
@ -357,4 +360,9 @@ object KUtil {
|
||||
|
||||
return table
|
||||
}
|
||||
|
||||
fun AbstractLatch?.child(count: Int): AbstractLatch {
|
||||
if (this == null) return SimpleLatch(count)
|
||||
return ParentLatch(count, this)
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.util
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.collections.primitive.Clearable
|
||||
import de.bixilon.kutil.concurrent.worker.unconditional.UnconditionalWorker
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.reflection.generic.GenericUtil
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.Parentable
|
||||
@ -73,7 +73,7 @@ object RegistriesUtil {
|
||||
return field?.get(registries).unsafeCast()
|
||||
}
|
||||
|
||||
fun Registries.postInit(latch: CountUpAndDownLatch) {
|
||||
fun Registries.postInit(latch: AbstractLatch) {
|
||||
val worker = UnconditionalWorker()
|
||||
for (field in types.values) {
|
||||
worker += { field.get(this).unsafeCast<Registry<*>>().postInit(this) }
|
||||
|
@ -15,8 +15,7 @@ package de.bixilon.minosoft.util.account.microsoft
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.kutil.concurrent.schedule.TaskScheduler.runLater
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.time.TimeUtil
|
||||
import de.bixilon.kutil.latch.AbstractLatch
|
||||
import de.bixilon.kutil.time.TimeUtil.millis
|
||||
import de.bixilon.minosoft.data.accounts.AccountStates
|
||||
import de.bixilon.minosoft.data.accounts.types.microsoft.MicrosoftAccount
|
||||
@ -129,7 +128,7 @@ object MicrosoftOAuthUtils {
|
||||
return Jackson.MAPPER.convertValue(response.body, AuthenticationResponse::class.java)
|
||||
}
|
||||
|
||||
fun loginToMicrosoftAccount(response: AuthenticationResponse, latch: CountUpAndDownLatch? = null): MicrosoftAccount {
|
||||
fun loginToMicrosoftAccount(response: AuthenticationResponse, latch: AbstractLatch? = null): MicrosoftAccount {
|
||||
Log.log(LogMessageType.AUTHENTICATION, LogLevels.INFO) { "Logging into microsoft account..." }
|
||||
latch?.let { it.count += 6 }
|
||||
val msaTokens = response.saveTokens()
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.modding.loader.mod
|
||||
|
||||
import de.bixilon.kutil.latch.CountUpAndDownLatch
|
||||
import de.bixilon.kutil.latch.SimpleLatch
|
||||
import de.bixilon.minosoft.modding.loader.LoadingPhases
|
||||
import de.bixilon.minosoft.modding.loader.ModList
|
||||
import de.bixilon.minosoft.modding.loader.mod.manifest.ModManifest
|
||||
@ -27,7 +27,7 @@ import kotlin.test.assertEquals
|
||||
internal class MinosoftModTest {
|
||||
|
||||
private fun createMod(): MinosoftMod {
|
||||
return MinosoftMod(ArchiveSource(File(".")), LoadingPhases.PRE_BOOT, CountUpAndDownLatch(0))
|
||||
return MinosoftMod(ArchiveSource(File(".")), LoadingPhases.PRE_BOOT, SimpleLatch(0))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user