Add ore gen

This commit is contained in:
Brennan Ward 2019-11-11 22:50:40 -05:00
parent f7dd5d11e1
commit 00c25a2638

View file

@ -13,13 +13,24 @@ package de.ellpeck.actuallyadditions.mod;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import de.ellpeck.actuallyadditions.mod.block.AABlocks;
import de.ellpeck.actuallyadditions.mod.item.AAItems; import de.ellpeck.actuallyadditions.mod.item.AAItems;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage.Decoration;
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.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries;
@Mod(ActuallyAdditions.MODID) @Mod(ActuallyAdditions.MODID)
public class ActuallyAdditions { public class ActuallyAdditions {
@ -40,6 +51,19 @@ public class ActuallyAdditions {
@SubscribeEvent @SubscribeEvent
public void setup(FMLCommonSetupEvent e) { public void setup(FMLCommonSetupEvent e) {
for (Biome b : ForgeRegistries.BIOMES) {
if (b.getFeatures(Decoration.UNDERGROUND_ORES).stream().anyMatch(ActuallyAdditions::isIronOreFeature)) {
b.addFeature(Decoration.UNDERGROUND_ORES, Biome.createDecoratedFeature(Feature.ORE, new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, AABlocks.BLACK_QUARTZ_ORE.getDefaultState(), 8), Placement.COUNT_RANGE, new CountRangeConfig(10, 0, 0, 64)));
}
}
}
public static boolean isIronOreFeature(ConfiguredFeature<?> f) {
if (f.feature == Feature.DECORATED) {
DecoratedFeatureConfig cfg = (DecoratedFeatureConfig) f.config;
if (cfg.feature.feature == Feature.ORE) return ((OreFeatureConfig) cfg.feature.config).state == Blocks.IRON_ORE.getDefaultState();
return false;
}
return false;
} }
} }