diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/EntityRendererTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/EntityRendererTestUtil.kt index adc216748..eb0f95fa2 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/EntityRendererTestUtil.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/EntityRendererTestUtil.kt @@ -33,6 +33,7 @@ import de.bixilon.minosoft.data.registries.entities.EntityType import de.bixilon.minosoft.data.scoreboard.ScoreboardManager import de.bixilon.minosoft.gui.rendering.RenderContext import de.bixilon.minosoft.gui.rendering.camera.Camera +import de.bixilon.minosoft.gui.rendering.entities.factory.DefaultEntityModels import de.bixilon.minosoft.gui.rendering.entities.feature.register.EntityRenderFeatures import de.bixilon.minosoft.gui.rendering.entities.renderer.EntityRenderer import de.bixilon.minosoft.gui.rendering.light.RenderLight @@ -81,7 +82,9 @@ object EntityRendererTestUtil { if (factory == RemotePlayerEntity) { connection.tabList.uuid[uuid] = PlayerAdditional("John") } - return factory.build(connection, PIG, EntityData(connection), Vec3d(1, 1, 1), EntityRotation.EMPTY, uuid)!! + val renderer = DefaultEntityModels[factory.identifier] + val type = PIG.copy(identifier = factory.identifier, modelFactory = renderer) + return factory.build(connection, type, EntityData(connection), Vec3d(1, 1, 1), EntityRotation.EMPTY, uuid)!! } fun EntitiesRenderer.create(factory: EntityFactory): EntityRenderer { diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/BillboardTextFeatureTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/BillboardTextFeatureTest.kt new file mode 100644 index 000000000..1ac399cf3 --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/BillboardTextFeatureTest.kt @@ -0,0 +1,39 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 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. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.gui.rendering.entities.feature.text + +import de.bixilon.minosoft.data.entities.entities.animal.Pig +import de.bixilon.minosoft.data.text.ChatComponent +import de.bixilon.minosoft.data.text.TextComponent +import de.bixilon.minosoft.gui.rendering.entities.EntityRendererTestUtil +import de.bixilon.minosoft.gui.rendering.entities.EntityRendererTestUtil.create +import org.testng.Assert.assertEquals +import org.testng.annotations.Test + +@Test(groups = ["entities", "rendering"]) +class BillboardTextFeatureTest { + + private fun create(text: ChatComponent? = null): BillboardTextFeature { + val renderer = EntityRendererTestUtil.create().create(Pig) + return BillboardTextFeature(renderer, text) + } + + fun `simple creation`() { + val text = create(TextComponent("Text")) + assertEquals(text.text?.message, "Text") + } + + + // TODO: unload on change(text, offset)/disable, render distance, comparing, text rendering, matrix (position, camera rotation, offset, entity dimensions, centering of it) +} diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/name/EntityNameFeatureTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/name/EntityNameFeatureTest.kt index bbf02948a..d92aa142d 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/name/EntityNameFeatureTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/name/EntityNameFeatureTest.kt @@ -244,4 +244,5 @@ class EntityNameFeatureTest { // TODO: targeted mob, invisible zombie // TODO: mob, armor stand, player (local/remote), pig, non living (boat?) // TODO: isInvisible, teams (with team nametag visibility), + // TODO: profile } diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/name/EntityScoreFeatureTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/name/EntityScoreFeatureTest.kt new file mode 100644 index 000000000..876fe89f8 --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/entities/feature/text/name/EntityScoreFeatureTest.kt @@ -0,0 +1,47 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 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. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.gui.rendering.entities.feature.text.name + +import de.bixilon.kutil.cast.CastUtil.unsafeCast +import de.bixilon.kutil.reflection.ReflectionUtil.forceSet +import de.bixilon.minosoft.data.entities.entities.player.RemotePlayerEntity +import de.bixilon.minosoft.gui.rendering.entities.EntityRendererTestUtil.create +import de.bixilon.minosoft.gui.rendering.entities.feature.text.BillbaordTextTestUtil.assertEmpty +import de.bixilon.minosoft.gui.rendering.entities.renderer.living.player.PlayerRenderer +import org.testng.annotations.Test + +@Test(groups = ["entities", "rendering"]) +class EntityScoreFeatureTest { + private val updateScore = EntityScoreFeature::class.java.getDeclaredMethod("updateScore").apply { isAccessible = true } + + private fun createScore(): EntityScoreFeature { + val renderer = create().create(RemotePlayerEntity).unsafeCast>() + renderer::score.forceSet(null) // remove + + return EntityScoreFeature(renderer) + } + + private fun EntityScoreFeature.updateScore() { + updateScore.invoke(this) + } + + fun `player without score`() { + val score = createScore() + score.updateScore() + score.assertEmpty() + } + + + // TODO: teams, invisibility, score, profile, correct text +} diff --git a/src/main/java/de/bixilon/minosoft/data/entities/entities/player/RemotePlayerEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/entities/player/RemotePlayerEntity.kt index 4bff68641..2ff7c814f 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/entities/player/RemotePlayerEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/entities/player/RemotePlayerEntity.kt @@ -42,14 +42,7 @@ class RemotePlayerEntity( override fun build(connection: PlayConnection, entityType: EntityType, data: EntityData, position: Vec3d, rotation: EntityRotation, uuid: UUID?): RemotePlayerEntity? { val additional = connection.tabList.uuid[uuid] ?: return null - return RemotePlayerEntity( - connection = connection, - entityType = connection.registries.entityType[identifier]!!, - data = data, - position = position, - rotation = rotation, - additional = additional, - ) + return RemotePlayerEntity(connection, entityType, data, position, rotation, additional) } } }