mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -04:00
fix wrong noise biome height cache corruption
BiomeSectionDataProvider was accessed with the in section height, that is not the height we want to use for the biome noise
This commit is contained in:
parent
e5c2d79f17
commit
580258943b
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
* Copyright (C) 2020-2024 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.
|
||||
*
|
||||
@ -23,7 +23,6 @@ import de.bixilon.minosoft.data.world.biome.accessor.noise.NoiseBiomeAccessor
|
||||
import de.bixilon.minosoft.data.world.biome.accessor.noise.VoronoiBiomeAccessor
|
||||
import de.bixilon.minosoft.data.world.chunk.chunk.Chunk
|
||||
import de.bixilon.minosoft.data.world.positions.BlockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.inSectionHeight
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.sectionHeight
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_19W36A
|
||||
|
||||
@ -46,7 +45,7 @@ class WorldBiomes(val world: World) : BiomeAccessor {
|
||||
|
||||
fun getBiome(x: Int, y: Int, z: Int, chunk: Chunk): Biome? {
|
||||
val noise = this.noise ?: return chunk.biomeSource.get(x, y, z)
|
||||
chunk[y.sectionHeight]?.let { return it.biomes[x, y.inSectionHeight, z] } // access cache
|
||||
chunk[y.sectionHeight]?.let { return it.biomes[x, y, z] } // access cache
|
||||
|
||||
return noise.get(x, y, z, chunk)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
* Copyright (C) 2020-2024 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.
|
||||
*
|
||||
@ -17,12 +17,14 @@ import de.bixilon.kutil.concurrent.lock.Lock
|
||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||
import de.bixilon.minosoft.data.world.chunk.ChunkSection
|
||||
import de.bixilon.minosoft.data.world.container.SectionDataProvider
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.inSectionHeight
|
||||
|
||||
class BiomeSectionDataProvider(
|
||||
lock: Lock? = null,
|
||||
val section: ChunkSection,
|
||||
) : SectionDataProvider<Biome?>(lock, false) {
|
||||
|
||||
@Deprecated("Wrong y coordinate for biomes")
|
||||
override fun get(index: Int): Biome? {
|
||||
var biome = super.get(index)
|
||||
if (biome != null) return biome
|
||||
@ -32,10 +34,11 @@ class BiomeSectionDataProvider(
|
||||
}
|
||||
|
||||
override fun get(x: Int, y: Int, z: Int): Biome? {
|
||||
var biome = super.get(x, y, z)
|
||||
val inSectionY = y.inSectionHeight
|
||||
var biome = super.get(x, inSectionY, z)
|
||||
if (biome != null) return biome
|
||||
biome = section.chunk.world.biomes.noise?.get(x, y, z, section.chunk)
|
||||
unsafeSet(x, y, z, biome)
|
||||
unsafeSet(x, inSectionY, z, biome)
|
||||
return biome
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user