Guest User

Untitled

a guest
Jun 1st, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. package com.cti.universeawakening;
  2. import com.cti.universeawakening.universeawakening;
  3. import com.cti.universeawakening.RegistryHandler;
  4. import net.minecraft.block.Blocks;
  5. import net.minecraft.item.Items;
  6. import net.minecraft.util.registry.Registry;
  7. import net.minecraft.util.registry.WorldGenRegistries;
  8. import net.minecraft.world.biome.Biome;
  9. import net.minecraft.world.gen.GenerationStage;
  10. import net.minecraft.world.gen.feature.OreFeature;
  11. import net.minecraft.world.gen.feature.ConfiguredFeature;
  12. import net.minecraft.world.gen.feature.Feature;
  13. import net.minecraft.world.gen.feature.IFeatureConfig;
  14. import net.minecraft.world.gen.feature.OreFeatureConfig;
  15. import net.minecraft.world.gen.feature.template.BlockMatchRuleTest;
  16. import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder;
  17. import net.minecraftforge.event.world.BiomeLoadingEvent;
  18. import net.minecraftforge.eventbus.api.EventPriority;
  19. import net.minecraftforge.eventbus.api.SubscribeEvent;
  20. import net.minecraftforge.fml.common.Mod;
  21. import java.util.ArrayList;
  22. import net.minecraft.block.Block;
  23.  
  24. /**
  25. * Ore generation
  26. * @author TechOFreak
  27. *
  28. */
  29.  
  30. @Mod.EventBusSubscriber
  31. public class OreGeneration {
  32.  
  33. private static final ArrayList<ConfiguredFeature<?, ?>> overworldOres = new ArrayList<ConfiguredFeature<?, ?>>();
  34. private static final ArrayList<ConfiguredFeature<?, ?>> netherOres = new ArrayList<ConfiguredFeature<?, ?>>();
  35. private static final ArrayList<ConfiguredFeature<?, ?>> endOres = new ArrayList<ConfiguredFeature<?, ?>>();
  36.  
  37. public static void registerOres(){
  38. //BASE_STONE_OVERWORLD is for generating in stone, granite, diorite, and andesite
  39. //NETHERRACK is for generating in netherrack
  40. //BASE_STONE_NETHER is for generating in netherrack, basalt and blackstone
  41.  
  42. //Overworld Ore Register
  43. overworldOres.add(register("copper_ore", Feature.ORE.withConfiguration(new OreFeatureConfig(
  44. OreFeatureConfig.FillerBlockType.NATURAL_STONE, RegistryHandler.COPPER_ORE.get().getDefaultState(), 4)) //Vein Size
  45. .range(64).square() //Spawn height start
  46. .func_242731_b(64))); //Chunk spawn frequency
  47. //overworldOres.add(register("earthy_deposit", Feature.ORE.withConfiguration(new OreFeatureConfig(
  48. // new BlockMatchRuleTest(Blocks.DIRT), RegistryHandlerBlocks.EARTHY_DEPOSIT.get().getDefaultState(), 4)) //Vein Size
  49. // .range(128).square() //Spawn height start
  50. // .func_242731_b(64))); //Chunk spawn frequency
  51.  
  52. //Nether Ore Register
  53. // netherOres.add(register("flame_crystal_ore", Feature.ORE.withConfiguration(new OreFeatureConfig(
  54. // OreFeatureConfig.FillerBlockType.NETHERRACK, RegistryHandlerBlocks.FLAME_CRYSTAL_ORE.get().getDefaultState(), 4))
  55. // .range(48).square()
  56. // .func_242731_b(64)));
  57.  
  58. //The End Ore Register
  59. // endOres.add(register("air_block", Feature.ORE.withConfiguration(new OreFeatureConfig(
  60. // new BlockMatchRuleTest(Blocks.END_STONE), RegistryHandlerBlocks.AIR_CRYSTAL_BLOCK.get().getDefaultState(), 4)) //Vein Size
  61. // .range(128).square() //Spawn height start
  62. // .func_242731_b(64))); //Chunk spawn frequency
  63. }
  64.  
  65. @SubscribeEvent(priority = EventPriority.HIGHEST)
  66. public static void gen(BiomeLoadingEvent event) {
  67. BiomeGenerationSettingsBuilder generation = event.getGeneration();
  68. if(event.getCategory().equals(Biome.Category.NETHER)){
  69. for(ConfiguredFeature<?, ?> ore : netherOres){
  70. if (ore != null) generation.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, ore);
  71. }
  72. }
  73. if(event.getCategory().equals(Biome.Category.THEEND)){
  74. for(ConfiguredFeature<?, ?> ore : endOres){
  75. if (ore != null) generation.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, ore);
  76. }
  77. }
  78. for(ConfiguredFeature<?, ?> ore : overworldOres){
  79. if (ore != null) generation.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, ore);
  80. }
  81. }
  82.  
  83. private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String name, ConfiguredFeature<FC, ?> configuredFeature) {
  84. return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, universeawakening.MOD_ID + ":" + name, configuredFeature);
  85. }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment