mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 02:45:13 -04:00
improve meshed entity rendering
This commit is contained in:
parent
3fc486f592
commit
351267d8cb
@ -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<BlockState?>, light: ByteArray, tints: IntArray?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, 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<BlockState?>, light: ByteArray, tints: IntArray?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, 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<BlockState?>, 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<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, 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<BlockState?>, light: ByteArray, tints: IntArray?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, 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
|
||||
}
|
||||
|
@ -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<ShulkerBoxRenderer {
|
||||
class ShulkerBoxBlockEntity(connection: PlayConnection) : StorageBlockEntity(connection), RenderedBlockEntity<ShulkerBoxRenderer> {
|
||||
override var renderer: ShulkerBoxRenderer? = null
|
||||
|
||||
override fun createRenderer(context: RenderContext, state: BlockState, position: Vec3i, light: Int): ShulkerBoxRenderer? {
|
||||
|
@ -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<BlockState?>, 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<BlockState?>, 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<BlockState?>, 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())
|
||||
|
||||
|
@ -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<BlockEntityRenderer<*>> = 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<RenderedBlockEntity<*>>()
|
||||
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<BlockRender>() ?: 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<BlockState?>, neighbours: Array<ChunkSection?>, 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<BlockState?>, neighbours: Array<ChunkSection?>, 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<BlockState?>, neighbours: Array<ChunkSection?>, x: Int, y: Int, z: Int, light: ByteArray, position: Vec3i, neighbourChunks: Array<Chunk>, 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)
|
||||
|
@ -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<BlockState?>, light: ByteArray, tints: IntArray?) = prototype()
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, 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()
|
||||
|
@ -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<BlockState?>, light: ByteArray, tints: IntArray?): Boolean {
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean {
|
||||
var rendered = false
|
||||
|
||||
for ((directionIndex, faces) in faces.withIndex()) {
|
||||
|
@ -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>,
|
||||
) : BlockRender {
|
||||
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, 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<BlockState?>, 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
|
||||
}
|
||||
}
|
||||
|
@ -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<BlockState?>, light: ByteArray, tints: IntArray?): Boolean
|
||||
fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?): Boolean
|
||||
|
||||
fun getProperties(direction: Directions): SideProperties? = 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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.models.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<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity): Boolean
|
||||
}
|
@ -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<BlockState?>, 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<BlockState?>, 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? {
|
||||
|
@ -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<BlockState?>, 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<BlockState?>, 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) {
|
||||
|
@ -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<BlockState?>, light: ByteArray, tints: IntArray?) = false
|
||||
override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMeshes, random: Random?, state: BlockState, neighbours: Array<BlockState?>, light: ByteArray, tints: IntArray?, entity: BlockEntity?) = false
|
||||
|
||||
override fun render(gui: GUIRenderer, offset: Vec2, consumer: GUIVertexConsumer, options: GUIVertexOptions?, size: Vec2, stack: ItemStack) = Unit
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user