1
0
mirror of https://github.com/TechnoVisionDev/Forge-Modding-Tutorial-1.16 synced 2024-10-27 20:34:04 +00:00

Match code to video

This commit is contained in:
TechnoVisionDev 2020-07-11 21:58:28 -07:00
parent 25ed35627a
commit 8378a9c843

View File

@ -6,6 +6,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.pattern.BlockMatcher; import net.minecraft.block.pattern.BlockMatcher;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.GenerationStage; import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraft.world.gen.feature.OreFeatureConfig;
@ -20,34 +21,30 @@ import net.minecraftforge.registries.ForgeRegistries;
@Mod.EventBusSubscriber(modid = Tutorial.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) @Mod.EventBusSubscriber(modid = Tutorial.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModOreGen { public class ModOreGen {
public static OreFeatureConfig.FillerBlockType END_STONE = OreFeatureConfig.FillerBlockType.create("END_STONE","end_stone", new BlockMatcher(Blocks.END_STONE)); public static OreFeatureConfig.FillerBlockType END_STONE = OreFeatureConfig.FillerBlockType.create("END_STONE",
"end_stone", new BlockMatcher(Blocks.END_STONE));
@SubscribeEvent @SubscribeEvent
public static void generateOres(FMLLoadCompleteEvent event) { public static void generateOres(FMLLoadCompleteEvent event) {
for (Biome biome : ForgeRegistries.BIOMES) { for (Biome biome : ForgeRegistries.BIOMES) {
//World Generation //Nether Generation
if (biome.getCategory() == Biome.Category.NETHER) { if (biome.getCategory() == Biome.Category.NETHER) {
genOre(biome, 15, 20, 5, 50, OreFeatureConfig.FillerBlockType.NETHERRACK, RegistryHandler.RUBY_ORE.get().getDefaultState(), 6); genOre(biome, 12, 5, 5, 80, OreFeatureConfig.FillerBlockType.NETHERRACK, RegistryHandler.RUBY_ORE.get().getDefaultState(), 4);
//End Generation //End Generation
} else if (biome.getCategory() == Biome.Category.THEEND) { } else if (biome.getCategory() == Biome.Category.THEEND) {
genOre(biome, 15, 5, 5, 80, END_STONE, RegistryHandler.RUBY_ORE.get().getDefaultState(), 8); genOre(biome, 18, 3, 5, 80, END_STONE, RegistryHandler.RUBY_ORE.get().getDefaultState(), 12);
//World Generation
//Nether Generation
} else { } else {
genOre(biome, 15, 5, 5, 80, OreFeatureConfig.FillerBlockType.NATURAL_STONE, RegistryHandler.RUBY_ORE.get().getDefaultState(), 12); genOre(biome, 15, 8, 5, 50, OreFeatureConfig.FillerBlockType.NATURAL_STONE, RegistryHandler.RUBY_ORE.get().getDefaultState(), 6);
} }
} }
} }
private static void genOre(Biome biome, int count, int bottomOffset, int topOffset, int max, OreFeatureConfig.FillerBlockType filler, BlockState defaultBlockstate, int size) { private static void genOre(Biome biome, int count, int bottomOffset, int topOffset, int max, OreFeatureConfig.FillerBlockType filler, BlockState defaultBlockstate, int size) {
System.out.println("STARTING: " + biome.getCategory().getName());
CountRangeConfig range = new CountRangeConfig(count, bottomOffset, topOffset, max); CountRangeConfig range = new CountRangeConfig(count, bottomOffset, topOffset, max);
OreFeatureConfig feature = new OreFeatureConfig(filler, defaultBlockstate, size); OreFeatureConfig feature = new OreFeatureConfig(filler, defaultBlockstate, size);
ConfiguredPlacement config = Placement.COUNT_RANGE.configure(range); ConfiguredPlacement config = Placement.COUNT_RANGE.configure(range);
biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(feature).withPlacement(config)); biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(feature).withPlacement(config));
System.out.println("FINISHED: " + biome.getCategory().getName());
} }
} }