Tweak biome container storage
This commit is contained in:
parent
c19bf30c91
commit
84c23dccf4
@ -31,10 +31,7 @@ import net.minecraft.entity.EntityType;
|
|||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.Biomes;
|
import net.minecraft.world.biome.Biomes;
|
||||||
import net.minecraft.world.biome.DefaultBiomeFeatures;
|
import net.minecraft.world.biome.DefaultBiomeFeatures;
|
||||||
import net.minecraft.world.biome.SwampBiome;
|
|
||||||
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
|
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 class Marshland extends BiomeVariant {
|
||||||
public Marshland() {
|
public Marshland() {
|
||||||
|
@ -38,7 +38,6 @@ import net.minecraft.world.biome.Biomes;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public abstract class AbstractBiomeMap implements BiomeMap {
|
public abstract class AbstractBiomeMap implements BiomeMap {
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ package com.terraforged.mod.biome.provider;
|
|||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.core.world.decorator.Decorator;
|
|
||||||
import com.terraforged.core.region.chunk.ChunkReader;
|
import com.terraforged.core.region.chunk.ChunkReader;
|
||||||
import com.terraforged.core.util.concurrent.ObjectPool;
|
import com.terraforged.core.util.concurrent.ObjectPool;
|
||||||
|
import com.terraforged.core.world.decorator.Decorator;
|
||||||
import com.terraforged.core.world.terrain.Terrain;
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
import com.terraforged.mod.biome.map.BiomeMap;
|
import com.terraforged.mod.biome.map.BiomeMap;
|
||||||
import com.terraforged.mod.biome.modifier.BiomeModifierManager;
|
import com.terraforged.mod.biome.modifier.BiomeModifierManager;
|
||||||
@ -139,7 +139,7 @@ public class BiomeProvider extends AbstractBiomeProvider {
|
|||||||
TerraContainer.Builder builder = TerraContainer.builder();
|
TerraContainer.Builder builder = TerraContainer.builder();
|
||||||
chunkReader.iterate((cell, dx, dz) -> {
|
chunkReader.iterate((cell, dx, dz) -> {
|
||||||
Biome biome = getBiome(cell, chunkReader.getBlockX() + dx, chunkReader.getBlockZ() + 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);
|
return builder.build(chunkReader);
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@ import com.terraforged.api.chunk.surface.SurfaceContext;
|
|||||||
import com.terraforged.api.chunk.surface.SurfaceManager;
|
import com.terraforged.api.chunk.surface.SurfaceManager;
|
||||||
import com.terraforged.api.material.layer.LayerManager;
|
import com.terraforged.api.material.layer.LayerManager;
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.core.world.decorator.Decorator;
|
|
||||||
import com.terraforged.core.region.RegionCache;
|
import com.terraforged.core.region.RegionCache;
|
||||||
import com.terraforged.core.region.RegionGenerator;
|
import com.terraforged.core.region.RegionGenerator;
|
||||||
import com.terraforged.core.region.Size;
|
import com.terraforged.core.region.Size;
|
||||||
import com.terraforged.core.region.chunk.ChunkReader;
|
import com.terraforged.core.region.chunk.ChunkReader;
|
||||||
import com.terraforged.core.util.concurrent.ThreadPool;
|
import com.terraforged.core.util.concurrent.ThreadPool;
|
||||||
|
import com.terraforged.core.world.decorator.Decorator;
|
||||||
import com.terraforged.feature.FeatureManager;
|
import com.terraforged.feature.FeatureManager;
|
||||||
import com.terraforged.feature.matcher.dynamic.DynamicMatcher;
|
import com.terraforged.feature.matcher.dynamic.DynamicMatcher;
|
||||||
import com.terraforged.feature.matcher.feature.FeatureMatcher;
|
import com.terraforged.feature.matcher.feature.FeatureMatcher;
|
||||||
|
@ -25,12 +25,10 @@
|
|||||||
|
|
||||||
package com.terraforged.mod.chunk;
|
package com.terraforged.mod.chunk;
|
||||||
|
|
||||||
import com.terraforged.api.biome.BiomeVariant;
|
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.core.region.chunk.ChunkReader;
|
import com.terraforged.core.region.chunk.ChunkReader;
|
||||||
import com.terraforged.core.util.PosIterator;
|
import com.terraforged.core.util.PosIterator;
|
||||||
import com.terraforged.core.world.terrain.Terrain;
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
import com.terraforged.mod.util.Environment;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.BiomeContainer;
|
import net.minecraft.world.biome.BiomeContainer;
|
||||||
@ -75,14 +73,6 @@ public class TerraContainer extends BiomeContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BiomeContainer bakeBiomes() {
|
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);
|
return new BiomeContainer(biomes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,19 +102,23 @@ public class TerraContainer extends BiomeContainer {
|
|||||||
private final Biome[] biomes = new Biome[SIZE];
|
private final Biome[] biomes = new Biome[SIZE];
|
||||||
private final Biome[] surfaceBiomeCache = new Biome[256];
|
private final Biome[] surfaceBiomeCache = new Biome[256];
|
||||||
|
|
||||||
public void set(int x, int y, int z, Biome biome) {
|
public void set(int x, int z, Biome biome) {
|
||||||
biomes[indexOf(x, y, z)] = biome;
|
|
||||||
|
|
||||||
surfaceBiomeCache[indexOf(x, z)] = 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) {
|
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);
|
return new TerraContainer(this, chunkReader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package com.terraforged.mod.command.task;
|
package com.terraforged.mod.command.task;
|
||||||
|
|
||||||
import com.terraforged.core.cell.Cell;
|
import com.terraforged.core.cell.Cell;
|
||||||
import com.terraforged.core.world.decorator.Decorator;
|
|
||||||
import com.terraforged.core.world.WorldGenerator;
|
import com.terraforged.core.world.WorldGenerator;
|
||||||
|
import com.terraforged.core.world.decorator.Decorator;
|
||||||
import com.terraforged.core.world.terrain.Terrain;
|
import com.terraforged.core.world.terrain.Terrain;
|
||||||
import com.terraforged.mod.biome.provider.BiomeProvider;
|
import com.terraforged.mod.biome.provider.BiomeProvider;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
Loading…
Reference in New Issue
Block a user