mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-08 14:59:16 -04:00
fix deadlock, fix render test loader
No clue how this test ever passed...
This commit is contained in:
parent
5f9058e44a
commit
cf488e1dd6
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -58,7 +58,6 @@ internal object MinosoftSIT {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "This is java version ${System.getProperty("java.version")}" }
|
||||
KUtil.initBootClasses()
|
||||
KUtil.initPlayClasses()
|
||||
disableGC()
|
||||
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "Setting up integration tests...." }
|
||||
|
||||
IntegratedAssets.DEFAULT.load()
|
||||
@ -77,19 +76,6 @@ internal object MinosoftSIT {
|
||||
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "Integration tests setup successfully!" }
|
||||
}
|
||||
|
||||
|
||||
@Deprecated("Not sure if that is needed")
|
||||
fun disableGC() {
|
||||
Thread {
|
||||
val references = IT.references
|
||||
// basically while (true)
|
||||
for (i in 0 until Int.MAX_VALUE) {
|
||||
Thread.sleep(100000L)
|
||||
}
|
||||
references.hashCode() // force keep reference to references
|
||||
}.start()
|
||||
}
|
||||
|
||||
fun loadPixlyzerData() {
|
||||
val (version, registries) = ITUtil.loadPixlyzerData(IT.TEST_VERSION_NAME)
|
||||
IT.VERSION = version
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2024 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -25,7 +25,6 @@ import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.network.session.play.PlaySession
|
||||
import de.bixilon.minosoft.protocol.network.session.play.SessionTestUtil.createSession
|
||||
import de.bixilon.minosoft.test.IT
|
||||
import de.bixilon.minosoft.test.IT.reference
|
||||
|
||||
|
||||
object ContainerTestUtil {
|
||||
@ -34,10 +33,6 @@ object ContainerTestUtil {
|
||||
private val furnace = IT.REGISTRIES.containerType[FurnaceContainer]!!
|
||||
|
||||
|
||||
init {
|
||||
reference()
|
||||
}
|
||||
|
||||
fun createInventory(session: PlaySession = createSession()): Container {
|
||||
val inventory = PlayerInventory(session.player.items, session)
|
||||
session.player.items.containers[0] = inventory
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -20,7 +20,6 @@ import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.test.IT
|
||||
import de.bixilon.minosoft.test.IT.reference
|
||||
import org.testng.Assert
|
||||
import org.testng.Assert.assertEquals
|
||||
|
||||
@ -28,9 +27,6 @@ abstract class BlockTest<T : Block> {
|
||||
val block: T = unsafeNull()
|
||||
val state: BlockState = unsafeNull()
|
||||
|
||||
init {
|
||||
reference()
|
||||
}
|
||||
|
||||
fun retrieveBlock(name: ResourceLocation) {
|
||||
val block = IT.REGISTRIES.block[name]
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -19,16 +19,12 @@ import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.item.factory.ItemFactory
|
||||
import de.bixilon.minosoft.data.registries.item.items.Item
|
||||
import de.bixilon.minosoft.test.IT
|
||||
import de.bixilon.minosoft.test.IT.reference
|
||||
import org.testng.Assert
|
||||
import org.testng.Assert.assertEquals
|
||||
|
||||
abstract class ItemTest<T : Item> {
|
||||
var item: T = unsafeNull()
|
||||
|
||||
init {
|
||||
reference()
|
||||
}
|
||||
|
||||
fun retrieveItem(name: ResourceLocation) {
|
||||
val item = IT.REGISTRIES.item[name]
|
||||
|
@ -52,6 +52,8 @@ object WorldTestUtil {
|
||||
world::time.forceSet(DataObserver(WorldTime()))
|
||||
world::biomes.forceSet(WorldBiomes(world))
|
||||
world::weather.forceSet(DataObserver(WorldWeather.Companion.SUNNY))
|
||||
world::hardcore.forceSet(DataObserver(false))
|
||||
world::difficulty.forceSet(DataObserver(null))
|
||||
|
||||
return world
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -14,20 +14,13 @@
|
||||
package de.bixilon.minosoft.gui.rendering
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.renderer.AsyncRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.renderer.DefaultRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.renderer.renderer.Renderer
|
||||
import de.bixilon.minosoft.test.IT.reference
|
||||
|
||||
|
||||
object RenderTestUtil {
|
||||
lateinit var rendering: Rendering
|
||||
lateinit var context: RenderContext
|
||||
|
||||
init {
|
||||
DefaultRenderer.reference()
|
||||
DefaultRenderer.list.clear()
|
||||
reference()
|
||||
}
|
||||
|
||||
fun Renderer.frame() {
|
||||
this.prePrepareDraw()
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -26,7 +26,7 @@ import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
class DummyWindow : BaseWindow {
|
||||
override val systemScale: Vec2 = Vec2(1.0f)
|
||||
override val systemScale by observed(Vec2(1.0f))
|
||||
override var size: Vec2i = Vec2i.EMPTY
|
||||
override var minSize: Vec2i = Vec2i.EMPTY
|
||||
override var maxSize: Vec2i = Vec2i.EMPTY
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2024 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -25,19 +25,21 @@ import de.bixilon.minosoft.config.profile.ProfileTestUtil.createProfiles
|
||||
import de.bixilon.minosoft.data.accounts.types.test.TestAccount
|
||||
import de.bixilon.minosoft.data.entities.entities.player.local.LocalPlayerEntity
|
||||
import de.bixilon.minosoft.data.entities.entities.player.local.SignatureKeyManagement
|
||||
import de.bixilon.minosoft.data.entities.entities.player.tab.TabList
|
||||
import de.bixilon.minosoft.data.language.manager.LanguageManager
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.scoreboard.ScoreboardManager
|
||||
import de.bixilon.minosoft.data.world.WorldTestUtil.createWorld
|
||||
import de.bixilon.minosoft.data.world.WorldTestUtil.initialize
|
||||
import de.bixilon.minosoft.data.world.biome.source.DummyBiomeSource
|
||||
import de.bixilon.minosoft.modding.event.master.EventMaster
|
||||
import de.bixilon.minosoft.protocol.network.network.client.test.TestNetwork
|
||||
import de.bixilon.minosoft.protocol.network.session.play.tick.SessionTicker
|
||||
import de.bixilon.minosoft.protocol.versions.Versions
|
||||
import de.bixilon.minosoft.tags.TagManager
|
||||
import de.bixilon.minosoft.test.IT
|
||||
import de.bixilon.minosoft.test.IT.FALLBACK_TAGS
|
||||
import de.bixilon.minosoft.test.IT.OBJENESIS
|
||||
import de.bixilon.minosoft.test.IT.reference
|
||||
import de.bixilon.minosoft.test.ITUtil
|
||||
import de.bixilon.minosoft.util.KUtil.startInit
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
@ -46,10 +48,6 @@ import java.util.concurrent.atomic.AtomicInteger
|
||||
object SessionTestUtil {
|
||||
private val profiles = createProfiles()
|
||||
|
||||
init {
|
||||
reference()
|
||||
}
|
||||
|
||||
private val LANGUAGE = PlaySession::language.field
|
||||
private val SEQUENCE = PlaySession::sequence.field
|
||||
private val ACCOUNT = PlaySession::account.field
|
||||
@ -65,12 +63,17 @@ object SessionTestUtil {
|
||||
private val TAGS = PlaySession::tags.field
|
||||
private val LEGACY_TAGS = PlaySession::legacyTags.field
|
||||
private val CAMERA = PlaySession::camera.field
|
||||
private val SCOREBOARD = PlaySession::scoreboard.field
|
||||
private val TICKER = PlaySession::ticker.field
|
||||
private val SERVER_INFO = PlaySession::serverInfo.field
|
||||
private val TAB_LIST = PlaySession::tabList.field
|
||||
|
||||
private val language = LanguageManager()
|
||||
private val signature = OBJENESIS.newInstance(SignatureKeyManagement::class.java)
|
||||
|
||||
|
||||
fun createSession(worldSize: Int = 0, light: Boolean = false, version: String? = null): PlaySession {
|
||||
// TODO: Init with local world
|
||||
val session = OBJENESIS.newInstance(PlaySession::class.java)
|
||||
LANGUAGE.set(session, language)
|
||||
val version = if (version == null) IT.VERSION else Versions[version] ?: throw IllegalArgumentException("Can not find version: $version")
|
||||
@ -91,6 +94,11 @@ object SessionTestUtil {
|
||||
TAGS.set(session, TagManager())
|
||||
LEGACY_TAGS.set(session, FALLBACK_TAGS)
|
||||
CAMERA.set(session, SessionCamera(session))
|
||||
SCOREBOARD.set(session, ScoreboardManager(session))
|
||||
TICKER.set(session, SessionTicker(session))
|
||||
SERVER_INFO.set(session, ServerInfo())
|
||||
TAB_LIST.set(session, TabList())
|
||||
|
||||
session.camera.init()
|
||||
if (worldSize > 0) {
|
||||
session.world.initialize(worldSize) { DummyBiomeSource(null) }
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2024 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -27,14 +27,4 @@ object IT {
|
||||
var REGISTRIES: Registries = unsafeNull()
|
||||
var FALLBACK_TAGS: TagManager = unsafeNull()
|
||||
val NULL_CONNECTION = OBJENESIS.newInstance(PlaySession::class.java)
|
||||
|
||||
val references: MutableList<Any> = mutableListOf()
|
||||
|
||||
init {
|
||||
reference()
|
||||
}
|
||||
|
||||
fun Any.reference() {
|
||||
references += this
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2024 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
@ -195,7 +195,6 @@ abstract class Entity(
|
||||
lastTickTime = time
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun tryTick(): Boolean {
|
||||
val time = millis()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user