diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt b/src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt index aedd3d1b5..da1218239 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/MinosoftSIT.kt @@ -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 diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/ContainerTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/ContainerTestUtil.kt index 0cd61f734..de5924a2b 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/ContainerTestUtil.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/ContainerTestUtil.kt @@ -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 diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/blocks/BlockTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/blocks/BlockTest.kt index 2f04d0b2f..1cdba4211 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/blocks/BlockTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/blocks/BlockTest.kt @@ -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 { val block: T = unsafeNull() val state: BlockState = unsafeNull() - init { - reference() - } fun retrieveBlock(name: ResourceLocation) { val block = IT.REGISTRIES.block[name] diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/ItemTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/ItemTest.kt index 2994709a1..22721df96 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/ItemTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/ItemTest.kt @@ -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 { var item: T = unsafeNull() - init { - reference() - } fun retrieveItem(name: ResourceLocation) { val item = IT.REGISTRIES.item[name] diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/WorldTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/WorldTestUtil.kt index 70f64c9ba..e282efacb 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/data/world/WorldTestUtil.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/world/WorldTestUtil.kt @@ -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 } diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/RenderTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/RenderTestUtil.kt index 4ddd1c37d..a0d17374f 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/RenderTestUtil.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/RenderTestUtil.kt @@ -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() diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/system/window/dummy/DummyWindow.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/system/window/dummy/DummyWindow.kt index 3716f2246..8f1511047 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/system/window/dummy/DummyWindow.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/system/window/dummy/DummyWindow.kt @@ -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 diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/session/play/SessionTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/session/play/SessionTestUtil.kt index 598c6ee33..a634e7f38 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/session/play/SessionTestUtil.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/session/play/SessionTestUtil.kt @@ -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) } diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/test/IT.kt b/src/integration-test/kotlin/de/bixilon/minosoft/test/IT.kt index 6963011fe..e9d49dfa0 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/test/IT.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/test/IT.kt @@ -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 = mutableListOf() - - init { - reference() - } - - fun Any.reference() { - references += this - } } diff --git a/src/main/java/de/bixilon/minosoft/data/entities/entities/Entity.kt b/src/main/java/de/bixilon/minosoft/data/entities/entities/Entity.kt index 722cdfa77..ca8fe643e 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/entities/Entity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/entities/Entity.kt @@ -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()