mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 09:26:11 -04:00
fix default dimension height, test equality of dimension deserialization and default constructor
This fixes some chunk bugs in < 1.15 if the top section was set
This commit is contained in:
parent
8ed82ef3be
commit
4b718d6c5f
@ -33,4 +33,8 @@ class AmbientLight(val base: Float = 0.0f) {
|
||||
override fun toString(): String {
|
||||
return base.toString()
|
||||
}
|
||||
|
||||
companion object {
|
||||
val DEFAULT = AmbientLight()
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import de.bixilon.minosoft.util.nbt.tag.NBTUtil.get
|
||||
data class DimensionProperties(
|
||||
// val piglinSafe: Boolean = false,
|
||||
// val natural: Boolean = true,
|
||||
val ambientLight: AmbientLight = AmbientLight(),
|
||||
val ambientLight: AmbientLight = AmbientLight.DEFAULT,
|
||||
// val respawnAnchorWorks: Boolean = false,
|
||||
val light: Boolean = true,
|
||||
val skyLight: Boolean = true,
|
||||
@ -59,16 +59,15 @@ data class DimensionProperties(
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_HEIGHT = 256
|
||||
const val DEFAULT_MAX_Y = DEFAULT_HEIGHT - 1
|
||||
|
||||
fun deserialize(identifier: ResourceLocation? = null, data: Map<String, Any>): DimensionProperties {
|
||||
return DimensionProperties(
|
||||
//piglinSafe = data["piglin_safe"]?.toBoolean() ?: false,
|
||||
//natural = data["natural"]?.toBoolean() ?: false,
|
||||
ambientLight = AmbientLight(data["ambient_light"]?.toFloat() ?: 0.0f),
|
||||
ambientLight = data["ambient_light"]?.toFloat()?.let { AmbientLight(it) } ?: AmbientLight.DEFAULT,
|
||||
//infiniBurn = ResourceLocation(data["infiniburn"].nullCast<String>() ?: "infiniburn_overworld"),
|
||||
//respawnAnchorWorks = data["respawn_anchor_works"]?.toBoolean() ?: false,
|
||||
skyLight = data["has_skylight", "has_sky_light"]?.toBoolean() ?: false,
|
||||
skyLight = data["has_skylight", "has_sky_light"]?.toBoolean() ?: true,
|
||||
//bedWorks = data["bed_works"]?.toBoolean() ?: false,
|
||||
effects = data["effects"].nullCast<String>()?.let { DefaultDimensionEffects[it.toResourceLocation()] } ?: identifier?.let { DefaultDimensionEffects[it] } ?: OverworldEffects,
|
||||
//hasRaids = data["has_raids"]?.toBoolean() ?: false,
|
||||
@ -77,7 +76,7 @@ data class DimensionProperties(
|
||||
minY = data["min_y"]?.toInt() ?: 0,
|
||||
//hasCeiling = data["has_ceiling"]?.toBoolean() ?: false,
|
||||
ultraWarm = data["ultrawarm"]?.toBoolean() ?: false,
|
||||
height = data["height"]?.toInt() ?: DEFAULT_MAX_Y,
|
||||
height = data["height"]?.toInt() ?: DEFAULT_HEIGHT,
|
||||
supports3DBiomes = data["supports_3d_biomes"]?.toBoolean() ?: true,
|
||||
)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* 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.
|
||||
*
|
||||
@ -38,4 +38,19 @@ class DimensionPropertiesTest {
|
||||
assertEquals(0, properties.maxSection)
|
||||
assertEquals(15, properties.maxY)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `legacy dimension`() {
|
||||
val properties = DimensionProperties()
|
||||
assertEquals(16, properties.sections)
|
||||
assertEquals(0, properties.minSection)
|
||||
assertEquals(15, properties.maxSection)
|
||||
assertEquals(255, properties.maxY)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `default of deserialization`() {
|
||||
val properties = DimensionProperties.deserialize(null, emptyMap())
|
||||
assertEquals(properties, DimensionProperties())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user