1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package me.km.world;
- 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.DecoratedFeatureConfig;
- import net.minecraft.world.gen.feature.Feature;
- import net.minecraft.world.gen.feature.OreFeatureConfig;
- import net.minecraft.world.gen.placement.CountRangeConfig;
- import net.minecraft.world.gen.placement.Placement;
- 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())
- {
- for(ConfiguredFeature f : biome.getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES))
- {
- if(!(f.config instanceof DecoratedFeatureConfig))
- {
- continue;
- }
- DecoratedFeatureConfig conf = (DecoratedFeatureConfig) f.config;
- if(!(conf.feature.config instanceof OreFeatureConfig))
- {
- continue;
- }
- OreFeatureConfig ore = (OreFeatureConfig) conf.feature.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.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES,
- Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,
- ore.getDefaultState(), maxCount)
- ).withPlacement(Placement.COUNT_RANGE.configure(new CountRangeConfig(spawnTries, 0, 0, maxHeight))));
- }
-
- 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);
- }
- }
|