Fix for BiomeProvider assuming coords passed into getNoiseBiome are block coords
This commit is contained in:
parent
84c23dccf4
commit
8eca5b6974
@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
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.ColumnFuzzedBiomeMagnifier;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -42,11 +43,6 @@ public abstract class AbstractBiomeProvider extends net.minecraft.world.biome.pr
|
|||||||
super(defaultBiomes);
|
super(defaultBiomes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Biome getNoiseBiome(int x, int y, int z) {
|
|
||||||
return getBiome(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Set<Biome> func_225530_a_(int x, int y, int z, int size) {
|
public final Set<Biome> func_225530_a_(int x, int y, int z, int size) {
|
||||||
return getBiomesInSquare(x, y, z, size);
|
return getBiomesInSquare(x, y, z, size);
|
||||||
@ -57,8 +53,6 @@ public abstract class AbstractBiomeProvider extends net.minecraft.world.biome.pr
|
|||||||
return findBiomePosition(centerX, centerY, centerZ, range, biomes, random);
|
return findBiomePosition(centerX, centerY, centerZ, range, biomes, random);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Biome getBiome(int x, int y, int z);
|
|
||||||
|
|
||||||
public abstract Set<Biome> getBiomesInSquare(int x, int y, int z, int size);
|
public abstract Set<Biome> getBiomesInSquare(int x, int y, int z, int size);
|
||||||
|
|
||||||
public abstract BlockPos findBiomePosition(int centerX, int centerY, int centerZ, int range, List<Biome> biomes, Random random);
|
public abstract BlockPos findBiomePosition(int centerX, int centerY, int centerZ, int range, List<Biome> biomes, Random random);
|
||||||
|
@ -28,7 +28,6 @@ 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.region.chunk.ChunkReader;
|
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.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;
|
||||||
@ -63,11 +62,13 @@ public class BiomeProvider extends AbstractBiomeProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Biome getBiome(int x, int y, int z) {
|
public Biome getNoiseBiome(int x, int y, int z) {
|
||||||
try (ObjectPool.Item<Cell<Terrain>> item = Cell.pooled()) {
|
// I don't know why +24, just seems to provide slightly more accurate results
|
||||||
context.heightmap.apply(item.getValue(), x, z);
|
x = (x << 2) + 24;
|
||||||
return getBiome(item.getValue(), x, z);
|
z = (z << 2) + 24;
|
||||||
}
|
Cell<Terrain> cell = new Cell<>();
|
||||||
|
context.heightmap.apply(cell, x, z);
|
||||||
|
return getBiome(cell, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +49,6 @@ import com.terraforged.feature.predicate.MinHeight;
|
|||||||
import com.terraforged.feature.template.type.FeatureTypes;
|
import com.terraforged.feature.template.type.FeatureTypes;
|
||||||
import com.terraforged.mod.Log;
|
import com.terraforged.mod.Log;
|
||||||
import com.terraforged.mod.biome.provider.BiomeProvider;
|
import com.terraforged.mod.biome.provider.BiomeProvider;
|
||||||
import com.terraforged.mod.biome.provider.TerraBiomeManager;
|
|
||||||
import com.terraforged.mod.chunk.fix.ChunkCarverFix;
|
import com.terraforged.mod.chunk.fix.ChunkCarverFix;
|
||||||
import com.terraforged.mod.chunk.fix.RegionFix;
|
import com.terraforged.mod.chunk.fix.RegionFix;
|
||||||
import com.terraforged.mod.decorator.ChunkPopulator;
|
import com.terraforged.mod.decorator.ChunkPopulator;
|
||||||
@ -92,7 +91,6 @@ public class TerraChunkGenerator extends ObfHelperChunkGenerator<GenerationSetti
|
|||||||
private final BiomeProvider biomeProvider;
|
private final BiomeProvider biomeProvider;
|
||||||
private final TerrainHelper terrainHelper;
|
private final TerrainHelper terrainHelper;
|
||||||
|
|
||||||
private final BiomeManager biomeManager;
|
|
||||||
private final GeoManager geologyManager;
|
private final GeoManager geologyManager;
|
||||||
private final FeatureManager featureManager;
|
private final FeatureManager featureManager;
|
||||||
private final SurfaceManager surfaceManager;
|
private final SurfaceManager surfaceManager;
|
||||||
@ -110,7 +108,6 @@ public class TerraChunkGenerator extends ObfHelperChunkGenerator<GenerationSetti
|
|||||||
this.baseDecorators = createBaseDecorators(context);
|
this.baseDecorators = createBaseDecorators(context);
|
||||||
this.postProcessors = createFeatureDecorators(context);
|
this.postProcessors = createFeatureDecorators(context);
|
||||||
this.terrainHelper = new TerrainHelper((int) world.getSeed(), 0.8F);
|
this.terrainHelper = new TerrainHelper((int) world.getSeed(), 0.8F);
|
||||||
this.biomeManager = new TerraBiomeManager(biomeProvider, context.world.getSeed());
|
|
||||||
this.featureManager = createFeatureManager(context);
|
this.featureManager = createFeatureManager(context);
|
||||||
this.regionCache = createRegionCache(context);
|
this.regionCache = createRegionCache(context);
|
||||||
SetupHooks.setup(getLayerManager(), context.copy());
|
SetupHooks.setup(getLayerManager(), context.copy());
|
||||||
@ -119,7 +116,7 @@ public class TerraChunkGenerator extends ObfHelperChunkGenerator<GenerationSetti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStructures(BiomeManager unused, IChunk chunk, ChunkGenerator<?> generator, TemplateManager templates) {
|
public void generateStructures(BiomeManager unused, IChunk chunk, ChunkGenerator<?> generator, TemplateManager templates) {
|
||||||
super.generateStructures(biomeManager, chunk, this, templates);
|
super.generateStructures(unused, chunk, this, templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -188,7 +185,7 @@ public class TerraChunkGenerator extends ObfHelperChunkGenerator<GenerationSetti
|
|||||||
public final void func_225550_a_(BiomeManager biomeManager, IChunk chunk, GenerationStage.Carving carving) {
|
public final void func_225550_a_(BiomeManager biomeManager, IChunk chunk, GenerationStage.Carving carving) {
|
||||||
// World carvers have hardcoded 'carvable' blocks which can be problematic with modded blocks
|
// World carvers have hardcoded 'carvable' blocks which can be problematic with modded blocks
|
||||||
// AirCarverFix shims the actual blockstates to an equivalent carvable type
|
// AirCarverFix shims the actual blockstates to an equivalent carvable type
|
||||||
super.func_225550_a_(this.biomeManager, new ChunkCarverFix(chunk, context.materials), carving);
|
super.func_225550_a_(biomeManager, new ChunkCarverFix(chunk, context.materials), carving);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -200,7 +197,7 @@ public class TerraChunkGenerator extends ObfHelperChunkGenerator<GenerationSetti
|
|||||||
Biome biome = container.getFeatureBiome();
|
Biome biome = container.getFeatureBiome();
|
||||||
DecoratorContext context = getContext().decorator(chunk);
|
DecoratorContext context = getContext().decorator(chunk);
|
||||||
|
|
||||||
IWorld regionFix = new RegionFix(region, container, this, biomeManager);
|
IWorld regionFix = new RegionFix(region, this);
|
||||||
BlockPos pos = new BlockPos(context.blockX, 0, context.blockZ);
|
BlockPos pos = new BlockPos(context.blockX, 0, context.blockZ);
|
||||||
|
|
||||||
// place biome features
|
// place biome features
|
||||||
|
@ -25,31 +25,17 @@
|
|||||||
|
|
||||||
package com.terraforged.mod.chunk.fix;
|
package com.terraforged.mod.chunk.fix;
|
||||||
|
|
||||||
import com.terraforged.mod.chunk.TerraContainer;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.biome.Biome;
|
|
||||||
import net.minecraft.world.biome.BiomeContainer;
|
|
||||||
import net.minecraft.world.biome.BiomeManager;
|
|
||||||
import net.minecraft.world.chunk.ChunkStatus;
|
|
||||||
import net.minecraft.world.chunk.IChunk;
|
|
||||||
import net.minecraft.world.gen.ChunkGenerator;
|
import net.minecraft.world.gen.ChunkGenerator;
|
||||||
import net.minecraft.world.gen.WorldGenRegion;
|
import net.minecraft.world.gen.WorldGenRegion;
|
||||||
|
|
||||||
// fixes hard-coded water and world height values
|
// fixes hard-coded water and world height values
|
||||||
// overrides biome methods to use TerraForged's provider/manager
|
|
||||||
public class RegionFix extends RegionDelegate {
|
public class RegionFix extends RegionDelegate {
|
||||||
|
|
||||||
private final WorldGenRegion region;
|
|
||||||
private final TerraContainer container;
|
|
||||||
private final BiomeManager biomeManager;
|
|
||||||
private final ChunkGenerator<?> generator;
|
private final ChunkGenerator<?> generator;
|
||||||
|
|
||||||
public RegionFix(WorldGenRegion region, TerraContainer container, ChunkGenerator<?> generator, BiomeManager biomeManager) {
|
public RegionFix(WorldGenRegion region, ChunkGenerator<?> generator) {
|
||||||
super(region.getWorld(), region);
|
super(region.getWorld(), region);
|
||||||
this.region = region;
|
|
||||||
this.container = container;
|
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
this.biomeManager = biomeManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,50 +47,4 @@ public class RegionFix extends RegionDelegate {
|
|||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
return generator.getMaxHeight();
|
return generator.getMaxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiomeManager func_225523_d_() {
|
|
||||||
return biomeManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Biome getNoiseBiome(int x, int y, int z) {
|
|
||||||
return getBiome(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Biome getNoiseBiomeRaw(int x, int y, int z) {
|
|
||||||
return getBiome(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Biome getBiome(BlockPos pos) {
|
|
||||||
return getBiome(pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Biome getBiome(int x, int y, int z) {
|
|
||||||
int chunkX = x >> 4;
|
|
||||||
int chunkZ = z >> 4;
|
|
||||||
if (chunkX == region.getMainChunkX() && chunkZ == region.getMainChunkZ()) {
|
|
||||||
return container.getBiome(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
TerraContainer container = getBiomes(chunkX, chunkZ);
|
|
||||||
if (container == null) {
|
|
||||||
return generator.getBiomeProvider().getNoiseBiome(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
return container.getBiome(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TerraContainer getBiomes(int chunkX, int chunkZ) {
|
|
||||||
IChunk chunk = getChunk(chunkX, chunkZ, ChunkStatus.BIOMES, false);
|
|
||||||
if (chunk != null) {
|
|
||||||
BiomeContainer container = chunk.getBiomes();
|
|
||||||
if (container instanceof TerraContainer) {
|
|
||||||
return (TerraContainer) container;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user