12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package me.km.world;
- import java.util.function.Supplier;
- import me.km.blocks.ModBlocks;
- import net.minecraft.block.Block;
- import net.minecraft.block.Blocks;
- import net.minecraft.world.biome.Biome;
- import net.minecraft.world.gen.GenerationStage;
- import net.minecraft.world.gen.feature.ConfiguredFeature;
- import net.minecraft.world.gen.feature.Feature;
- import net.minecraft.world.gen.feature.OreFeatureConfig;
- import net.minecraftforge.registries.ForgeRegistries;
- public class ModWorldGeneration {
- public static void register() {
- // search for all biomes which generate ore
- for(Biome biome : ForgeRegistries.BIOMES.getValues()) {
- biome.getGenerationSettings().getFeatures().forEach(list -> {
- for(Supplier<ConfiguredFeature<?, ?>> entry : list) {
- if(entry.get().config instanceof OreFeatureConfig) {
- OreFeatureConfig ore = (OreFeatureConfig) entry.get().config;
- if(ore.state == Blocks.IRON_ORE.getDefaultState()) {
- addFeatures(biome);
- break;
- }
- }
- }
- });
- }
- }
- private static void addOre(Biome b, Block ore, int maxCount, int spawnTries, int maxHeight) {
- b.getGenerationSettings().getFeatures().get(GenerationStage.Decoration.UNDERGROUND_ORES.ordinal()).add(() -> {
- return Feature.ORE.withConfiguration(
- new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD,
- ore.getDefaultState(), maxCount)).range(maxHeight).square().func_242731_b(spawnTries);
- });
- }
- private static void addFeatures(Biome biome) {
- // | max | bottom | top | max | spawn |
- // name | size | offset | offset | high | tries |
- // ---------------------------------------------------
- // coal | 17 | 0 | 0 | 128 | 20 |
- // iron | 9 | 0 | 0 | 64 | 20 |
- // gold | 9 | 0 | 0 | 32 | 2 |
- // redstone | 8 | 0 | 0 | 16 | 8 |
- // diamond | 8 | 0 | 0 | 16 | 1 |
- // lapis | 7 | - | - | - | - |
- // copper | 9 | 0 | 0 | 128 | 25 |
- // tin | 6 | 0 | 0 | 96 | 12 |
- // silver | 9 | 0 | 0 | 64 | 3 |
- addOre(biome, ModBlocks.copperOre, 9, 25, 128);
- addOre(biome, ModBlocks.tinOre, 6, 12, 96);
- addOre(biome, ModBlocks.silverOre, 9, 3, 64);
- }
- }
|