mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
wip sign rendering
This commit is contained in:
parent
e581e19873
commit
c031b241f9
@ -29,7 +29,7 @@ abstract class BlockEntity(
|
|||||||
|
|
||||||
open fun tick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i) = Unit
|
open fun tick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i) = Unit
|
||||||
|
|
||||||
fun getRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer<out BlockEntity>? {
|
open fun getRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer<out BlockEntity>? {
|
||||||
if (this.renderer?.blockState != blockState) {
|
if (this.renderer?.blockState != blockState) {
|
||||||
this.renderer = createRenderer(renderWindow, blockState, blockPosition, light)
|
this.renderer = createRenderer(renderWindow, blockState, blockPosition, light)
|
||||||
} else {
|
} else {
|
||||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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<*>
|
||||||
|
}
|
@ -18,12 +18,12 @@ import de.bixilon.minosoft.data.registries.ResourceLocation
|
|||||||
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
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.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
class SignBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
|
class SignBlockEntity(connection: PlayConnection) : MeshedBlockEntity(connection) {
|
||||||
var lines: Array<ChatComponent> = Array(ProtocolDefinition.SIGN_LINES) { ChatComponent.of("") }
|
var lines: Array<ChatComponent> = 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 {
|
override fun createMeshedRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i): SignBlockEntityRenderer {
|
||||||
return SignBlockEntityRenderer(this)
|
return SignBlockEntityRenderer(this, blockState)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : BlockEntityFactory<SignBlockEntity> {
|
companion object : BlockEntityFactory<SignBlockEntity> {
|
||||||
|
@ -30,12 +30,12 @@ open class ChestBlockEntity(connection: PlayConnection) : StorageBlockEntity(con
|
|||||||
override fun createRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer<*>? {
|
override fun createRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer<*>? {
|
||||||
val type = blockState.properties[BlockProperties.CHEST_TYPE] ?: return null
|
val type = blockState.properties[BlockProperties.CHEST_TYPE] ?: return null
|
||||||
if (type == ChestTypes.SINGLE) {
|
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) {
|
if (type == ChestTypes.LEFT) {
|
||||||
// only left chest will be rendered (the model is the double chest), reduces drawing overhead
|
// 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
|
return null
|
||||||
|
@ -26,7 +26,7 @@ import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
|||||||
class EnderChestBlockEntity(connection: PlayConnection) : StorageBlockEntity(connection) {
|
class EnderChestBlockEntity(connection: PlayConnection) : StorageBlockEntity(connection) {
|
||||||
|
|
||||||
override fun createRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer<out BlockEntity>? {
|
override fun createRenderer(renderWindow: RenderWindow, blockState: BlockState, blockPosition: Vec3i, light: Int): BlockEntityRenderer<out BlockEntity>? {
|
||||||
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)
|
return SingleChestRenderer(this, renderWindow, blockState, blockPosition, model, light)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.DaylightDetectorBlock
|
||||||
import de.bixilon.minosoft.data.registries.blocks.types.entity.redstone.PistonBlock
|
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.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.leaves.LeavesBlock
|
||||||
import de.bixilon.minosoft.data.registries.blocks.types.plant.CropBlock
|
import de.bixilon.minosoft.data.registries.blocks.types.plant.CropBlock
|
||||||
import de.bixilon.minosoft.data.registries.blocks.types.plant.PlantBlock
|
import de.bixilon.minosoft.data.registries.blocks.types.plant.PlantBlock
|
||||||
@ -78,7 +80,8 @@ object DefaultBlockFactories : DefaultClassFactory<BlockFactory<*>>(
|
|||||||
JukeboxBlock,
|
JukeboxBlock,
|
||||||
DispenserBlock,
|
DispenserBlock,
|
||||||
DropperBlock,
|
DropperBlock,
|
||||||
SignBlock,
|
WallSignBlock,
|
||||||
|
StandingSignBlock,
|
||||||
MobSpawnerBlock,
|
MobSpawnerBlock,
|
||||||
PistonBlock,
|
PistonBlock,
|
||||||
BrewingStandBlock,
|
BrewingStandBlock,
|
||||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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<String, Any>) : BlockWithEntity<SignBlockEntity>(resourceLocation, registries, data) {
|
||||||
|
abstract val model: SignModel?
|
||||||
|
}
|
||||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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<String, Any>) : SignBlock(resourceLocation, registries, data) {
|
||||||
|
override var model: StandingSignModel? = null
|
||||||
|
|
||||||
|
companion object : BlockFactory<StandingSignBlock>, MultiClassFactory<StandingSignBlock> {
|
||||||
|
override val ALIASES: Set<String> = setOf("SignBlock")
|
||||||
|
|
||||||
|
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): StandingSignBlock {
|
||||||
|
return StandingSignBlock(resourceLocation, registries, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,18 +11,20 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* 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.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.blocks.BlockFactory
|
import de.bixilon.minosoft.data.registries.blocks.BlockFactory
|
||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
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<String, Any>) : BlockWithEntity<SignBlockEntity>(resourceLocation, registries, data) {
|
open class WallSignBlock(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>) : SignBlock(resourceLocation, registries, data) {
|
||||||
|
override var model: WallSignModel? = null
|
||||||
|
|
||||||
companion object : BlockFactory<SignBlock> {
|
companion object : BlockFactory<WallSignBlock> {
|
||||||
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): SignBlock {
|
|
||||||
return SignBlock(resourceLocation, registries, data)
|
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): WallSignBlock {
|
||||||
|
return WallSignBlock(resourceLocation, registries, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -191,7 +191,7 @@ class RenderWindow(
|
|||||||
|
|
||||||
Log.log(LogMessageType.RENDERING_LOADING, LogLevels.VERBOSE) { "Loading skeletal meshes ${stopwatch.totalTime()}" }
|
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)
|
model.loadMesh(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.world.entities
|
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.DoubleChestRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.world.entities.renderer.storage.SingleChestRenderer
|
import de.bixilon.minosoft.gui.rendering.world.entities.renderer.storage.SingleChestRenderer
|
||||||
|
|
||||||
@ -24,5 +26,24 @@ object DefaultEntityModels {
|
|||||||
|
|
||||||
DoubleChestRenderer.NormalChest,
|
DoubleChestRenderer.NormalChest,
|
||||||
DoubleChestRenderer.TrappedChest,
|
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,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTex
|
|||||||
|
|
||||||
class EntityModels(val renderWindow: RenderWindow) {
|
class EntityModels(val renderWindow: RenderWindow) {
|
||||||
private val unbakedModels: MutableMap<ResourceLocation, SkeletalModel> = mutableMapOf()
|
private val unbakedModels: MutableMap<ResourceLocation, SkeletalModel> = mutableMapOf()
|
||||||
val models: MutableMap<ResourceLocation, BakedSkeletalModel> = mutableMapOf()
|
val skeletal: MutableMap<ResourceLocation, BakedSkeletalModel> = mutableMapOf()
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun loadUnbakedModel(path: ResourceLocation): SkeletalModel {
|
fun loadUnbakedModel(path: ResourceLocation): SkeletalModel {
|
||||||
@ -30,7 +30,7 @@ class EntityModels(val renderWindow: RenderWindow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun loadModel(name: ResourceLocation, path: ResourceLocation, textureOverride: MutableMap<Int, AbstractTexture> = mutableMapOf()): BakedSkeletalModel {
|
fun loadModel(name: ResourceLocation, path: ResourceLocation, textureOverride: MutableMap<Int, AbstractTexture> = mutableMapOf()): BakedSkeletalModel {
|
||||||
return models.getOrPut(name) { loadUnbakedModel(path).bake(renderWindow, textureOverride) }
|
return skeletal.getOrPut(name) { loadUnbakedModel(path).bake(renderWindow, textureOverride) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cleanup() {
|
fun cleanup() {
|
||||||
|
@ -18,5 +18,5 @@ import de.bixilon.minosoft.gui.rendering.models.ModelLoader
|
|||||||
|
|
||||||
interface EntityRendererRegister {
|
interface EntityRendererRegister {
|
||||||
|
|
||||||
fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) {}
|
fun register(renderWindow: RenderWindow, modelLoader: ModelLoader) = Unit
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,10 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.world.entities
|
package de.bixilon.minosoft.gui.rendering.world.entities
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.entities.block.BlockEntity
|
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.RenderWindow
|
||||||
import de.bixilon.minosoft.gui.rendering.models.SingleBlockRenderable
|
import de.bixilon.minosoft.gui.rendering.models.SingleBlockRenderable
|
||||||
|
|
||||||
interface MeshedBlockEntityRenderer<E : BlockEntity> : BlockEntityRenderer<E>, SingleBlockRenderable {
|
interface MeshedBlockEntityRenderer<E : BlockEntity> : BlockEntityRenderer<E>, SingleBlockRenderable {
|
||||||
override val blockState: BlockState
|
|
||||||
get() = TODO("Not yet implemented")
|
|
||||||
override var light: Int
|
override var light: Int
|
||||||
get() = 0
|
get() = 0
|
||||||
set(value) {}
|
set(value) {}
|
||||||
|
@ -11,10 +11,12 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* 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.entities.block.SignBlockEntity
|
||||||
import de.bixilon.minosoft.data.registries.blocks.BlockState
|
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.entities.MeshedBlockEntityRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.world.mesh.WorldMesh
|
import de.bixilon.minosoft.gui.rendering.world.mesh.WorldMesh
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
@ -22,10 +24,15 @@ import java.util.*
|
|||||||
|
|
||||||
class SignBlockEntityRenderer(
|
class SignBlockEntityRenderer(
|
||||||
val sign: SignBlockEntity,
|
val sign: SignBlockEntity,
|
||||||
|
override val blockState: BlockState,
|
||||||
) : MeshedBlockEntityRenderer<SignBlockEntity> {
|
) : MeshedBlockEntityRenderer<SignBlockEntity> {
|
||||||
|
|
||||||
override fun singleRender(position: Vec3i, mesh: WorldMesh, random: Random, blockState: BlockState, neighbours: Array<BlockState?>, light: ByteArray, ambientLight: FloatArray, tints: IntArray?): Boolean {
|
override fun singleRender(position: Vec3i, mesh: WorldMesh, random: Random, blockState: BlockState, neighbours: Array<BlockState?>, light: ByteArray, ambientLight: FloatArray, tints: IntArray?): Boolean {
|
||||||
|
val model = this.blockState.block.nullCast<SignBlock>() ?: return false
|
||||||
println("Rendering sign at $position")
|
println("Rendering sign at $position")
|
||||||
|
|
||||||
|
// ToDo
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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,
|
||||||
|
)
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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)
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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<StandingSignBlock>() ?: 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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)
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* 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<WallSignBlock>() ?: 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -43,7 +43,6 @@ class SingleChestRenderer(
|
|||||||
light,
|
light,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val SINGLE_MODEL = "minecraft:block/entities/single_chest".toResourceLocation().bbModel()
|
val SINGLE_MODEL = "minecraft:block/entities/single_chest".toResourceLocation().bbModel()
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class SolidCullSectionPreparer(
|
|||||||
position = Vec3i(offsetX + x, offsetY + y, offsetZ + z)
|
position = Vec3i(offsetX + x, offsetY + y, offsetZ + z)
|
||||||
blockEntity = section.blockEntities.unsafeGet(x, y, z)
|
blockEntity = section.blockEntities.unsafeGet(x, y, z)
|
||||||
val blockEntityModel = blockEntity?.getRenderer(renderWindow, blockState, position, light[6].toInt())
|
val blockEntityModel = blockEntity?.getRenderer(renderWindow, blockState, position, light[6].toInt())
|
||||||
if (blockEntityModel != null) {
|
if (blockEntityModel != null) { // ToDo: ignore if is MeshedBlockEntityRenderer?
|
||||||
blockEntities += blockEntityModel
|
blockEntities += blockEntityModel
|
||||||
mesh.addBlock(x, y, z)
|
mesh.addBlock(x, y, z)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user