diff --git a/FeatureManager b/FeatureManager index 6cd959a..a5fce36 160000 --- a/FeatureManager +++ b/FeatureManager @@ -1 +1 @@ -Subproject commit 6cd959a0b0f3c5150ea70234c2c9b0a81d144d4a +Subproject commit a5fce368cc3baae2ccb96531b6062eee70b0da5b diff --git a/src/main/java/com/terraforged/api/event/SetupEvent.java b/src/main/java/com/terraforged/api/event/SetupEvent.java index d161252..c69ae7a 100644 --- a/src/main/java/com/terraforged/api/event/SetupEvent.java +++ b/src/main/java/com/terraforged/api/event/SetupEvent.java @@ -30,6 +30,7 @@ import com.terraforged.api.chunk.column.DecoratorManager; import com.terraforged.api.chunk.surface.SurfaceManager; import com.terraforged.api.material.geology.GeologyManager; import com.terraforged.api.material.layer.LayerManager; +import com.terraforged.fm.structure.StructureManager; import com.terraforged.world.GeneratorContext; import com.terraforged.world.terrain.provider.TerrainProvider; import com.terraforged.fm.modifier.FeatureModifiers; @@ -109,6 +110,16 @@ public abstract class SetupEvent extends Event { } } + /** + * Register custom FeatureModifiers + */ + public static class Structures extends SetupEvent { + + public Structures(StructureManager manager, GeneratorContext context) { + super(manager, context); + } + } + /** * Register custom Terrain Populators */ diff --git a/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java b/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java index 5b71e90..1c42fe1 100644 --- a/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java +++ b/src/main/java/com/terraforged/chunk/TerraChunkGenerator.java @@ -33,6 +33,7 @@ import com.terraforged.core.cell.Cell; import com.terraforged.core.region.Size; import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.region.gen.RegionCache; +import com.terraforged.fm.structure.StructureManager; import com.terraforged.fm.FeatureManager; import com.terraforged.material.Materials; import com.terraforged.material.geology.GeoManager; @@ -75,6 +76,7 @@ public class TerraChunkGenerator extends ChunkGenerator { private final GeoManager geologyManager; private final FeatureManager featureManager; + private final StructureManager structureManager; private final SurfaceManager surfaceManager; private final BlockDataManager blockDataManager; private final List baseDecorators; @@ -93,6 +95,7 @@ public class TerraChunkGenerator extends ChunkGenerator { this.structureGenerator = new StructureGenerator(this); this.surfaceManager = TerraSetupFactory.createSurfaceManager(context); + this.structureManager = TerraSetupFactory.createStructureManager(context); this.geologyManager = TerraSetupFactory.createGeologyManager(context); this.baseDecorators = TerraSetupFactory.createBaseDecorators(geologyManager, context); this.postProcessors = TerraSetupFactory.createFeatureDecorators(context); @@ -210,6 +213,10 @@ public class TerraChunkGenerator extends ChunkGenerator { return featureManager; } + public final StructureManager getStructureManager() { + return structureManager; + } + public final GeoManager getGeologyManager() { return geologyManager; } diff --git a/src/main/java/com/terraforged/chunk/TerraSetupFactory.java b/src/main/java/com/terraforged/chunk/TerraSetupFactory.java index 4dc75c2..a5617f8 100644 --- a/src/main/java/com/terraforged/chunk/TerraSetupFactory.java +++ b/src/main/java/com/terraforged/chunk/TerraSetupFactory.java @@ -4,11 +4,11 @@ import com.terraforged.api.chunk.column.ColumnDecorator; import com.terraforged.api.chunk.surface.SurfaceManager; import com.terraforged.biome.ModBiomes; import com.terraforged.biome.surface.IcebergsSurface; -import com.terraforged.biome.surface.SteppeSurface; import com.terraforged.biome.surface.SwampSurface; import com.terraforged.decorator.feature.LayerDecorator; import com.terraforged.decorator.feature.SnowEroder; import com.terraforged.feature.Matchers; +import com.terraforged.fm.structure.StructureManager; import com.terraforged.fm.FeatureManager; import com.terraforged.fm.matcher.biome.BiomeMatcher; 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.Biomes; import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.structure.Structure; import java.io.File; import java.util.ArrayList; @@ -93,27 +94,27 @@ public class TerraSetupFactory { // block ugly features modifiers.getPredicates().add(Matchers.sedimentDisks(), FeaturePredicate.DENY); - - // 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); + modifiers.getPredicates().add(FeatureMatcher.of(Feature.MINESHAFT), new MinHeight(context.levels.waterY + 20)); return FeatureManager.create(context.world, SetupHooks.setup(modifiers, context.copy())); } public static SurfaceManager createSurfaceManager(TerraContext context) { 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.FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 20, 15)); manager.replace(Biomes.SWAMP.delegate.get(), new SwampSurface()); manager.replace(ModBiomes.MARSHLAND, new SwampSurface()); 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) { return new GeoManager(context); } diff --git a/src/main/java/com/terraforged/chunk/generator/StructureGenerator.java b/src/main/java/com/terraforged/chunk/generator/StructureGenerator.java index 78dae74..fe2a12b 100644 --- a/src/main/java/com/terraforged/chunk/generator/StructureGenerator.java +++ b/src/main/java/com/terraforged/chunk/generator/StructureGenerator.java @@ -1,6 +1,7 @@ package com.terraforged.chunk.generator; import com.terraforged.chunk.TerraChunkGenerator; +import com.terraforged.fm.predicate.FeaturePredicate; import net.minecraft.network.DebugPacketSender; import net.minecraft.util.SharedSeedRandom; 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.BiomeManager; 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.structure.Structure; import net.minecraft.world.gen.feature.structure.StructureStart; @@ -31,16 +31,21 @@ public class StructureGenerator { generator.queueChunk(chunkpos.x, chunkpos.z); BlockPos biomePos = new BlockPos(chunkpos.getXStart() + 9, 0, chunkpos.getZStart() + 9); + Biome biome = biomes.getBiome(biomePos); for (Structure structure : Feature.STRUCTURES.values()) { if (generator.getBiomeProvider().hasStructure(structure)) { + FeaturePredicate predicate = generator.getStructureManager().getPredicate(structure); + if (!predicate.test(chunk, biome)) { + continue; + } + StructureStart existingStart = chunk.getStructureStart(structure.getStructureName()); int refCount = existingStart != null ? existingStart.func_227457_j_() : 0; SharedSeedRandom random = new SharedSeedRandom(); StructureStart start = StructureStart.DUMMY; - Biome biome = biomes.getBiome(biomePos); 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()); altStart.init(generator, templates, chunkpos.x, chunkpos.z, biome); diff --git a/src/main/java/com/terraforged/util/setup/SetupHooks.java b/src/main/java/com/terraforged/util/setup/SetupHooks.java index 6431063..3b0ad80 100644 --- a/src/main/java/com/terraforged/util/setup/SetupHooks.java +++ b/src/main/java/com/terraforged/util/setup/SetupHooks.java @@ -32,6 +32,7 @@ import com.terraforged.api.chunk.surface.SurfaceManager; import com.terraforged.api.event.SetupEvent; import com.terraforged.api.material.geology.GeologyManager; import com.terraforged.api.material.layer.LayerManager; +import com.terraforged.fm.structure.StructureManager; import com.terraforged.fm.modifier.FeatureModifiers; import com.terraforged.world.GeneratorContext; import com.terraforged.world.terrain.provider.TerrainProvider; @@ -71,6 +72,11 @@ public class SetupHooks { return manager; } + public static T setup(T manager, GeneratorContext context) { + MinecraftForge.EVENT_BUS.post(new SetupEvent.Structures(manager, context)); + return manager; + } + public static void setup(List base, List feature, GeneratorContext context) { MinecraftForge.EVENT_BUS.post(new SetupEvent.Decorators(new DecoratorManager(base, feature), context)); } diff --git a/src/main/resources/data/terraforged/features/trees/oak_plains.json b/src/main/resources/data/terraforged/features/trees/oak_plains.json index ad4bd9f..480f917 100644 --- a/src/main/resources/data/terraforged/features/trees/oak_plains.json +++ b/src/main/resources/data/terraforged/features/trees/oak_plains.json @@ -1,7 +1,8 @@ { "biomes": [ + "minecraft:river", "minecraft:plains", - "minecraft:river" + "minecraft:sunflower_plains" ], "match": [ [