mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 02:45:13 -04:00
wip block model testing
This commit is contained in:
parent
e5250e5c07
commit
e421dbfda5
@ -13,22 +13,50 @@
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.models
|
||||
|
||||
import de.bixilon.minosoft.gui.rendering.models.raw.block.BlockModel
|
||||
import de.bixilon.minosoft.gui.rendering.models.raw.light.GUILights
|
||||
import de.bixilon.minosoft.test.IT.OBJENESIS
|
||||
import org.testng.Assert.assertEquals
|
||||
import org.testng.annotations.Test
|
||||
|
||||
@Test(groups = ["models"])
|
||||
class BlockModelTest {
|
||||
private val block = """{"gui_light":"side","display":{"gui":{"rotation":[30,225,0],"translation":[0,0,0],"scale":[0.625,0.625,0.625]},"ground":{"rotation":[0,0,0],"translation":[0,3,0],"scale":[0.25,0.25,0.25]},"fixed":{"rotation":[0,0,0],"translation":[0,0,0],"scale":[0.5,0.5,0.5]},"thirdperson_righthand":{"rotation":[75,45,0],"translation":[0,2.5,0],"scale":[0.375,0.375,0.375]},"firstperson_righthand":{"rotation":[0,45,0],"translation":[0,0,0],"scale":[0.4,0.4,0.4]},"firstperson_lefthand":{"rotation":[0,225,0],"translation":[0,0,0],"scale":[0.4,0.4,0.4]}}}"""
|
||||
private val cube = """{"parent":"block/block","elements":[{"from":[0,0,0],"to":[16,16,16],"faces":{"down":{"texture":"#down","cullface":"down"},"up":{"texture":"#up","cullface":"up"},"north":{"texture":"#north","cullface":"north"},"south":{"texture":"#south","cullface":"south"},"west":{"texture":"#west","cullface":"west"},"east":{"texture":"#east","cullface":"east"}}}]}"""
|
||||
private val cube_all = """{"parent":"block/cube","textures":{"particle":"#all","down":"#all","up":"#all","north":"#all","east":"#all","south":"#all","west":"#all"}}"""
|
||||
|
||||
fun redWool() {
|
||||
val state = """{"variants":{"":{"model":"minecraft:block/red_wool"}}}"""
|
||||
val models = mapOf(
|
||||
"block/red_wool" to """{"parent":"minecraft:block/cube_all","textures": {"all":"minecraft:block/red_wool"}}""",
|
||||
"block/cube_all" to cube_all,
|
||||
"bloc/cube" to cube,
|
||||
"block/block" to block
|
||||
)
|
||||
val model = TODO()
|
||||
private fun createLoader(): ModelLoader {
|
||||
val instance = OBJENESIS.newInstance(ModelLoader::class.java)
|
||||
|
||||
|
||||
return instance
|
||||
}
|
||||
|
||||
private fun loadModel(json: String): BlockModel = TODO()
|
||||
|
||||
fun emptyModel() {
|
||||
val json = """{}"""
|
||||
|
||||
val model = loadModel(json)
|
||||
|
||||
assertEquals(model, BlockModel(GUILights.SIDE, null, null, null, true))
|
||||
}
|
||||
|
||||
fun basicModel() {
|
||||
val json = """{"gui_scale":"front", "ambientocclusion":false}"""
|
||||
|
||||
val model = loadModel(json)
|
||||
|
||||
assertEquals(model, BlockModel(GUILights.FRONT, null, null, null, true))
|
||||
}
|
||||
|
||||
fun cubeAll() {
|
||||
TODO()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val BLOCK = """{"gui_light":"side","display":{"gui":{"rotation":[30,225,0],"translation":[0,0,0],"scale":[0.625,0.625,0.625]},"ground":{"rotation":[0,0,0],"translation":[0,3,0],"scale":[0.25,0.25,0.25]},"fixed":{"rotation":[0,0,0],"translation":[0,0,0],"scale":[0.5,0.5,0.5]},"thirdperson_righthand":{"rotation":[75,45,0],"translation":[0,2.5,0],"scale":[0.375,0.375,0.375]},"firstperson_righthand":{"rotation":[0,45,0],"translation":[0,0,0],"scale":[0.4,0.4,0.4]},"firstperson_lefthand":{"rotation":[0,225,0],"translation":[0,0,0],"scale":[0.4,0.4,0.4]}}}"""
|
||||
const val CUBE = """{"parent":"block/block","elements":[{"from":[0,0,0],"to":[16,16,16],"faces":{"down":{"texture":"#down","cullface":"down"},"up":{"texture":"#up","cullface":"up"},"north":{"texture":"#north","cullface":"north"},"south":{"texture":"#south","cullface":"south"},"west":{"texture":"#west","cullface":"west"},"east":{"texture":"#east","cullface":"east"}}}]}"""
|
||||
const val CUBE_ALL = """{"parent":"block/cube","textures":{"particle":"#all","down":"#all","up":"#all","north":"#all","east":"#all","south":"#all","west":"#all"}}"""
|
||||
|
||||
|
||||
val CUBE_ALL_MODEL: BlockModel = TODO()
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.models
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.minosoft.gui.rendering.models.BlockModelTest.Companion.BLOCK
|
||||
import de.bixilon.minosoft.gui.rendering.models.BlockModelTest.Companion.CUBE
|
||||
import de.bixilon.minosoft.gui.rendering.models.BlockModelTest.Companion.CUBE_ALL
|
||||
import de.bixilon.minosoft.gui.rendering.models.raw.block.state.DirectBlockModel
|
||||
import de.bixilon.minosoft.gui.rendering.models.raw.block.state.apply.BlockStateModel
|
||||
import de.bixilon.minosoft.gui.rendering.models.raw.block.state.variant.SingleVariantBlockModel
|
||||
import org.testng.Assert.assertEquals
|
||||
import org.testng.annotations.Test
|
||||
|
||||
@Test(groups = ["models"])
|
||||
class BlockStateModelTest {
|
||||
|
||||
private fun loadModel(state: String, files: Map<String, String>): DirectBlockModel = TODO()
|
||||
|
||||
fun redWool() {
|
||||
val state = """{"variants":{"":{"model":"minecraft:block/red_wool"}}}"""
|
||||
val models = mapOf(
|
||||
"block/red_wool" to """{"parent":"minecraft:block/cube_all","textures":{"all":"minecraft:block/red_wool"}}""",
|
||||
"block/cube_all" to CUBE_ALL,
|
||||
"bloc/cube" to CUBE,
|
||||
"block/block" to BLOCK,
|
||||
)
|
||||
val model = loadModel(state, models)
|
||||
|
||||
assertEquals(model.unsafeCast<SingleVariantBlockModel>().apply, BlockStateModel(
|
||||
model = BlockModelTest.CUBE_ALL_MODEL,
|
||||
x = 0,
|
||||
y = 0,
|
||||
uvLock = false,
|
||||
weight = 1,
|
||||
))
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ data class BlockModel(
|
||||
val display: Map<ModelDisplayPositions, ModelDisplay>?,
|
||||
val elements: List<ModelElement>?,
|
||||
val textures: Map<String, String>?,
|
||||
val ambientOcclusion: Boolean?,
|
||||
val ambientOcclusion: Boolean,
|
||||
) {
|
||||
|
||||
companion object {
|
||||
|
@ -21,6 +21,7 @@ import de.bixilon.minosoft.gui.rendering.models.raw.block.state.variant.VariantB
|
||||
interface DirectBlockModel {
|
||||
|
||||
companion object {
|
||||
|
||||
fun deserialize(data: JsonObject): DirectBlockModel? {
|
||||
data["variants"]?.toJsonObject()?.let { return VariantBlockModel.deserialize(it) }
|
||||
data["multipart"]?.toJsonObject()?.let { return ConditionBlockModel.deserialize(it) }
|
||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.models.raw.block.state.condition
|
||||
import de.bixilon.kutil.json.JsonObject
|
||||
import de.bixilon.minosoft.gui.rendering.models.raw.block.state.DirectBlockModel
|
||||
|
||||
@Deprecated("TODO")
|
||||
class ConditionBlockModel : DirectBlockModel {
|
||||
|
||||
companion object {
|
||||
|
@ -15,6 +15,4 @@ package de.bixilon.minosoft.gui.rendering.models.raw.block.state.variant
|
||||
|
||||
import de.bixilon.minosoft.data.registries.blocks.properties.BlockProperties
|
||||
|
||||
class BlockVariant(
|
||||
val properties: Map<BlockProperties, Any>
|
||||
)
|
||||
typealias BlockVariant = Map<BlockProperties, Any>
|
||||
|
@ -32,7 +32,7 @@ interface VariantBlockModel : DirectBlockModel {
|
||||
properties[property] = value
|
||||
}
|
||||
|
||||
return BlockVariant(properties)
|
||||
return properties
|
||||
}
|
||||
|
||||
fun deserialize(data: JsonObject): VariantBlockModel? {
|
||||
|
Loading…
x
Reference in New Issue
Block a user