wip: blocks with force waterloggeed properties (e.g. kelp)

This commit is contained in:
Bixilon 2021-06-19 19:56:09 +02:00
parent c00dbb101b
commit 9e3d3a409f
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 47 additions and 1 deletions

View File

@ -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 {

View File

@ -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 <https://www.gnu.org/licenses/>.
*
* 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
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*
* 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
}

View File

@ -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))
}