diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java index 8652812..a988794 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/Marshland.java @@ -31,10 +31,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraft.world.biome.DefaultBiomeFeatures; -import net.minecraft.world.biome.SwampBiome; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; public class Marshland extends BiomeVariant { public Marshland() { diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java index 234ff88..aa6bb9a 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/map/AbstractBiomeMap.java @@ -38,7 +38,6 @@ import net.minecraft.world.biome.Biomes; import java.util.Collections; import java.util.HashSet; import java.util.Set; -import java.util.function.Function; public abstract class AbstractBiomeMap implements BiomeMap { diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java index a1a0df1..2c04e10 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/biome/provider/BiomeProvider.java @@ -27,9 +27,9 @@ package com.terraforged.mod.biome.provider; import com.google.common.collect.Sets; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.decorator.Decorator; import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.util.concurrent.ObjectPool; +import com.terraforged.core.world.decorator.Decorator; import com.terraforged.core.world.terrain.Terrain; import com.terraforged.mod.biome.map.BiomeMap; import com.terraforged.mod.biome.modifier.BiomeModifierManager; @@ -139,7 +139,7 @@ public class BiomeProvider extends AbstractBiomeProvider { TerraContainer.Builder builder = TerraContainer.builder(); chunkReader.iterate((cell, dx, dz) -> { Biome biome = getBiome(cell, chunkReader.getBlockX() + dx, chunkReader.getBlockZ() + dz); - builder.fill(dx, dz, biome); + builder.set(dx, dz, biome); }); return builder.build(chunkReader); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java index c1e1a17..ed98495 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraChunkGenerator.java @@ -32,12 +32,12 @@ import com.terraforged.api.chunk.surface.SurfaceContext; import com.terraforged.api.chunk.surface.SurfaceManager; import com.terraforged.api.material.layer.LayerManager; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.decorator.Decorator; import com.terraforged.core.region.RegionCache; import com.terraforged.core.region.RegionGenerator; import com.terraforged.core.region.Size; import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.util.concurrent.ThreadPool; +import com.terraforged.core.world.decorator.Decorator; import com.terraforged.feature.FeatureManager; import com.terraforged.feature.matcher.dynamic.DynamicMatcher; import com.terraforged.feature.matcher.feature.FeatureMatcher; diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java index 65d1fe3..2528a26 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/chunk/TerraContainer.java @@ -25,12 +25,10 @@ package com.terraforged.mod.chunk; -import com.terraforged.api.biome.BiomeVariant; import com.terraforged.core.cell.Cell; import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.util.PosIterator; import com.terraforged.core.world.terrain.Terrain; -import com.terraforged.mod.util.Environment; import net.minecraft.util.math.MathHelper; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeContainer; @@ -75,14 +73,6 @@ public class TerraContainer extends BiomeContainer { } public BiomeContainer bakeBiomes() { - if (Environment.isDev()) { - for (int i = 0; i < biomes.length; i++) { - Biome biome = biomes[i]; - if (biome instanceof BiomeVariant) { - biomes[i] = ((BiomeVariant) biome).getBase(); - } - } - } return new BiomeContainer(biomes); } @@ -112,19 +102,23 @@ public class TerraContainer extends BiomeContainer { private final Biome[] biomes = new Biome[SIZE]; private final Biome[] surfaceBiomeCache = new Biome[256]; - public void set(int x, int y, int z, Biome biome) { - biomes[indexOf(x, y, z)] = biome; - + public void set(int x, int z, Biome biome) { surfaceBiomeCache[indexOf(x, z)] = biome; } - public void fill(int x, int z, Biome biome) { - for (int y = 0; y < 256; y += 4) { - set(x, y, z, biome); - } - } - public TerraContainer build(ChunkReader chunkReader) { + // biome storage format is 1 biome pos == 4x4x4 blocks, stored in an 4x64x4 (xyz) array + // sample the 1:1 surfaceBiomeCache every 4 blocks with a 2 block offset (roughly center of the 4x4 area) + for (int dy = 0; dy < 64; dy++) { + for (int dz = 0; dz < 4; dz++) { + for (int dx = 0; dx < 4; dx++) { + int x = 2 + (dx * 4); + int z = 2 + (dz * 4); + int index = indexOf(dx, dy, dz); + biomes[index] = surfaceBiomeCache[indexOf(x, z)]; + } + } + } return new TerraContainer(this, chunkReader); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/command/task/FindBiomeTask.java b/TerraForgedMod/src/main/java/com/terraforged/mod/command/task/FindBiomeTask.java index 8124af6..63b7e07 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/command/task/FindBiomeTask.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/command/task/FindBiomeTask.java @@ -26,8 +26,8 @@ package com.terraforged.mod.command.task; import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.decorator.Decorator; import com.terraforged.core.world.WorldGenerator; +import com.terraforged.core.world.decorator.Decorator; import com.terraforged.core.world.terrain.Terrain; import com.terraforged.mod.biome.provider.BiomeProvider; import net.minecraft.util.math.BlockPos;