From 9e3d3a409ffa1822f92d9e092c2f9977f7da0821 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sat, 19 Jun 2021 19:56:09 +0200 Subject: [PATCH] wip: blocks with force waterloggeed properties (e.g. `kelp`) --- .../data/registries/blocks/types/Block.kt | 1 + .../registries/blocks/types/FluidFillable.kt | 20 ++++++++++++++++ .../data/registries/blocks/types/KelpBlock.kt | 23 +++++++++++++++++++ .../gui/rendering/chunk/WorldRenderer.kt | 4 +++- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/bixilon/minosoft/data/registries/blocks/types/FluidFillable.kt create mode 100644 src/main/java/de/bixilon/minosoft/data/registries/blocks/types/KelpBlock.kt diff --git a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/Block.kt b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/Block.kt index 1b8275e05..4796c845f 100644 --- a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/Block.kt +++ b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/Block.kt @@ -128,6 +128,7 @@ open class Block( "NetherPortalBlock" to { resourceLocation, registries, data -> NetherPortalBlock(resourceLocation, registries, data) }, "RedstoneTorchBlock" to { resourceLocation, registries, data -> RedstoneTorchBlock(resourceLocation, registries, data) }, "HoneyBlock" to { resourceLocation, registries, data -> HoneyBlock(resourceLocation, registries, data) }, + "KelpBlock" to { resourceLocation, registries, data -> KelpBlock(resourceLocation, registries, data) }, ) override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Block { diff --git a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/FluidFillable.kt b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/FluidFillable.kt new file mode 100644 index 000000000..c08109b3d --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/FluidFillable.kt @@ -0,0 +1,20 @@ +/* + * Minosoft + * Copyright (C) 2021 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.data.registries.blocks.types + +import de.bixilon.minosoft.data.registries.ResourceLocation + +interface FluidFillable { + val fluid: ResourceLocation +} diff --git a/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/KelpBlock.kt b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/KelpBlock.kt new file mode 100644 index 000000000..b3f7771df --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/registries/blocks/types/KelpBlock.kt @@ -0,0 +1,23 @@ +/* + * Minosoft + * Copyright (C) 2021 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.data.registries.blocks.types + +import com.google.gson.JsonObject +import de.bixilon.minosoft.data.registries.ResourceLocation +import de.bixilon.minosoft.data.registries.fluid.DefaultFluids +import de.bixilon.minosoft.data.registries.versions.Registries + +open class KelpBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data), FluidFillable { + override val fluid: ResourceLocation = DefaultFluids.WATER +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt index 7523b4ce2..116a8301e 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt @@ -20,6 +20,8 @@ import de.bixilon.minosoft.data.registries.ResourceLocation import de.bixilon.minosoft.data.registries.blocks.BlockState import de.bixilon.minosoft.data.registries.blocks.properties.BlockProperties import de.bixilon.minosoft.data.registries.blocks.types.FluidBlock +import de.bixilon.minosoft.data.registries.blocks.types.FluidFillable +import de.bixilon.minosoft.data.registries.fluid.DefaultFluids import de.bixilon.minosoft.data.registries.versions.Registries import de.bixilon.minosoft.data.world.Chunk import de.bixilon.minosoft.data.world.ChunkSection @@ -106,7 +108,7 @@ class WorldRenderer( offset = blockPosition.getWorldOffset(blockState.block), ) - if (blockState.properties[BlockProperties.WATERLOGGED] == true) { + if (blockState.properties[BlockProperties.WATERLOGGED] == true || (blockState.block is FluidFillable && blockState.block.fluid == DefaultFluids.WATER)) { waterBlock?.fluidRenderer?.render(context.copy(blockState = waterBlock.defaultState)) }