Move structures an clean up how they're added to biomes

This commit is contained in:
Sollace 2020-05-28 13:40:36 +02:00
parent ca70c87b04
commit 2cac91c351
11 changed files with 34 additions and 38 deletions

View file

@ -1,6 +1,5 @@
package com.minelittlepony.unicopia.structure; package com.minelittlepony.unicopia.structure;
import java.util.Arrays;
import java.util.Random; import java.util.Random;
import java.util.function.Function; import java.util.function.Function;
@ -19,7 +18,6 @@ import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.decorator.Decorator; import net.minecraft.world.gen.decorator.Decorator;
@ -37,25 +35,14 @@ class CloudDungeonFeature extends AbstractTempleFeature<DefaultFeatureConfig> {
new Identifier("unicopia", "cloud/island_small") new Identifier("unicopia", "cloud/island_small")
}; };
public CloudDungeonFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> func) { public CloudDungeonFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> func, Biome...biomes) {
super(func); super(func);
Arrays.asList( for (Biome biome : biomes) {
Biomes.OCEAN,
Biomes.WOODED_BADLANDS_PLATEAU,
Biomes.DESERT,
Biomes.DESERT_HILLS,
Biomes.JUNGLE,
Biomes.JUNGLE_HILLS,
Biomes.SWAMP,
Biomes.SWAMP_HILLS,
Biomes.ICE_SPIKES,
Biomes.TAIGA
).forEach(biome -> {
biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, configure(FeatureConfig.DEFAULT) biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, configure(FeatureConfig.DEFAULT)
.createDecoratedFeature(Decorator.NOPE .createDecoratedFeature(Decorator.NOPE
.configure(NopeDecoratorConfig.DEFAULT))); .configure(NopeDecoratorConfig.DEFAULT)));
}); }
} }
@Override @Override

View file

@ -1,6 +1,5 @@
package com.minelittlepony.unicopia.structure; package com.minelittlepony.unicopia.structure;
import java.util.Arrays;
import java.util.Random; import java.util.Random;
import java.util.function.Function; import java.util.function.Function;
@ -19,7 +18,6 @@ import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.decorator.Decorator; import net.minecraft.world.gen.decorator.Decorator;
@ -39,26 +37,14 @@ class RuinFeature extends AbstractTempleFeature<DefaultFeatureConfig> {
new Identifier("unicopia", "ground/wizard_tower_blue") new Identifier("unicopia", "ground/wizard_tower_blue")
}; };
public RuinFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> func) { public RuinFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> func, Biome... biomes) {
super(func); super(func);
Arrays.asList( for (Biome biome : biomes) {
Biomes.TAIGA,
Biomes.TAIGA_HILLS,
Biomes.GIANT_TREE_TAIGA,
Biomes.GIANT_TREE_TAIGA_HILLS,
Biomes.SNOWY_TAIGA,
Biomes.SNOWY_TAIGA_HILLS,
Biomes.GIANT_SPRUCE_TAIGA,
Biomes.GIANT_TREE_TAIGA_HILLS,
Biomes.SNOWY_TAIGA_MOUNTAINS,
Biomes.DARK_FOREST,
Biomes.DARK_FOREST_HILLS
).forEach(biome -> {
biome.addFeature(GenerationStep.Feature.SURFACE_STRUCTURES, biome.addFeature(GenerationStep.Feature.SURFACE_STRUCTURES,
configure(FeatureConfig.DEFAULT) configure(FeatureConfig.DEFAULT)
.createDecoratedFeature(Decorator.NOPE.configure(DecoratorConfig.DEFAULT))); .createDecoratedFeature(Decorator.NOPE.configure(DecoratorConfig.DEFAULT)));
}); }
} }
@Override @Override

View file

