diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index d4441b61..884388ee 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -21,13 +21,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.gen.GenerationStage; import net.minecraft.world.gen.GenerationStage.Decoration; -import net.minecraft.world.gen.feature.IFeatureConfig; -import net.minecraft.world.gen.placement.ConfiguredPlacement; -import net.minecraft.world.gen.placement.IPlacementConfig; -import net.minecraft.world.gen.placement.NoPlacementConfig; -import net.minecraft.world.gen.placement.Placement; import net.minecraft.world.server.ChunkHolder; import net.minecraft.world.server.ChunkManager; import net.minecraft.world.server.ServerChunkProvider; @@ -53,18 +47,17 @@ public class CommonEvents { @SubscribeEvent public void onBiomeLoad(BiomeLoadingEvent event) { if (ModConfig.instance.auraBlooms.get()) { - ConfiguredPlacement placement = Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG); - event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.AURA_BLOOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_BLOOM); switch (event.getCategory()) { case DESERT: - event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.AURA_CACTUS.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_CACTUS); break; case NETHER: - event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.CRIMSON_AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); - event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.WARPED_AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.CRIMSON_AURA_MUSHROOM); + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.WARPED_AURA_MUSHROOM); break; case MUSHROOM: - event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(placement)); + event.getGeneration().func_242513_a(Decoration.VEGETAL_DECORATION, ModFeatures.Configured.AURA_MUSHROOM); break; } } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java index 3a306cc7..43a2cedb 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -1,9 +1,8 @@ package de.ellpeck.naturesaura.gen; -import net.minecraft.world.gen.feature.BaseTreeFeatureConfig; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraft.world.gen.feature.TreeFeature; +import net.minecraft.world.gen.feature.*; +import net.minecraft.world.gen.placement.IPlacementConfig; +import net.minecraft.world.gen.placement.Placement; @SuppressWarnings("FieldNamingConvention") public final class ModFeatures { @@ -16,4 +15,13 @@ public final class ModFeatures { public static Feature CRIMSON_AURA_MUSHROOM; public static Feature AURA_MUSHROOM; + public static final class Configured { + + public static final ConfiguredFeature AURA_BLOOM = ModFeatures.AURA_BLOOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)); + public static final ConfiguredFeature AURA_CACTUS = ModFeatures.AURA_CACTUS.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)); + public static final ConfiguredFeature CRIMSON_AURA_MUSHROOM = ModFeatures.CRIMSON_AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)); + public static final ConfiguredFeature WARPED_AURA_MUSHROOM = ModFeatures.WARPED_AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)); + public static final ConfiguredFeature AURA_MUSHROOM = ModFeatures.AURA_MUSHROOM.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)); + + } } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index 3b56f76b..4dfcd401 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -45,7 +45,10 @@ import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.potion.Effect; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.WorldGenRegistries; import net.minecraft.world.World; +import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.structure.Structure; import net.minecraftforge.common.extensions.IForgeContainerType; @@ -55,6 +58,7 @@ import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.items.IItemHandler; +import java.lang.reflect.Field; import java.util.HashSet; import java.util.Set; @@ -337,6 +341,15 @@ public final class ModRegistry { if (item instanceof ITESRProvider) NaturesAura.proxy.registerTESR((ITESRProvider) item); } + + for (Field entry : ModFeatures.Configured.class.getFields()) { + try { + ConfiguredFeature feature = (ConfiguredFeature) entry.get(null); + Registry.register(WorldGenRegistries.field_243653_e, feature.feature.getRegistryName(), feature); + } catch (IllegalAccessException e) { + NaturesAura.LOGGER.error(e); + } + } } public static Block createFlowerPot(Block block) {