Guest User

Ore gen code

a guest
Dec 13th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. package com.fran.mythology.world.gen;
  2.  
  3. import com.fran.mythology.MythMod;
  4. import com.fran.mythology.util.RegistryHandler;
  5. import net.minecraft.util.registry.Registry;
  6. import net.minecraft.util.registry.WorldGenRegistries;
  7. import net.minecraft.world.biome.Biome;
  8. import net.minecraft.world.gen.GenerationStage;
  9. import net.minecraft.world.gen.feature.ConfiguredFeature;
  10. import net.minecraft.world.gen.feature.Feature;
  11. import net.minecraft.world.gen.feature.IFeatureConfig;
  12. import net.minecraft.world.gen.feature.OreFeatureConfig;
  13. import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder;
  14. import net.minecraftforge.event.world.BiomeLoadingEvent;
  15. import net.minecraftforge.eventbus.api.EventPriority;
  16. import net.minecraftforge.eventbus.api.SubscribeEvent;
  17.  
  18. import java.util.ArrayList;
  19.  
  20. public class MythOreGen {
  21.  
  22.  
  23.  
  24.  
  25. // this is what I had:
  26. private static final ArrayList<ConfiguredFeature<?, ?>> overworldOres = new ArrayList<ConfiguredFeature<?, ?>>();
  27. private static final ArrayList<ConfiguredFeature<?, ?>> netherOres = new ArrayList<ConfiguredFeature<?, ?>>();
  28. private static final ArrayList<ConfiguredFeature<?, ?>> endOres = new ArrayList<ConfiguredFeature<?, ?>>();
  29.  
  30. public static void registerOre(){
  31. //Overworld Ore Register
  32. overworldOres.add(register("silver_ore", Feature.ORE.withConfiguration(new OreFeatureConfig(
  33. OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, RegistryHandler.SILVER_ORE.get().getDefaultState(), 5))
  34. .range(112).square()// Spawn height start
  35. .func_242731_b(155))); // Chunk Spawn frequency
  36.  
  37. //Nether Ore Register
  38. netherOres.add(register("silver_ore", Feature.ORE.withConfiguration(new OreFeatureConfig(
  39. OreFeatureConfig.FillerBlockType.BASE_STONE_NETHER, RegistryHandler.SILVER_ORE.get().getDefaultState(), 3))
  40. .range(0).square() // Spawn height start
  41. .func_242731_b(0))); // Chunk Spawn frequency
  42.  
  43. //End Ore Register
  44. endOres.add(register("silver_ore", Feature.ORE.withConfiguration(new OreFeatureConfig(
  45. OreFeatureConfig.FillerBlockType.BASE_STONE_NETHER, RegistryHandler.SILVER_ORE.get().getDefaultState(), 3))
  46. .range(0).square() // Spawn height start
  47. .func_242731_b(0))); // Chunk Spawn frequency
  48. }
  49.  
  50.  
  51.  
  52. @SubscribeEvent(priority = EventPriority.HIGHEST)
  53. public static void gen(BiomeLoadingEvent event) {
  54. BiomeGenerationSettingsBuilder generation = event.getGeneration();
  55. if(event.getCategory().equals(Biome.Category.NETHER)){
  56. for(ConfiguredFeature<?, ?> ore : netherOres){
  57. if (ore != null) generation.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, ore);
  58. }
  59. }
  60. if(event.getCategory().equals(Biome.Category.THEEND)){
  61. for(ConfiguredFeature<?, ?> ore :endOres){
  62. if (ore != null) generation.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, ore);
  63. }
  64. }
  65. for(ConfiguredFeature<?, ?> ore :overworldOres){
  66. if (ore != null) generation.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, ore);
  67. }
  68. }
  69.  
  70.  
  71. private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String name, ConfiguredFeature<FC, ?> configuredFeature) {
  72. return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, MythMod.MOD_ID + ":" + name, configuredFeature);
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment