blocks: set cave_air and void_air to null too

This commit is contained in:
Bixilon 2022-09-26 21:20:04 +02:00
parent be8319d962
commit 39d952a6d5
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 39 additions and 2 deletions

View File

@ -125,7 +125,9 @@ data class BlockState(
val outlineShape = data["outline_shape"]?.asShape() ?: VoxelShape.EMPTY
val lightProperties = if (outlineShape == VoxelShape.FULL) {
val lightProperties = if (outlineShape == VoxelShape.EMPTY) {
TransparentProperty
} else if (outlineShape == VoxelShape.FULL) {
if (data["is_opaque"]?.toBoolean() != false) SolidProperty else TransparentProperty
} else {
DirectedProperty.of(outlineShape)

View File

@ -49,6 +49,7 @@ import de.bixilon.minosoft.data.registries.blocks.types.water.SeagrassBlock
import de.bixilon.minosoft.data.registries.factory.clazz.DefaultClassFactory
object DefaultBlockFactories : DefaultClassFactory<BlockFactory<*>>(
AirBlock,
FluidBlock,
DoorBlock,
LeverBlock,

View File

@ -0,0 +1,29 @@
/*
* Minosoft
* Copyright (C) 2020-2022 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
import de.bixilon.minosoft.data.registries.blocks.BlockFactory
import de.bixilon.minosoft.data.registries.registries.Registries
@Deprecated("Air is always null!")
open class AirBlock(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>) : Block(resourceLocation, registries, data) {
companion object : BlockFactory<AirBlock> {
override fun build(resourceLocation: ResourceLocation, registries: Registries, data: Map<String, Any>): AirBlock {
return AirBlock(resourceLocation, registries, data)
}
}
}

View File

@ -17,6 +17,7 @@ import de.bixilon.kutil.exception.Broken
import de.bixilon.kutil.json.JsonObject
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.registries.blocks.BlockState
import de.bixilon.minosoft.data.registries.blocks.types.AirBlock
import de.bixilon.minosoft.data.registries.registries.Registries
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
@ -72,7 +73,11 @@ class BlockStateRegistry(var flattened: Boolean) : AbstractRegistry<BlockState?>
if (id == ProtocolDefinition.AIR_BLOCK_ID) {
return null
}
return forceGet(id)
val state = forceGet(id) ?: return null
if (state.block is AirBlock) {
return null
}
return state
}
override fun getId(value: BlockState?): Int {