diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/BlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/BlockEntity.kt index 072f319c3..84878fd3f 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/BlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/BlockEntity.kt @@ -29,7 +29,7 @@ abstract class BlockEntity( open fun tick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i) = Unit - fun getRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer? { + open fun getRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer? { if (this.renderer?.blockState != blockState) { this.renderer = createRenderer(renderWindow, blockState, blockPosition, light) } else { diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/MeshedBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/MeshedBlockEntity.kt new file mode 100644 index 000000000..70e31f063 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/MeshedBlockEntity.kt @@ -0,0 +1,40 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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.data.entities.block + +import de.bixilon.minosoft.data.registries.blocks.BlockState +import de.bixilon.minosoft.gui.rendering.RenderWindow +import de.bixilon.minosoft.gui.rendering.world.entities.BlockEntityRenderer +import de.bixilon.minosoft.gui.rendering.world.entities.MeshedBlockEntityRenderer +import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection +import glm_.vec3.Vec3i + +abstract class MeshedBlockEntity(connection: PlayConnection) : BlockEntity(connection) { + + override fun getRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): MeshedBlockEntityRenderer<*>? { + var renderer = this.renderer + if (renderer is MeshedBlockEntityRenderer<*> && renderer.blockState == blockState) { + return renderer + } + renderer = createMeshedRenderer(renderWindow, blockState, blockPosition) + this.renderer = renderer + return renderer + } + + override fun createRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer<*> { + throw IllegalAccessException() + } + + abstract fun createMeshedRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i): MeshedBlockEntityRenderer<*> +} diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/SignBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/SignBlockEntity.kt index f8bf47342..a6173b4fa 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/SignBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/SignBlockEntity.kt @@ -18,12 +18,12 @@ import de.bixilon.minosoft.data.registries.ResourceLocation import de.bixilon.minosoft.data.registries.blocks.BlockState import de.bixilon.minosoft.data.text.ChatComponent import de.bixilon.minosoft.gui.rendering.RenderWindow -import de.bixilon.minosoft.gui.rendering.world.entities.renderer.SignBlockEntityRenderer +import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.SignBlockEntityRenderer import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition import glm_.vec3.Vec3i -class SignBlockEntity(connection: PlayConnection) : BlockEntity(connection) { +class SignBlockEntity(connection: PlayConnection) : MeshedBlockEntity(connection) { var lines: Array = Array(ProtocolDefinition.SIGN_LINES) { ChatComponent.of("") } @@ -35,8 +35,8 @@ class SignBlockEntity(connection: PlayConnection) : BlockEntity(connection) { } } - override fun createRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): SignBlockEntityRenderer { - return SignBlockEntityRenderer(this) + override fun createMeshedRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i): SignBlockEntityRenderer { + return SignBlockEntityRenderer(this, blockState) } companion object : BlockEntityFactory { diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ChestBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ChestBlockEntity.kt index b15f66d34..d3e739f7c 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ChestBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ChestBlockEntity.kt @@ -30,12 +30,12 @@ open class ChestBlockEntity(connection: PlayConnection) : StorageBlockEntity(con override fun createRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer<*>? { val type = blockState.properties[BlockProperties.CHEST_TYPE] ?: return null if (type == ChestTypes.SINGLE) { - return SingleChestRenderer(this, renderWindow, blockState, blockPosition, renderWindow.modelLoader.entities.models[getSingleModel()] ?: return null, light) + return SingleChestRenderer(this, renderWindow, blockState, blockPosition, renderWindow.modelLoader.entities.skeletal[getSingleModel()] ?: return null, light) } if (type == ChestTypes.LEFT) { // only left chest will be rendered (the model is the double chest), reduces drawing overhead - return DoubleChestRenderer(this, renderWindow, blockState, blockPosition, renderWindow.modelLoader.entities.models[getDoubleModel()] ?: return null, light) + return DoubleChestRenderer(this, renderWindow, blockState, blockPosition, renderWindow.modelLoader.entities.skeletal[getDoubleModel()] ?: return null, light) } return null diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/EnderChestBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/EnderChestBlockEntity.kt index 528d036f2..44e80af50 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/EnderChestBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/EnderChestBlockEntity.kt @@ -26,7 +26,7 @@ import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection class EnderChestBlockEntity(connection: PlayConnection) : StorageBlockEntity(connection) { override fun createRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer? { - val model = renderWindow.modelLoader.entities.models[SingleChestRenderer.EnderChest.MODEL] ?: return null + val model = renderWindow.modelLoader.entities.skeletal[SingleChestRenderer.EnderChest.MODEL] ?: return null return SingleChestRenderer(this, renderWindow, blockState, blockPosition, model, light) } diff --git a/src/main/java/de/bixilon/minosoft/data/registries/blocks/DefaultBlockFactories.kt b/src/main/java/de/bixilon/minosoft/data/registries/blocks/DefaultBlockFactories.kt index 295db40dd..b64251f44 100644 --- a/src/main/java/de/bixilon/minosoft/data/registries/blocks/DefaultBlockFactories.kt +++ b/src/main/java/de/bixilon/minosoft/data/registries/blocks/DefaultBlockFactories.kt @@ -34,6 +34,8 @@ import de.bixilon.minosoft.data.registries.blocks.types.entity.redstone.CommandB import de.bixilon.minosoft.data.registries.blocks.types.entity.redstone.DaylightDetectorBlock import de.bixilon.minosoft.data.registries.blocks.types.entity.redstone.PistonBlock import de.bixilon.minosoft.data.registries.blocks.types.entity.redstone.SculkSensorBlock +import de.bixilon.minosoft.data.registries.blocks.types.entity.sign.StandingSignBlock +import de.bixilon.minosoft.data.registries.blocks.types.entity.sign.WallSignBlock import de.bixilon.minosoft.data.registries.blocks.types.leaves.LeavesBlock import de.bixilon.minosoft.data.registries.blocks.types.plant.CropBlock import de.bixilon.minosoft.data.registries.blocks.types.plant.PlantBlock @@ -78,7 +80,8 @@ object DefaultBlockFactories : DefaultClassFactory>( JukeboxBlock, DispenserBlock, DropperBlock, - SignBlock, + WallSignBlock, + StandingSignBlock, MobSpawnerBlock, PistonBlock, BrewingStandBlock, diff --git a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/SignBlock.kt b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/SignBlock.kt new file mode 100644 index 000000000..9f648465d --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/SignBlock.kt @@ -0,0 +1,25 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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.data.registries.blocks.types.entity.sign + +import de.bixilon.minosoft.data.entities.block.SignBlockEntity +import de.bixilon.minosoft.data.registries.ResourceLocation +import de.bixilon.minosoft.data.registries.blocks.types.entity.BlockWithEntity +import de.bixilon.minosoft.data.registries.registries.Registries +import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.SignModel + +abstract class SignBlock(resourceLocation: ResourceLocation, registries: Registries, data: Map) : BlockWithEntity(resourceLocation, registries, data) { + abstract val model: SignModel? +} + diff --git a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/StandingSignBlock.kt b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/StandingSignBlock.kt new file mode 100644 index 000000000..2e3a42ae2 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/StandingSignBlock.kt @@ -0,0 +1,33 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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.data.registries.blocks.types.entity.sign + +import de.bixilon.minosoft.data.registries.ResourceLocation +import de.bixilon.minosoft.data.registries.blocks.BlockFactory +import de.bixilon.minosoft.data.registries.factory.clazz.MultiClassFactory +import de.bixilon.minosoft.data.registries.registries.Registries +import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.standing.StandingSignModel + +open class StandingSignBlock(resourceLocation: ResourceLocation, registries: Registries, data: Map) : SignBlock(resourceLocation, registries, data) { + override var model: StandingSignModel? = null + + companion object : BlockFactory, MultiClassFactory { + override val ALIASES: Set = setOf("SignBlock") + + override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map): StandingSignBlock { + return StandingSignBlock(resourceLocation, registries, data) + } + } +} + diff --git a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/SignBlock.kt b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/WallSignBlock.kt similarity index 65% rename from src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/SignBlock.kt rename to src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/WallSignBlock.kt index 7e2c8cb3c..c5aea1c14 100644 --- a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/SignBlock.kt +++ b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/sign/WallSignBlock.kt @@ -11,18 +11,20 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.data.registries.blocks.types.entity +package de.bixilon.minosoft.data.registries.blocks.types.entity.sign -import de.bixilon.minosoft.data.entities.block.SignBlockEntity import de.bixilon.minosoft.data.registries.ResourceLocation import de.bixilon.minosoft.data.registries.blocks.BlockFactory import de.bixilon.minosoft.data.registries.registries.Registries +import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.wall.WallSignModel -open class SignBlock(resourceLocation: ResourceLocation, registries: Registries, data: Map) : BlockWithEntity(resourceLocation, registries, data) { +open class WallSignBlock(resourceLocation: ResourceLocation, registries: Registries, data: Map) : SignBlock(resourceLocation, registries, data) { + override var model: WallSignModel? = null - companion object : BlockFactory { - override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map): SignBlock { - return SignBlock(resourceLocation, registries, data) + companion object : BlockFactory { + + override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map): WallSignBlock { + return WallSignBlock(resourceLocation, registries, data) } } } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt index e0e103fb2..47722123a 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt @@ -191,7 +191,7 @@ class RenderWindow( Log.log(LogMessageType.RENDERING_LOADING, LogLevels.VERBOSE) { "Loading skeletal meshes ${stopwatch.totalTime()}" } - for (model in modelLoader.entities.models.values) { + for (model in modelLoader.entities.skeletal.values) { model.loadMesh(this) } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/DefaultEntityModels.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/DefaultEntityModels.kt index 9c1b02937..ccf9f3cfa 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/DefaultEntityModels.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/DefaultEntityModels.kt @@ -13,6 +13,8 @@ package de.bixilon.minosoft.gui.rendering.world.entities +import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.standing.StandingSignModels +import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.wall.WallSignModels import de.bixilon.minosoft.gui.rendering.world.entities.renderer.storage.DoubleChestRenderer import de.bixilon.minosoft.gui.rendering.world.entities.renderer.storage.SingleChestRenderer @@ -24,5 +26,24 @@ object DefaultEntityModels { DoubleChestRenderer.NormalChest, DoubleChestRenderer.TrappedChest, + + + StandingSignModels.Acacia, + StandingSignModels.Birch, + StandingSignModels.Crimson, + StandingSignModels.DarkOak, + StandingSignModels.Jungle, + StandingSignModels.Oak, + StandingSignModels.Spruce, + StandingSignModels.WarpedSign, + + WallSignModels.Acacia, + WallSignModels.Birch, + WallSignModels.Crimson, + WallSignModels.DarkOak, + WallSignModels.Jungle, + WallSignModels.Oak, + WallSignModels.Spruce, + WallSignModels.WarpedSign, ) } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/EntityModels.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/EntityModels.kt index afc384731..d697e544d 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/EntityModels.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/EntityModels.kt @@ -22,7 +22,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTex class EntityModels(val renderWindow: RenderWindow) { private val unbakedModels: MutableMap = mutableMapOf() - val models: MutableMap = mutableMapOf() + val skeletal: MutableMap = mutableMapOf() @Synchronized fun loadUnbakedModel(path: ResourceLocation): SkeletalModel { @@ -30,7 +30,7 @@ class EntityModels(val renderWindow: RenderWindow) { } fun loadModel(name: ResourceLocation, path: ResourceLocation, textureOverride: MutableMap = mutableMapOf()): BakedSkeletalModel { - return models.getOrPut(name) { loadUnbakedModel(path).bake(renderWindow, textureOverride) } + return skeletal.getOrPut(name) { loadUnbakedModel(path).bake(renderWindow, textureOverride) } } fun cleanup() { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/EntityRendererRegister.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/EntityRendererRegister.kt index 11797a527..2c5c3f9b0 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/EntityRendererRegister.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/EntityRendererRegister.kt @@ -18,5 +18,5 @@ import de.bixilon.minosoft.gui.rendering.models.ModelLoader interface EntityRendererRegister { - fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) {} + fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) = Unit } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/MeshedBlockEntityRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/MeshedBlockEntityRenderer.kt index 811b44dc0..80d489427 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/MeshedBlockEntityRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/MeshedBlockEntityRenderer.kt @@ -14,13 +14,10 @@ package de.bixilon.minosoft.gui.rendering.world.entities import de.bixilon.minosoft.data.entities.block.BlockEntity -import de.bixilon.minosoft.data.registries.blocks.BlockState import de.bixilon.minosoft.gui.rendering.RenderWindow import de.bixilon.minosoft.gui.rendering.models.SingleBlockRenderable interface MeshedBlockEntityRenderer : BlockEntityRenderer, SingleBlockRenderable { - override val blockState: BlockState - get() = TODO("Not yet implemented") override var light: Int get() = 0 set(value) {} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/SignBlockEntityRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/SignBlockEntityRenderer.kt similarity index 85% rename from src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/SignBlockEntityRenderer.kt rename to src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/SignBlockEntityRenderer.kt index f1148bd39..4711e38ef 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/SignBlockEntityRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/SignBlockEntityRenderer.kt @@ -11,10 +11,12 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.gui.rendering.world.entities.renderer +package de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign +import de.bixilon.kutil.cast.CastUtil.nullCast import de.bixilon.minosoft.data.entities.block.SignBlockEntity import de.bixilon.minosoft.data.registries.blocks.BlockState +import de.bixilon.minosoft.data.registries.blocks.types.entity.sign.SignBlock import de.bixilon.minosoft.gui.rendering.world.entities.MeshedBlockEntityRenderer import de.bixilon.minosoft.gui.rendering.world.mesh.WorldMesh import glm_.vec3.Vec3i @@ -22,10 +24,15 @@ import java.util.* class SignBlockEntityRenderer( val sign: SignBlockEntity, + override val blockState: BlockState, ) : MeshedBlockEntityRenderer { override fun singleRender(position: Vec3i, mesh: WorldMesh, random: Random, blockState: BlockState, neighbours: Array, light: ByteArray, ambientLight: FloatArray, tints: IntArray?): Boolean { + val model = this.blockState.block.nullCast() ?: return false println("Rendering sign at $position") + + // ToDo + return true } } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/SignModel.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/SignModel.kt new file mode 100644 index 000000000..acd1e7b49 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/SignModel.kt @@ -0,0 +1,20 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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.world.entities.renderer.sign + +import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture + +abstract class SignModel( + val texture: AbstractTexture, +) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/standing/StandingSignModel.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/standing/StandingSignModel.kt new file mode 100644 index 000000000..59c05c063 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/standing/StandingSignModel.kt @@ -0,0 +1,21 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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.world.entities.renderer.sign.standing + +import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture +import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.SignModel + +class StandingSignModel( + texture: AbstractTexture, +) : SignModel(texture) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/standing/StandingSignModels.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/standing/StandingSignModels.kt new file mode 100644 index 000000000..3dc9c03ce --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/standing/StandingSignModels.kt @@ -0,0 +1,98 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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.world.entities.renderer.sign.standing + +import de.bixilon.kutil.cast.CastUtil.nullCast +import de.bixilon.minosoft.data.registries.ResourceLocation +import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks +import de.bixilon.minosoft.data.registries.blocks.types.entity.sign.StandingSignBlock +import de.bixilon.minosoft.gui.rendering.RenderWindow +import de.bixilon.minosoft.gui.rendering.models.ModelLoader +import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture +import de.bixilon.minosoft.gui.rendering.world.entities.EntityRendererRegister +import de.bixilon.minosoft.util.KUtil.toResourceLocation + +object StandingSignModels { + + fun register(renderWindow: RenderWindow, modelLoader: ModelLoader, textureName: ResourceLocation, block: ResourceLocation) { + val block = renderWindow.connection.registries.blockRegistry[block].nullCast() ?: return + val texture = renderWindow.textureManager.staticTextures.createTexture(textureName) + val signModel = StandingSignModel(texture) + block.model = signModel + } + + object Acacia : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/acacia".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.ACACIA_SIGN) + } + } + + object Birch : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/birch".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.BIRCH_SIGN) + } + } + + object Crimson : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/crimson".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.CRIMSON_SIGN) + } + } + + object DarkOak : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/dark_oak".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.DARK_OAK_SIGN) + } + } + + object Jungle : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/jungle".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.JUNGLE_SIGN) + } + } + + object Oak : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/oak".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.OAK_SIGN) + } + } + + object Spruce : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/spruce".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.SPRUCE_SIGN) + } + } + + object WarpedSign : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/warped".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.WARPED_SIGN) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/wall/WallSignModel.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/wall/WallSignModel.kt new file mode 100644 index 000000000..7a539dc82 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/wall/WallSignModel.kt @@ -0,0 +1,21 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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.world.entities.renderer.sign.wall + +import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture +import de.bixilon.minosoft.gui.rendering.world.entities.renderer.sign.SignModel + +class WallSignModel( + texture: AbstractTexture, +) : SignModel(texture) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/wall/WallSignModels.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/wall/WallSignModels.kt new file mode 100644 index 000000000..f1ca1c836 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/sign/wall/WallSignModels.kt @@ -0,0 +1,98 @@ +/* + * Minosoft + * Copyright (C) 2020-2022 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.world.entities.renderer.sign.wall + +import de.bixilon.kutil.cast.CastUtil.nullCast +import de.bixilon.minosoft.data.registries.ResourceLocation +import de.bixilon.minosoft.data.registries.blocks.MinecraftBlocks +import de.bixilon.minosoft.data.registries.blocks.types.entity.sign.WallSignBlock +import de.bixilon.minosoft.gui.rendering.RenderWindow +import de.bixilon.minosoft.gui.rendering.models.ModelLoader +import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture +import de.bixilon.minosoft.gui.rendering.world.entities.EntityRendererRegister +import de.bixilon.minosoft.util.KUtil.toResourceLocation + +object WallSignModels { + + fun register(renderWindow: RenderWindow, modelLoader: ModelLoader, textureName: ResourceLocation, block: ResourceLocation) { + val block = renderWindow.connection.registries.blockRegistry[block].nullCast() ?: return + val texture = renderWindow.textureManager.staticTextures.createTexture(textureName) + val signModel = WallSignModel(texture) + block.model = signModel + } + + object Acacia : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/acacia".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.ACACIA_WALL_SIGN) + } + } + + object Birch : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/birch".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.BIRCH_WALL_SIGN) + } + } + + object Crimson : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/crimson".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.CRIMSON_WALL_SIGN) + } + } + + object DarkOak : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/dark_oak".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.DARK_OAK_WALL_SIGN) + } + } + + object Jungle : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/jungle".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.JUNGLE_WALL_SIGN) + } + } + + object Oak : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/oak".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.OAK_WALL_SIGN) + } + } + + object Spruce : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/spruce".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.SPRUCE_WALL_SIGN) + } + } + + object WarpedSign : EntityRendererRegister { + val TEXTURE = "minecraft:entity/signs/warped".toResourceLocation().texture() + + override fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) { + register(renderWindow, modelLoader, TEXTURE, MinecraftBlocks.WARPED_WALL_SIGN) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/storage/SingleChestRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/storage/SingleChestRenderer.kt index 827149ada..9d21e3007 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/storage/SingleChestRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/entities/renderer/storage/SingleChestRenderer.kt @@ -43,7 +43,6 @@ class SingleChestRenderer( light, ) { - companion object { val SINGLE_MODEL = "minecraft:block/entities/single_chest".toResourceLocation().bbModel() diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt index 1b77df6b7..959ea7486 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt @@ -92,7 +92,7 @@ class SolidCullSectionPreparer( position = Vec3i(offsetX + x, offsetY + y, offsetZ + z) blockEntity = section.blockEntities.unsafeGet(x, y, z) val blockEntityModel = blockEntity?.getRenderer(renderWindow, blockState, position, light[6].toInt()) - if (blockEntityModel != null) { + if (blockEntityModel != null) { // ToDo: ignore if is MeshedBlockEntityRenderer? blockEntities += blockEntityModel mesh.addBlock(x, y, z) }