mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -04:00
improve entity test setup, more tests
This commit is contained in:
parent
20ac20007e
commit
46f69edb09
@ -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 <E : Entity> EntitiesRenderer.create(factory: EntityFactory<E>): EntityRenderer<E> {
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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)
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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<PlayerRenderer<*>>()
|
||||
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
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user