diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesherTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesherTest.kt index 39168341f..9ef2ead62 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesherTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesherTest.kt @@ -38,7 +38,6 @@ import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.FaceProperties import de.bixilon.minosoft.gui.rendering.models.block.state.baked.cull.side.SideProperties import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender -import de.bixilon.minosoft.gui.rendering.models.block.state.render.EntityBlockRender import de.bixilon.minosoft.gui.rendering.system.base.texture.TextureTransparencies import de.bixilon.minosoft.gui.rendering.system.dummy.DummyRenderSystem import de.bixilon.minosoft.gui.rendering.tint.TintManager @@ -376,12 +375,12 @@ class SolidSectionMesherTest { } val state = BlockState(block, 0) state.model = object : TestModel(this, null) { - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { assertEquals(light.size, 7) for ((index, entry) in light.withIndex()) { assertEquals(required[index], entry.toInt() and 0xFF) } - return super.render(position, offset, mesh, random, state, neighbours, light, tints) + return super.render(position, offset, mesh, random, state, neighbours, light, tints, entity) } } @@ -394,12 +393,12 @@ class SolidSectionMesherTest { } val state = BlockState(block, 0) state.model = object : TestModel(this, null) { - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { assertEquals(neighbours.size, 6) for ((index, entry) in neighbours.withIndex()) { assertEquals(required[index], entry) } - return super.render(position, offset, mesh, random, state, neighbours, light, tints) + return super.render(position, offset, mesh, random, state, neighbours, light, tints, entity) } } @@ -434,13 +433,9 @@ class SolidSectionMesherTest { } init { - this.model = object : EntityBlockRender { + this.model = object : BlockRender { - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { - Broken("This requires an entity") - } - - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity): Boolean { + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { entities.add(TestQueue.RenderedEntity(Vec3i(position), state, true)).let { if (!it) throw IllegalArgumentException("Twice!!!") } return true @@ -463,7 +458,7 @@ class SolidSectionMesherTest { return this.properties } - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { queue.blocks.add(TestQueue.RenderedBlock(Vec3i(position), state, tints?.getOrNull(0))).let { if (!it) throw IllegalArgumentException("Twice!!!") } return true } diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ShulkerBoxBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ShulkerBoxBlockEntity.kt index dc58e9a0a..5a5ad5757 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ShulkerBoxBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ShulkerBoxBlockEntity.kt @@ -25,7 +25,7 @@ import de.bixilon.minosoft.gui.rendering.chunk.entities.renderer.storage.shulker import de.bixilon.minosoft.gui.rendering.skeletal.baked.BakedSkeletalModel import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection -class ShulkerBoxBlockEntity(connection: PlayConnection) : StorageBlockEntity(connection), RenderedBlockEntity { override var renderer: ShulkerBoxRenderer? = null override fun createRenderer(context: RenderContext, state: BlockState, position: Vec3i, light: Int): ShulkerBoxRenderer? { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/sign/SignBlockEntityRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/sign/SignBlockEntityRenderer.kt index 4560be66e..3e2f8d639 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/sign/SignBlockEntityRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/entities/renderer/sign/SignBlockEntityRenderer.kt @@ -40,14 +40,14 @@ import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions import de.bixilon.minosoft.gui.rendering.models.block.element.ModelElement.Companion.BLOCK_SIZE -import de.bixilon.minosoft.gui.rendering.models.block.state.render.EntityBlockRender +import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.rotateAssign import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.toVec3 import java.util.* class SignBlockEntityRenderer( val context: RenderContext, -) : EntityBlockRender { +) : BlockRender { private fun BlockState.getRotation(): Float { if (this !is PropertyBlockState) return 0.0f @@ -55,13 +55,8 @@ class SignBlockEntityRenderer( return rotation * ROTATION_STEP } - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { - state.model?.render(position, offset, mesh, random, state, neighbours, light, tints) // render wood part - return true - } - - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity): Boolean { - render(position, offset, mesh, random, state, neighbours, light, tints) + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { + state.model?.render(position, offset, mesh, random, state, neighbours, light, tints, entity) // render wood part if (entity !is SignBlockEntity) return true renderText(state, entity, offset, mesh, light[SELF_LIGHT_INDEX].toInt()) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesher.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesher.kt index 74855a57c..7a89df8c3 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesher.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/mesher/SolidSectionMesher.kt @@ -17,6 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2i import de.bixilon.kotlinglm.vec3.Vec3 import de.bixilon.kotlinglm.vec3.Vec3i import de.bixilon.kutil.cast.CastUtil.nullCast +import de.bixilon.kutil.cast.CastUtil.unsafeCast import de.bixilon.kutil.observer.DataObserver.Companion.observe import de.bixilon.minosoft.data.direction.Directions import de.bixilon.minosoft.data.direction.Directions.Companion.O_DOWN @@ -36,8 +37,8 @@ import de.bixilon.minosoft.data.world.chunk.neighbours.ChunkNeighbours import de.bixilon.minosoft.data.world.positions.BlockPosition import de.bixilon.minosoft.gui.rendering.RenderContext import de.bixilon.minosoft.gui.rendering.chunk.entities.BlockEntityRenderer +import de.bixilon.minosoft.gui.rendering.chunk.entities.renderer.RenderedBlockEntity import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes -import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition import java.util.* @@ -61,7 +62,6 @@ class SolidSectionMesher( val isLowestSection = sectionHeight == chunk.minSection val isHighestSection = sectionHeight == chunk.maxSection val blocks = section.blocks - val sectionLight = section.light val entities: ArrayList> = ArrayList(section.blockEntities.count) val position = BlockPosition() @@ -89,7 +89,12 @@ class SolidSectionMesher( val state = blocks[index] ?: continue if (state.block is FluidBlock) continue // fluids are rendered in a different renderer - light[SELF_LIGHT_INDEX] = sectionLight[index] + val model = state.model ?: state.block.model + val blockEntity = section.blockEntities[index]?.nullCast>() + if (model == null && blockEntity == null) continue + + + light[SELF_LIGHT_INDEX] = section.light[index] position.z = offsetZ + z floatOffset[2] = (position.z - cameraOffset.z).toFloat() @@ -98,34 +103,17 @@ class SolidSectionMesher( light[SELF_LIGHT_INDEX] = (light[SELF_LIGHT_INDEX].toInt() or 0xF0).toByte() } - val entity = section.blockEntities[index]?.getRenderer(context, state, position, light[SELF_LIGHT_INDEX].toInt()) - val blockModel = state.block.model ?: state.model - val model = blockModel ?: entity.nullCast() ?: continue - if (y == 0) { - if (fastBedrock && state === bedrock) { - neighbourBlocks[O_DOWN] = bedrock - } else { - neighbourBlocks[O_DOWN] = neighbours[O_DOWN]?.blocks?.let { it[x, ProtocolDefinition.SECTION_MAX_Y, z] } - light[O_DOWN] = (if (isLowestSection) chunk.light.bottom else neighbours[O_DOWN]?.light)?.get(ProtocolDefinition.SECTION_MAX_Y shl 8 or baseIndex) ?: 0x00 - } - } else { - neighbourBlocks[O_DOWN] = blocks[(y - 1) shl 8 or baseIndex] - light[O_DOWN] = sectionLight[(y - 1) shl 8 or baseIndex] - } - if (y == ProtocolDefinition.SECTION_MAX_Y) { - neighbourBlocks[O_UP] = neighbours[O_UP]?.blocks?.let { it[x, 0, z] } - light[O_UP] = (if (isHighestSection) chunk.light.top else neighbours[O_UP]?.light)?.get((z shl 4) or x) ?: 0x00 - } else { - neighbourBlocks[O_UP] = blocks[(y + 1) shl 8 or baseIndex] - light[O_UP] = sectionLight[(y + 1) shl 8 or baseIndex] - } + checkDown(state, fastBedrock, baseIndex, isLowestSection, neighbourBlocks, neighbours, x, y, z, light, section, chunk) + checkUp(isHighestSection, baseIndex, neighbourBlocks, neighbours, x, y, z, light, section, chunk) checkNorth(neighbourBlocks, neighbours, x, y, z, light, position, neighbourChunks, section, chunk) checkSouth(neighbourBlocks, neighbours, x, y, z, light, position, neighbourChunks, section, chunk) checkWest(neighbourBlocks, neighbours, x, y, z, light, position, neighbourChunks, section, chunk) checkEast(neighbourBlocks, neighbours, x, y, z, light, position, neighbourChunks, section, chunk) + // TODO: cull neighbours + if (position.y - 1 >= maxHeight) { light[O_UP] = (light[O_UP].toInt() or 0xF0).toByte() light[O_DOWN] = (light[O_DOWN].toInt() or 0xF0).toByte() @@ -143,11 +131,10 @@ class SolidSectionMesher( val tints = tints.getBlockTint(state, chunk.getBiome(position.x and 0x0F, y, position.z and 0x0F), x, y, z) - var rendered = model.render(position, floatOffset, mesh, random, state, neighbourBlocks, light, tints) + var rendered = false + model?.render(position, floatOffset, mesh, random, state, neighbourBlocks, light, tints, blockEntity.unsafeCast())?.let { if (it) rendered = true } - if (entity is BlockRender) { - rendered = entity.render(position, floatOffset, mesh, random, state, neighbourBlocks, light, tints) || rendered - } + blockEntity?.getRenderer(context, state, position, light[SELF_LIGHT_INDEX].toInt())?.let { rendered = true; entities += it } if (offset != null) { floatOffset[0] -= offset.x @@ -165,6 +152,30 @@ class SolidSectionMesher( mesh.blockEntities = entities } + private inline fun checkDown(state: BlockState, fastBedrock: Boolean, baseIndex: Int, lowest: Boolean, neighbourBlocks: Array, neighbours: Array, x: Int, y: Int, z: Int, light: ByteArray, section: ChunkSection, chunk: Chunk) { + if (y == 0) { + if (fastBedrock && state === bedrock) { + neighbourBlocks[O_DOWN] = bedrock + } else { + neighbourBlocks[O_DOWN] = neighbours[O_DOWN]?.blocks?.let { it[x, ProtocolDefinition.SECTION_MAX_Y, z] } + light[O_DOWN] = (if (lowest) chunk.light.bottom else neighbours[O_DOWN]?.light)?.get(ProtocolDefinition.SECTION_MAX_Y shl 8 or baseIndex) ?: 0x00 + } + } else { + neighbourBlocks[O_DOWN] = section.blocks[(y - 1) shl 8 or baseIndex] + light[O_DOWN] = section.light[(y - 1) shl 8 or baseIndex] + } + } + + fun checkUp(highest: Boolean, baseIndex: Int, neighbourBlocks: Array, neighbours: Array, x: Int, y: Int, z: Int, light: ByteArray, section: ChunkSection, chunk: Chunk) { + if (y == ProtocolDefinition.SECTION_MAX_Y) { + neighbourBlocks[O_UP] = neighbours[O_UP]?.blocks?.let { it[x, 0, z] } + light[O_UP] = (if (highest) chunk.light.top else neighbours[O_UP]?.light)?.get((z shl 4) or x) ?: 0x00 + } else { + neighbourBlocks[O_UP] = section.blocks[(y + 1) shl 8 or baseIndex] + light[O_UP] = section.light[(y + 1) shl 8 or baseIndex] + } + } + private inline fun checkNorth(neighbourBlocks: Array, neighbours: Array, x: Int, y: Int, z: Int, light: ByteArray, position: Vec3i, neighbourChunks: Array, section: ChunkSection, chunk: Chunk) { if (z == 0) { setNeighbour(neighbourBlocks, x, y, ProtocolDefinition.SECTION_MAX_Z, light, position, neighbours[O_NORTH], neighbourChunks[ChunkNeighbours.NORTH], O_NORTH) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/BlockModelPrototype.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/BlockModelPrototype.kt index 3268deb43..fcc82f062 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/BlockModelPrototype.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/BlockModelPrototype.kt @@ -17,6 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2 import de.bixilon.kotlinglm.vec3.Vec3i import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.data.direction.Directions +import de.bixilon.minosoft.data.entities.block.BlockEntity import de.bixilon.minosoft.data.registries.blocks.state.BlockState import de.bixilon.minosoft.data.registries.blocks.types.Block import de.bixilon.minosoft.data.world.positions.BlockPosition @@ -31,7 +32,7 @@ import de.bixilon.minosoft.gui.rendering.models.loader.legacy.ModelChooser import java.util.* class BlockModelPrototype(val model: DirectBlockModel) : BlockRender { - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?) = prototype() + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?) = prototype() override fun getParticleTexture(random: Random?, position: Vec3i) = prototype() override fun getProperties(direction: Directions) = prototype() override fun render(gui: GUIRenderer, offset: Vec2, consumer: GUIVertexConsumer, options: GUIVertexOptions?, size: Vec2, stack: ItemStack) = prototype() diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedModel.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedModel.kt index f27eb804d..f1df12bbe 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedModel.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/baked/BakedModel.kt @@ -17,6 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2 import de.bixilon.kotlinglm.vec3.Vec3i import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.data.direction.Directions +import de.bixilon.minosoft.data.entities.block.BlockEntity import de.bixilon.minosoft.data.registries.blocks.state.BlockState import de.bixilon.minosoft.data.world.positions.BlockPosition import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes @@ -45,7 +46,7 @@ class BakedModel( override fun getParticleTexture(random: Random?, position: Vec3i) = particle - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { var rendered = false for ((directionIndex, faces) in faces.withIndex()) { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/builder/BuiltModel.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/builder/BuiltModel.kt index aed83ecbf..93628042c 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/builder/BuiltModel.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/builder/BuiltModel.kt @@ -17,6 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2 import de.bixilon.kotlinglm.vec3.Vec3i import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.data.direction.Directions +import de.bixilon.minosoft.data.entities.block.BlockEntity import de.bixilon.minosoft.data.registries.blocks.state.BlockState import de.bixilon.minosoft.data.world.positions.BlockPosition import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes @@ -35,11 +36,11 @@ class BuiltModel( val dynamic: Array, ) : BlockRender { - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { - var rendered = model.render(position, offset, mesh, random, state, neighbours, light, tints) + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { + var rendered = model.render(position, offset, mesh, random, state, neighbours, light, tints, entity) for (dynamic in this.dynamic) { - if (dynamic.render(position, offset, mesh, random, state, neighbours, light, tints)) { + if (dynamic.render(position, offset, mesh, random, state, neighbours, light, tints, entity)) { rendered = true } } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/BlockRender.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/BlockRender.kt index d787ced2d..10d2ceb55 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/BlockRender.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/BlockRender.kt @@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.models.block.state.render import de.bixilon.kotlinglm.vec3.Vec3i import de.bixilon.minosoft.data.direction.Directions +import de.bixilon.minosoft.data.entities.block.BlockEntity import de.bixilon.minosoft.data.registries.blocks.state.BlockState import de.bixilon.minosoft.data.world.positions.BlockPosition import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes @@ -26,7 +27,7 @@ import java.util.* interface BlockRender : ItemRender { fun getParticleTexture(random: Random?, position: Vec3i): Texture? = null - fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean + fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean fun getProperties(direction: Directions): SideProperties? = null } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/EntityBlockRender.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/EntityBlockRender.kt deleted file mode 100644 index 70e400205..000000000 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/EntityBlockRender.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.models.block.state.render - -import de.bixilon.minosoft.data.entities.block.BlockEntity -import de.bixilon.minosoft.data.registries.blocks.state.BlockState -import de.bixilon.minosoft.data.world.positions.BlockPosition -import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes -import java.util.* - -interface EntityBlockRender : BlockRender { - fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity): Boolean -} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/PickedBlockRender.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/PickedBlockRender.kt index 1c6f09ff3..5aa6158a4 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/PickedBlockRender.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/PickedBlockRender.kt @@ -17,6 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2 import de.bixilon.kotlinglm.vec3.Vec3i import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.data.direction.Directions +import de.bixilon.minosoft.data.entities.block.BlockEntity import de.bixilon.minosoft.data.registries.blocks.state.BlockState import de.bixilon.minosoft.data.world.positions.BlockPosition import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes @@ -37,8 +38,8 @@ interface PickedBlockRender : BlockRender { default?.render(gui, offset, consumer, options, size, stack) } - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { - return pick(state, neighbours)?.render(position, offset, mesh, random, state, neighbours, light, tints) ?: false + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { + return pick(state, neighbours)?.render(position, offset, mesh, random, state, neighbours, light, tints, entity) ?: false } override fun getProperties(direction: Directions): SideProperties? { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/WeightedBlockRender.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/WeightedBlockRender.kt index 453dc2541..a7b031ab2 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/WeightedBlockRender.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/WeightedBlockRender.kt @@ -18,6 +18,7 @@ import de.bixilon.kotlinglm.vec3.Vec3i import de.bixilon.kutil.exception.Broken import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.data.direction.Directions +import de.bixilon.minosoft.data.entities.block.BlockEntity import de.bixilon.minosoft.data.registries.blocks.state.BlockState import de.bixilon.minosoft.data.world.positions.BlockPosition import de.bixilon.minosoft.data.world.positions.BlockPositionUtil.positionHash @@ -61,8 +62,8 @@ class WeightedBlockRender( return getModel(random, position).getParticleTexture(random, position) } - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?): Boolean { - return getModel(random, position).render(position, offset, mesh, random, state, neighbours, light, tints) + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean { + return getModel(random, position).render(position, offset, mesh, random, state, neighbours, light, tints, entity) } override fun render(gui: GUIRenderer, offset: Vec2, consumer: GUIVertexConsumer, options: GUIVertexOptions?, size: Vec2, stack: ItemStack) { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/PropertyOnlyBlockRender.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/PropertyOnlyBlockRender.kt index e2bd55c78..38f7410b3 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/PropertyOnlyBlockRender.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/PropertyOnlyBlockRender.kt @@ -15,6 +15,7 @@ package de.bixilon.minosoft.gui.rendering.models.block.state.render.property import de.bixilon.kotlinglm.vec2.Vec2 import de.bixilon.minosoft.data.container.stack.ItemStack +import de.bixilon.minosoft.data.entities.block.BlockEntity import de.bixilon.minosoft.data.registries.blocks.state.BlockState import de.bixilon.minosoft.data.world.positions.BlockPosition import de.bixilon.minosoft.gui.rendering.chunk.mesh.ChunkMeshes @@ -25,7 +26,7 @@ import de.bixilon.minosoft.gui.rendering.models.block.state.render.BlockRender import java.util.* interface PropertyOnlyBlockRender : BlockRender { - override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?) = false + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?, entity: BlockEntity?) = false override fun render(gui: GUIRenderer, offset: Vec2, consumer: GUIVertexConsumer, options: GUIVertexOptions?, size: Vec2, stack: ItemStack) = Unit }