From 8fe94cfcaf44d58f8faf6c085a7a1ba1ee70a402 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Sun, 29 Oct 2023 22:41:10 +0100 Subject: [PATCH] shulker box: block culling --- .../types/entity/storage/ShulkerBoxBlock.kt | 5 +++ .../property/FullBlockPropertyRenderer.kt | 27 ++++++++++++++++ .../property/PropertyOnlyBlockRender.kt | 31 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/FullBlockPropertyRenderer.kt create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/PropertyOnlyBlockRender.kt diff --git a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/storage/ShulkerBoxBlock.kt b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/storage/ShulkerBoxBlock.kt index d67c63ede..0ebcae9cb 100644 --- a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/storage/ShulkerBoxBlock.kt +++ b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/entity/storage/ShulkerBoxBlock.kt @@ -25,12 +25,17 @@ import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft import de.bixilon.minosoft.data.registries.identified.ResourceLocation import de.bixilon.minosoft.data.registries.item.items.Item import de.bixilon.minosoft.data.registries.registries.Registries +import de.bixilon.minosoft.gui.rendering.models.block.state.render.property.FullBlockPropertyRenderer import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection open class ShulkerBoxBlock(identifier: ResourceLocation, settings: BlockSettings) : Block(identifier, settings), StorageBlock, FullOpaqueBlock, BlockWithItem { override val item: Item = this::item.inject(identifier) override val hardness: Float get() = 2.0f + init { + this.model = FullBlockPropertyRenderer + } + override fun createBlockEntity(connection: PlayConnection) = ShulkerBoxBlockEntity(connection) companion object : BlockFactory { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/FullBlockPropertyRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/FullBlockPropertyRenderer.kt new file mode 100644 index 000000000..a2ff6ea5e --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/FullBlockPropertyRenderer.kt @@ -0,0 +1,27 @@ +/* + * 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.property + +import de.bixilon.kotlinglm.vec2.Vec2 +import de.bixilon.minosoft.data.direction.Directions +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.system.base.texture.TextureTransparencies +import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2Util.EMPTY + +object FullBlockPropertyRenderer : PropertyOnlyBlockRender { + private val properties = SideProperties(arrayOf(FaceProperties(Vec2.EMPTY, Vec2(1.0f), TextureTransparencies.OPAQUE)), TextureTransparencies.OPAQUE) + + override fun getProperties(direction: Directions) = this.properties +} 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 new file mode 100644 index 000000000..e4d103282 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/models/block/state/render/property/PropertyOnlyBlockRender.kt @@ -0,0 +1,31 @@ +/* + * 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.property + +import de.bixilon.kotlinglm.vec2.Vec2 +import de.bixilon.minosoft.data.container.stack.ItemStack +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.ChunkMesh +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.state.render.BlockRender +import java.util.* + +interface PropertyOnlyBlockRender : BlockRender { + override fun render(position: BlockPosition, offset: FloatArray, mesh: ChunkMesh, random: Random?, state: BlockState, neighbours: Array, light: ByteArray, tints: IntArray?) = false + + override fun render(gui: GUIRenderer, offset: Vec2, consumer: GUIVertexConsumer, options: GUIVertexOptions?, size: Vec2, stack: ItemStack) = Unit +}