mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
SkyProperties
This commit is contained in:
parent
05ff4647a2
commit
f1a87aac25
@ -19,7 +19,11 @@ import de.bixilon.kutil.primitive.BooleanUtil.toBoolean
|
|||||||
import de.bixilon.kutil.primitive.FloatUtil.toFloat
|
import de.bixilon.kutil.primitive.FloatUtil.toFloat
|
||||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.gui.rendering.sky.properties.DefaultSkyProperties
|
||||||
|
import de.bixilon.minosoft.gui.rendering.sky.properties.OverworldSkyProperties
|
||||||
|
import de.bixilon.minosoft.gui.rendering.sky.properties.SkyProperties
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.get
|
import de.bixilon.minosoft.util.nbt.tag.NBTUtil.get
|
||||||
|
|
||||||
data class DimensionProperties(
|
data class DimensionProperties(
|
||||||
@ -30,7 +34,7 @@ data class DimensionProperties(
|
|||||||
val respawnAnchorWorks: Boolean = false,
|
val respawnAnchorWorks: Boolean = false,
|
||||||
val hasSkyLight: Boolean = true,
|
val hasSkyLight: Boolean = true,
|
||||||
val bedWorks: Boolean = true,
|
val bedWorks: Boolean = true,
|
||||||
val skyProperties: ResourceLocation = ResourceLocation("overworld"),
|
val skyProperties: SkyProperties = OverworldSkyProperties,
|
||||||
val hasRaids: Boolean = true,
|
val hasRaids: Boolean = true,
|
||||||
val logicalHeight: Int = DEFAULT_HEIGHT,
|
val logicalHeight: Int = DEFAULT_HEIGHT,
|
||||||
val coordinateScale: Double = 0.0,
|
val coordinateScale: Double = 0.0,
|
||||||
@ -79,7 +83,7 @@ data class DimensionProperties(
|
|||||||
respawnAnchorWorks = data["respawn_anchor_works"]?.toBoolean() ?: false,
|
respawnAnchorWorks = data["respawn_anchor_works"]?.toBoolean() ?: false,
|
||||||
hasSkyLight = data["has_skylight", "has_sky_light"]?.toBoolean() ?: false,
|
hasSkyLight = data["has_skylight", "has_sky_light"]?.toBoolean() ?: false,
|
||||||
bedWorks = data["bed_works"]?.toBoolean() ?: false,
|
bedWorks = data["bed_works"]?.toBoolean() ?: false,
|
||||||
skyProperties = ResourceLocation(data["effects"].nullCast<String>() ?: "overworld"),
|
skyProperties = data["effects"].nullCast<String>()?.let { DefaultSkyProperties[it.toResourceLocation()] } ?: OverworldSkyProperties,
|
||||||
hasRaids = data["has_raids"]?.toBoolean() ?: false,
|
hasRaids = data["has_raids"]?.toBoolean() ?: false,
|
||||||
logicalHeight = data["logical_height"]?.toInt() ?: DEFAULT_MAX_Y,
|
logicalHeight = data["logical_height"]?.toInt() ?: DEFAULT_MAX_Y,
|
||||||
coordinateScale = data["coordinate_scale"].nullCast() ?: 0.0,
|
coordinateScale = data["coordinate_scale"].nullCast() ?: 0.0,
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui.rendering.sky.properties
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.util.ResourceLocationMap
|
||||||
|
|
||||||
|
object DefaultSkyProperties : ResourceLocationMap<SkyProperties>(
|
||||||
|
OverworldSkyProperties,
|
||||||
|
NetherSkyProperties,
|
||||||
|
EndSkyProperties,
|
||||||
|
)
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui.rendering.sky.properties
|
||||||
|
|
||||||
|
import de.bixilon.kutil.exception.Broken
|
||||||
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.minecraft
|
||||||
|
|
||||||
|
object EndSkyProperties : SkyProperties {
|
||||||
|
override val resourceLocation = minecraft("the_end")
|
||||||
|
|
||||||
|
override val daylightCycle: Boolean get() = false
|
||||||
|
override val fixedTexture: ResourceLocation = minecraft("environment/end_sky").texture()
|
||||||
|
|
||||||
|
override val sun: Boolean get() = false
|
||||||
|
override val moon: Boolean get() = false
|
||||||
|
override val stars: Boolean get() = false
|
||||||
|
|
||||||
|
override val clouds: Boolean get() = false
|
||||||
|
override fun getCloudHeight(connection: PlayConnection): IntRange = Broken()
|
||||||
|
|
||||||
|
override val fullbright: Boolean get() = true
|
||||||
|
|
||||||
|
override val fog: Boolean get() = false
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui.rendering.sky.properties
|
||||||
|
|
||||||
|
import de.bixilon.kutil.exception.Broken
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.minecraft
|
||||||
|
|
||||||
|
object NetherSkyProperties : SkyProperties {
|
||||||
|
override val resourceLocation = minecraft("the_nether")
|
||||||
|
|
||||||
|
override val daylightCycle: Boolean get() = false
|
||||||
|
|
||||||
|
override val sun: Boolean get() = false
|
||||||
|
override val moon: Boolean get() = false
|
||||||
|
override val stars: Boolean get() = false
|
||||||
|
|
||||||
|
override val clouds: Boolean get() = false
|
||||||
|
override fun getCloudHeight(connection: PlayConnection): IntRange = Broken()
|
||||||
|
|
||||||
|
override val fullbright: Boolean get() = true
|
||||||
|
|
||||||
|
override val fog: Boolean get() = true
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui.rendering.sky.properties
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.registries.dimension.DimensionProperties
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.minecraft
|
||||||
|
|
||||||
|
object OverworldSkyProperties : SkyProperties {
|
||||||
|
override val resourceLocation = minecraft("overworld")
|
||||||
|
|
||||||
|
override val daylightCycle: Boolean get() = true
|
||||||
|
|
||||||
|
override val sun: Boolean get() = true
|
||||||
|
override val moon: Boolean get() = true
|
||||||
|
override val stars: Boolean get() = true
|
||||||
|
|
||||||
|
override val clouds: Boolean get() = true
|
||||||
|
override fun getCloudHeight(connection: PlayConnection): IntRange {
|
||||||
|
val height = connection.world.dimension?.dataHeight ?: DimensionProperties.DEFAULT_HEIGHT
|
||||||
|
if (height > DimensionProperties.DEFAULT_HEIGHT) {
|
||||||
|
return 192..196
|
||||||
|
}
|
||||||
|
return 128..132
|
||||||
|
}
|
||||||
|
|
||||||
|
override val fullbright: Boolean get() = false
|
||||||
|
|
||||||
|
override val fog: Boolean get() = true
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui.rendering.sky.properties
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.registries.ResourceLocationAble
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
|
||||||
|
interface SkyProperties : ResourceLocationAble {
|
||||||
|
val daylightCycle: Boolean
|
||||||
|
val fixedTexture: ResourceLocation? get() = null
|
||||||
|
|
||||||
|
val sun: Boolean
|
||||||
|
val moon: Boolean
|
||||||
|
val stars: Boolean
|
||||||
|
|
||||||
|
val clouds: Boolean
|
||||||
|
fun getCloudHeight(connection: PlayConnection): IntRange
|
||||||
|
|
||||||
|
val fullbright: Boolean get() = false
|
||||||
|
|
||||||
|
val fog: Boolean
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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.util
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.registries.MultiResourceLocationAble
|
||||||
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.registries.ResourceLocationAble
|
||||||
|
|
||||||
|
open class ResourceLocationMap<T : ResourceLocationAble>(vararg entries: T) : Iterable<T> {
|
||||||
|
private val entries: MutableMap<ResourceLocation, T> = mutableMapOf()
|
||||||
|
|
||||||
|
init {
|
||||||
|
for (factory in entries) {
|
||||||
|
this.entries[factory.resourceLocation] = factory
|
||||||
|
if (factory is MultiResourceLocationAble) {
|
||||||
|
for (resourceLocation in factory.ALIASES) {
|
||||||
|
this.entries[resourceLocation] = factory
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun get(resourceLocation: ResourceLocation): T? {
|
||||||
|
return this.entries[resourceLocation]
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun iterator(): Iterator<T> {
|
||||||
|
return this.entries.values.iterator()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user