@ -6,6 +6,7 @@ import net.minecraft.structure.StructurePieceType;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.CountExtraChanceDecoratorConfig; import net.minecraft.world.gen.decorator.CountExtraChanceDecoratorConfig;
import net.minecraft.world.gen.decorator.Decorator; import net.minecraft.world.gen.decorator.Decorator;
@ -19,15 +20,37 @@ public interface UStructures {
StructurePieceType CLOUD_HOUSE_PART = part("cloud_house", CloudDungeonFeature.Piece::new); StructurePieceType CLOUD_HOUSE_PART = part("cloud_house", CloudDungeonFeature.Piece::new);
StructurePieceType RUIN_PART = part("ruin", RuinFeature.Piece::new); StructurePieceType RUIN_PART = part("ruin", RuinFeature.Piece::new);
StructureFeature<DefaultFeatureConfig> CLOUD_HOUSE = feature("cloud_house", new CloudDungeonFeature(DefaultFeatureConfig::deserialize)); StructureFeature<DefaultFeatureConfig> CLOUD_HOUSE = feature("cloud_house", new CloudDungeonFeature(DefaultFeatureConfig::deserialize, Biomes.OCEAN,
StructureFeature<DefaultFeatureConfig> RUIN = feature("ruin", new RuinFeature(DefaultFeatureConfig::deserialize)); Biomes.WOODED_BADLANDS_PLATEAU,
Biomes.DESERT,
Biomes.DESERT_HILLS,
Biomes.JUNGLE,
Biomes.JUNGLE_HILLS,
Biomes.SWAMP,
Biomes.SWAMP_HILLS,
Biomes.ICE_SPIKES,
Biomes.TAIGA));
StructureFeature<DefaultFeatureConfig> RUIN = feature("ruin", new RuinFeature(DefaultFeatureConfig::deserialize,
Biomes.TAIGA,
Biomes.TAIGA_HILLS,
Biomes.GIANT_TREE_TAIGA,
Biomes.GIANT_TREE_TAIGA_HILLS,
Biomes.SNOWY_TAIGA,
Biomes.SNOWY_TAIGA_HILLS,
Biomes.GIANT_SPRUCE_TAIGA,
Biomes.GIANT_TREE_TAIGA_HILLS,
Biomes.SNOWY_TAIGA_MOUNTAINS,
Biomes.DARK_FOREST,
Biomes.DARK_FOREST_HILLS
));
static StructurePieceType part(String id, StructurePieceType type) { static StructurePieceType part(String id, StructurePieceType type) {
return Registry.register(Registry.STRUCTURE_PIECE, new Identifier("unicopia", id), type); return Registry.register(Registry.STRUCTURE_PIECE, new Identifier("unicopia", id), type);
} }
static <C extends FeatureConfig, F extends Feature<C>> F feature(String id, F feature) { static <C extends FeatureConfig, F extends StructureFeature<C>> F feature(String name, F feature) {
return Registry.register(Registry.FEATURE, new Identifier("unicopia", id), feature); Identifier id = new Identifier("unicopia", name);
return Registry.register(Registry.STRUCTURE_FEATURE, id, Registry.register(Registry.FEATURE, id, feature));
} }
static void bootstrap() { static void bootstrap() {
@ -41,7 +64,7 @@ public interface UStructures {
Feature.FANCY_TREE.configure(CustomSaplingGenerator.APPLE_TREE.fancyConfig).withChance(0.01F)), Feature.FANCY_TREE.configure(CustomSaplingGenerator.APPLE_TREE.fancyConfig).withChance(0.01F)),
Feature.NORMAL_TREE.configure(CustomSaplingGenerator.APPLE_TREE.config) Feature.NORMAL_TREE.configure(CustomSaplingGenerator.APPLE_TREE.config)
)) ))
.createDecoratedFeature(Decorator.COUNT_EXTRA_HEIGHTMAP.configure(new CountExtraChanceDecoratorConfig(10, 0.1F, 1)))); .createDecoratedFeature(Decorator.COUNT_EXTRA_HEIGHTMAP.configure(new CountExtraChanceDecoratorConfig(0, 0.1F, 3))));
} }
}); });
} }