structure predicate stuff + fix sunflower plains trees
This commit is contained in:
parent
cc5c3c48d5
commit
3a342bba96
@ -1 +1 @@
|
|||||||
Subproject commit 6cd959a0b0f3c5150ea70234c2c9b0a81d144d4a
|
Subproject commit a5fce368cc3baae2ccb96531b6062eee70b0da5b
|
@ -30,6 +30,7 @@ import com.terraforged.api.chunk.column.DecoratorManager;
|
|||||||
import com.terraforged.api.chunk.surface.SurfaceManager;
|
import com.terraforged.api.chunk.surface.SurfaceManager;
|
||||||
import com.terraforged.api.material.geology.GeologyManager;
|
import com.terraforged.api.material.geology.GeologyManager;
|
||||||
import com.terraforged.api.material.layer.LayerManager;
|
import com.terraforged.api.material.layer.LayerManager;
|
||||||
|
import com.terraforged.fm.structure.StructureManager;
|
||||||
import com.terraforged.world.GeneratorContext;
|
import com.terraforged.world.GeneratorContext;
|
||||||
import com.terraforged.world.terrain.provider.TerrainProvider;
|
import com.terraforged.world.terrain.provider.TerrainProvider;
|
||||||
import com.terraforged.fm.modifier.FeatureModifiers;
|
import com.terraforged.fm.modifier.FeatureModifiers;
|
||||||
@ -109,6 +110,16 @@ public abstract class SetupEvent<T> extends Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register custom FeatureModifiers
|
||||||
|
*/
|
||||||
|
public static class Structures extends SetupEvent<StructureManager> {
|
||||||
|
|
||||||
|
public Structures(StructureManager manager, GeneratorContext context) {
|
||||||
|
super(manager, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register custom Terrain Populators
|
* Register custom Terrain Populators
|
||||||
*/
|
*/
|
||||||
|
@ -33,6 +33,7 @@ import com.terraforged.core.cell.Cell;
|
|||||||
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.region.gen.RegionCache;
|
import com.terraforged.core.region.gen.RegionCache;
|
||||||
|
import com.terraforged.fm.structure.StructureManager;
|
||||||
import com.terraforged.fm.FeatureManager;
|
import com.terraforged.fm.FeatureManager;
|
||||||
import com.terraforged.material.Materials;
|
import com.terraforged.material.Materials;
|
||||||
import com.terraforged.material.geology.GeoManager;
|
import com.terraforged.material.geology.GeoManager;
|
||||||
@ -75,6 +76,7 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
|
|||||||
|
|
||||||
private final GeoManager geologyManager;
|
private final GeoManager geologyManager;
|
||||||
private final FeatureManager featureManager;
|
private final FeatureManager featureManager;
|
||||||
|
private final StructureManager structureManager;
|
||||||
private final SurfaceManager surfaceManager;
|
private final SurfaceManager surfaceManager;
|
||||||
private final BlockDataManager blockDataManager;
|
private final BlockDataManager blockDataManager;
|
||||||
private final List<ColumnDecorator> baseDecorators;
|
private final List<ColumnDecorator> baseDecorators;
|
||||||
@ -93,6 +95,7 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
|
|||||||
this.structureGenerator = new StructureGenerator(this);
|
this.structureGenerator = new StructureGenerator(this);
|
||||||
|
|
||||||
this.surfaceManager = TerraSetupFactory.createSurfaceManager(context);
|
this.surfaceManager = TerraSetupFactory.createSurfaceManager(context);
|
||||||
|
this.structureManager = TerraSetupFactory.createStructureManager(context);
|
||||||
this.geologyManager = TerraSetupFactory.createGeologyManager(context);
|
this.geologyManager = TerraSetupFactory.createGeologyManager(context);
|
||||||
this.baseDecorators = TerraSetupFactory.createBaseDecorators(geologyManager, context);
|
this.baseDecorators = TerraSetupFactory.createBaseDecorators(geologyManager, context);
|
||||||
this.postProcessors = TerraSetupFactory.createFeatureDecorators(context);
|
this.postProcessors = TerraSetupFactory.createFeatureDecorators(context);
|
||||||
@ -210,6 +213,10 @@ public class TerraChunkGenerator extends ChunkGenerator<GenerationSettings> {
|
|||||||
return featureManager;
|
return featureManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final StructureManager getStructureManager() {
|
||||||
|
return structureManager;
|
||||||
|
}
|
||||||
|
|
||||||
public final GeoManager getGeologyManager() {
|
public final GeoManager getGeologyManager() {
|
||||||
return geologyManager;
|
return geologyManager;
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@ import com.terraforged.api.chunk.column.ColumnDecorator;
|
|||||||
import com.terraforged.api.chunk.surface.SurfaceManager;
|
import com.terraforged.api.chunk.surface.SurfaceManager;
|
||||||
import com.terraforged.biome.ModBiomes;
|
import com.terraforged.biome.ModBiomes;
|
||||||
import com.terraforged.biome.surface.IcebergsSurface;
|
import com.terraforged.biome.surface.IcebergsSurface;
|
||||||
import com.terraforged.biome.surface.SteppeSurface;
|
|
||||||
import com.terraforged.biome.surface.SwampSurface;
|
import com.terraforged.biome.surface.SwampSurface;
|
||||||
import com.terraforged.decorator.feature.LayerDecorator;
|
import com.terraforged.decorator.feature.LayerDecorator;
|
||||||
import com.terraforged.decorator.feature.SnowEroder;
|
import com.terraforged.decorator.feature.SnowEroder;
|
||||||
import com.terraforged.feature.Matchers;
|
import com.terraforged.feature.Matchers;
|
||||||
|
import com.terraforged.fm.structure.StructureManager;
|
||||||
import com.terraforged.fm.FeatureManager;
|
import com.terraforged.fm.FeatureManager;
|
||||||
import com.terraforged.fm.matcher.biome.BiomeMatcher;
|
import com.terraforged.fm.matcher.biome.BiomeMatcher;
|
||||||
import com.terraforged.fm.matcher.feature.FeatureMatcher;
|
import com.terraforged.fm.matcher.feature.FeatureMatcher;
|
||||||
@ -29,6 +29,7 @@ import com.terraforged.util.setup.SetupHooks;
|
|||||||
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.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
|
import net.minecraft.world.gen.feature.structure.Structure;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -93,27 +94,27 @@ public class TerraSetupFactory {
|
|||||||
|
|
||||||
// block ugly features
|
// block ugly features
|
||||||
modifiers.getPredicates().add(Matchers.sedimentDisks(), FeaturePredicate.DENY);
|
modifiers.getPredicates().add(Matchers.sedimentDisks(), FeaturePredicate.DENY);
|
||||||
|
modifiers.getPredicates().add(FeatureMatcher.of(Feature.MINESHAFT), new MinHeight(context.levels.waterY + 20));
|
||||||
// limit to deep oceans
|
|
||||||
modifiers.getPredicates().add(FeatureMatcher.of(Feature.SHIPWRECK), MinDepth.DEPTH55);
|
|
||||||
modifiers.getPredicates().add(FeatureMatcher.of(Feature.OCEAN_RUIN), DeepWater.INSTANCE);
|
|
||||||
modifiers.getPredicates().add(FeatureMatcher.of(Feature.OCEAN_MONUMENT), DeepWater.INSTANCE);
|
|
||||||
|
|
||||||
// prevent mineshafts above ground
|
|
||||||
modifiers.getPredicates().add(FeatureMatcher.of(Feature.MINESHAFT), MinHeight.HEIGHT80);
|
|
||||||
|
|
||||||
return FeatureManager.create(context.world, SetupHooks.setup(modifiers, context.copy()));
|
return FeatureManager.create(context.world, SetupHooks.setup(modifiers, context.copy()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SurfaceManager createSurfaceManager(TerraContext context) {
|
public static SurfaceManager createSurfaceManager(TerraContext context) {
|
||||||
SurfaceManager manager = new SurfaceManager();
|
SurfaceManager manager = new SurfaceManager();
|
||||||
manager.replace(Biomes.FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 20, 15));
|
|
||||||
manager.replace(Biomes.DEEP_FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 30, 30));
|
manager.replace(Biomes.DEEP_FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 30, 30));
|
||||||
|
manager.replace(Biomes.FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 20, 15));
|
||||||
manager.replace(Biomes.SWAMP.delegate.get(), new SwampSurface());
|
manager.replace(Biomes.SWAMP.delegate.get(), new SwampSurface());
|
||||||
manager.replace(ModBiomes.MARSHLAND, new SwampSurface());
|
manager.replace(ModBiomes.MARSHLAND, new SwampSurface());
|
||||||
return SetupHooks.setup(manager, context);
|
return SetupHooks.setup(manager, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StructureManager createStructureManager(TerraContext context) {
|
||||||
|
StructureManager manager = new StructureManager();
|
||||||
|
manager.register(Structure.OCEAN_MONUMENT, DeepWater.INSTANCE);
|
||||||
|
manager.register(Structure.OCEAN_RUIN, DeepWater.INSTANCE);
|
||||||
|
return SetupHooks.setup(manager, context);
|
||||||
|
}
|
||||||
|
|
||||||
public static GeoManager createGeologyManager(TerraContext context) {
|
public static GeoManager createGeologyManager(TerraContext context) {
|
||||||
return new GeoManager(context);
|
return new GeoManager(context);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.terraforged.chunk.generator;
|
package com.terraforged.chunk.generator;
|
||||||
|
|
||||||
import com.terraforged.chunk.TerraChunkGenerator;
|
import com.terraforged.chunk.TerraChunkGenerator;
|
||||||
|
import com.terraforged.fm.predicate.FeaturePredicate;
|
||||||
import net.minecraft.network.DebugPacketSender;
|
import net.minecraft.network.DebugPacketSender;
|
||||||
import net.minecraft.util.SharedSeedRandom;
|
import net.minecraft.util.SharedSeedRandom;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -10,7 +11,6 @@ import net.minecraft.world.IWorld;
|
|||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.BiomeManager;
|
import net.minecraft.world.biome.BiomeManager;
|
||||||
import net.minecraft.world.chunk.IChunk;
|
import net.minecraft.world.chunk.IChunk;
|
||||||
import net.minecraft.world.gen.ChunkGenerator;
|
|
||||||
import net.minecraft.world.gen.feature.Feature;
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import net.minecraft.world.gen.feature.structure.Structure;
|
import net.minecraft.world.gen.feature.structure.Structure;
|
||||||
import net.minecraft.world.gen.feature.structure.StructureStart;
|
import net.minecraft.world.gen.feature.structure.StructureStart;
|
||||||
@ -31,16 +31,21 @@ public class StructureGenerator {
|
|||||||
generator.queueChunk(chunkpos.x, chunkpos.z);
|
generator.queueChunk(chunkpos.x, chunkpos.z);
|
||||||
|
|
||||||
BlockPos biomePos = new BlockPos(chunkpos.getXStart() + 9, 0, chunkpos.getZStart() + 9);
|
BlockPos biomePos = new BlockPos(chunkpos.getXStart() + 9, 0, chunkpos.getZStart() + 9);
|
||||||
|
Biome biome = biomes.getBiome(biomePos);
|
||||||
|
|
||||||
for (Structure<?> structure : Feature.STRUCTURES.values()) {
|
for (Structure<?> structure : Feature.STRUCTURES.values()) {
|
||||||
if (generator.getBiomeProvider().hasStructure(structure)) {
|
if (generator.getBiomeProvider().hasStructure(structure)) {
|
||||||
|
FeaturePredicate predicate = generator.getStructureManager().getPredicate(structure);
|
||||||
|
if (!predicate.test(chunk, biome)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
StructureStart existingStart = chunk.getStructureStart(structure.getStructureName());
|
StructureStart existingStart = chunk.getStructureStart(structure.getStructureName());
|
||||||
int refCount = existingStart != null ? existingStart.func_227457_j_() : 0;
|
int refCount = existingStart != null ? existingStart.func_227457_j_() : 0;
|
||||||
|
|
||||||
SharedSeedRandom random = new SharedSeedRandom();
|
SharedSeedRandom random = new SharedSeedRandom();
|
||||||
StructureStart start = StructureStart.DUMMY;
|
StructureStart start = StructureStart.DUMMY;
|
||||||
|
|
||||||
Biome biome = biomes.getBiome(biomePos);
|
|
||||||
if (structure.func_225558_a_(biomes, generator, random, chunkpos.x, chunkpos.z, biome)) {
|
if (structure.func_225558_a_(biomes, generator, random, chunkpos.x, chunkpos.z, biome)) {
|
||||||
StructureStart altStart = structure.getStartFactory().create(structure, chunkpos.x, chunkpos.z, MutableBoundingBox.getNewBoundingBox(), refCount, generator.getSeed());
|
StructureStart altStart = structure.getStartFactory().create(structure, chunkpos.x, chunkpos.z, MutableBoundingBox.getNewBoundingBox(), refCount, generator.getSeed());
|
||||||
altStart.init(generator, templates, chunkpos.x, chunkpos.z, biome);
|
altStart.init(generator, templates, chunkpos.x, chunkpos.z, biome);
|
||||||
|
@ -32,6 +32,7 @@ import com.terraforged.api.chunk.surface.SurfaceManager;
|
|||||||
import com.terraforged.api.event.SetupEvent;
|
import com.terraforged.api.event.SetupEvent;
|
||||||
import com.terraforged.api.material.geology.GeologyManager;
|
import com.terraforged.api.material.geology.GeologyManager;
|
||||||
import com.terraforged.api.material.layer.LayerManager;
|
import com.terraforged.api.material.layer.LayerManager;
|
||||||
|
import com.terraforged.fm.structure.StructureManager;
|
||||||
import com.terraforged.fm.modifier.FeatureModifiers;
|
import com.terraforged.fm.modifier.FeatureModifiers;
|
||||||
import com.terraforged.world.GeneratorContext;
|
import com.terraforged.world.GeneratorContext;
|
||||||
import com.terraforged.world.terrain.provider.TerrainProvider;
|
import com.terraforged.world.terrain.provider.TerrainProvider;
|
||||||
@ -71,6 +72,11 @@ public class SetupHooks {
|
|||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T extends StructureManager> T setup(T manager, GeneratorContext context) {
|
||||||
|
MinecraftForge.EVENT_BUS.post(new SetupEvent.Structures(manager, context));
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setup(List<ColumnDecorator> base, List<ColumnDecorator> feature, GeneratorContext context) {
|
public static void setup(List<ColumnDecorator> base, List<ColumnDecorator> feature, GeneratorContext context) {
|
||||||
MinecraftForge.EVENT_BUS.post(new SetupEvent.Decorators(new DecoratorManager(base, feature), context));
|
MinecraftForge.EVENT_BUS.post(new SetupEvent.Decorators(new DecoratorManager(base, feature), context));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"biomes": [
|
"biomes": [
|
||||||
|
"minecraft:river",
|
||||||
"minecraft:plains",
|
"minecraft:plains",
|
||||||
"minecraft:river"
|
"minecraft:sunflower_plains"
|
||||||
],
|
],
|
||||||
"match": [
|
"match": [
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user