fix chest renderer in <1.13

This commit is contained in:
Moritz Zwerger 2023-10-31 23:22:26 +01:00
parent 076d63e075
commit b3a34c0cf0
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 8 additions and 4 deletions

View File

@ -312,7 +312,7 @@ class SolidSectionMesherTest {
assertEquals(queue.blocks.size, 7)
}
// TODO: test sign block entity rendering
// TODO: test skylight (w/ heightmap), fast bedrock, camera offset
// TODO: test skylight (w/ heightmap), fast bedrock, camera offset, block random offset
class TestQueue {
val blocks: MutableSet<RenderedBlock> = mutableSetOf()

View File

@ -18,6 +18,8 @@ import de.bixilon.minosoft.data.entities.block.BlockEntityFactory
import de.bixilon.minosoft.data.registries.blocks.properties.BlockProperties
import de.bixilon.minosoft.data.registries.blocks.properties.ChestTypes
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
import de.bixilon.minosoft.data.registries.blocks.state.PropertyBlockState
import de.bixilon.minosoft.data.registries.blocks.types.entity.storage.WoodenChestBlock
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.RenderContext
@ -31,8 +33,10 @@ open class ChestBlockEntity(connection: PlayConnection) : StorageBlockEntity(con
override var renderer: ChestRenderer? = null
override fun createRenderer(context: RenderContext, state: BlockState, position: Vec3i, light: Int): ChestRenderer? {
val type: ChestTypes = state[BlockProperties.CHEST_TYPE]
if (type == ChestTypes.SINGLE) {
if (state.block !is WoodenChestBlock<*>) return null
if (state !is PropertyBlockState) return null
val type = state.properties[BlockProperties.CHEST_TYPE]
if (type == ChestTypes.SINGLE || type == null) { // TODO: type null: check neighbour blocks (<1.13)
return SingleChestRenderer(this, context, state, position, context.models.skeletal[getSingleModel()] ?: return null, light)
}

View File

@ -85,7 +85,7 @@ open class PropertyBlockState(
}
override fun <T> get(property: BlockProperty<T>): T {
val value = this.properties[property] ?: throw IllegalArgumentException("$this has not property $property")
val value = this.properties[property] ?: throw IllegalArgumentException("$this has no property $property")
return value.unsafeCast()
}