Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Biomes #53

Merged
merged 1 commit into from
Jul 31, 2021
Merged

Fix Biomes #53

merged 1 commit into from
Jul 31, 2021

Conversation

Owen1212055
Copy link
Collaborator

Because worlds can now have their height adjusted biomes are now able to change size. BiomeStorage.a used to be 256 as this was when biomes were 2D. However due to the biome format changing and height things this constant has changed. It represents the MAXIMUM amount of biome data that can be held... uh oh.
image

This caused biomes to use A LOT of memory because it was setting the biome data to as large as possible.

We now however use the chunk biome container constructor directly. Using a custom BiomeSource object (spigot calls it a WorldChunkManager) we simply make it always return the default value.

public ChunkBiomeContainer(IdMap<Biome> biomes, LevelHeightAccessor world, ChunkPos chunkPos, BiomeSource biomeSource, @Nullable int[] aint) {
        this(biomes, world, new Biome[(1 << ChunkBiomeContainer.WIDTH_BITS + ChunkBiomeContainer.WIDTH_BITS) * ChunkBiomeContainer.ceilDiv(world.getHeight(), 4)]);
        int i = QuartPos.fromBlock(chunkPos.getMinBlockX());
        int j = this.quartMinY;
        int k = QuartPos.fromBlock(chunkPos.getMinBlockZ());

        for (int l = 0; l < this.biomes.length; ++l) {
            if (aint != null && l < aint.length) {
                this.biomes[l] = (Biome) biomes.byId(aint[l]);
            }

            if (this.biomes[l] == null) {
                this.biomes[l] = ChunkBiomeContainer.generateBiomeForIndex(biomeSource, i, j, k, l);
            }
        }

    }

The world format should not need to be changed. As the length of biomes is stored in the world data.

@Paul19988 Paul19988 merged commit d6638e6 into Paul19988:develop Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants