Posted August 25, 20214 yr I have been trying to generate an ore for my mod and have created a new feature and registered it. However, whenever I join a world, it immediately crashes. I cannot find anything useful in the crash report and am stumped. Can you find where I made a mistake? Main Mod Class: package com.monkey.ExampleMod; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraft.world.gen.GenerationStage.Decoration; import net.minecraftforge.common.BiomeManager.BiomeType; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.world.BiomeLoadingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.monkey.ExampleMod.capabilities.Examples; import com.monkey.ExampleMod.capabilities.ExamplesProvider; import com.monkey.ExampleMod.capabilities.ExamplesStorage; import com.monkey.ExampleMod.capabilities.IExamples; import com.monkey.ExampleMod.capabilities.IVersions; import com.monkey.ExampleMod.capabilities.Versions; import com.monkey.ExampleMod.capabilities.VersionsProvider; import com.monkey.ExampleMod.capabilities.VersionsStorage; import com.monkey.ExampleMod.events.ExampleStats; import com.monkey.ExampleMod.init.BlockInit; import com.monkey.ExampleMod.init.EffectsInit; import com.monkey.ExampleMod.init.FeaturesInit; import com.monkey.ExampleMod.init.ItemInit; import com.monkey.ExampleMod.init.SoundInit; import com.monkey.ExampleMod.init.TileEntityInit; @Mod("ExampleMod") @Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Bus.FORGE) public class ExampleMod { public static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "ExampleMod"; public static final ItemGroup ExampleMod_GROUP = new ExampleModGroup("ExampleModtab"); public ExampleMod() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); BlockInit.BLOCKS.register(bus); ItemInit.ITEMS.register(bus); EffectsInit.EFFECTS.register(bus); SoundInit.SOUNDS.register(bus); TileEntityInit.TILE_ENTITY.register(bus); MinecraftForge.EVENT_BUS.register(this); FMLJavaModLoadingContext.get().getModEventBus().addListener(ExampleMod::onCommonSetup); } @SubscribeEvent public static void onCommonSetup(FMLCommonSetupEvent event) { CapabilityManager.INSTANCE.register(IExample.class, new ExampleStorage(), Examples::new); CapabilityManager.INSTANCE.register(IExampleTwo.class, new ExampleTwoStorage(), ExampleTwo::new); RenderTypeLookup.setRenderLayer(BlockInit.FLASK_GLASS.get(), RenderType.translucent()); } @SubscribeEvent public void onBiomeLoading(final BiomeLoadingEvent biome) { if(!(biome.getCategory() == Biome.Category.NETHER || biome.getCategory() == Biome.Category.THEEND)) { System.out.println("!"); biome.getGeneration().getFeatures(Decoration.UNDERGROUND_ORES) .add(() -> FeaturesInit.ORE_SULFUR_CONFIG); } } @SubscribeEvent public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof PlayerEntity) { event.addCapability(new ResourceLocation(ExampleMod.MOD_ID, "examples"), new ExamplesProvider()); event.addCapability(new ResourceLocation(ExampleMod.MOD_ID, "versions"), new VersionsProvider()); } } public static class ExampleModGroup extends ItemGroup { public ExampleModGroup(String label) { super(label); } @Override public ItemStack makeIcon() { return ItemInit.EXAMPLE_ICON.get().getDefaultInstance(); } } } Feature Class: package com.monkey.Example.init; import com.monkey.Example.Example; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.WorldGenRegistries; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.IFeatureConfig; import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; @Mod.EventBusSubscriber(modid = Example.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class FeaturesInit { public static ConfiguredFeature<?, ?> ORE_SULFUR_CONFIG; @SubscribeEvent public void setup(FMLCommonSetupEvent event) { ORE_SULFUR_CONFIG = register("ore_sulfur", Feature.ORE.configured( new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, BlockInit.SULFUR_ORE.get().defaultBlockState(), 9)).range(64).squared().count(20)); } private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) { return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation(Example.MOD_ID, key), configuredFeature); } } Edited August 26, 20214 yr by MonkeyKnight
August 25, 20214 yr is the FMLCommonSetupEvent in FeaturesInit fired? is your mod load because the mod id is invalid, you can't use upper case please use next time spoilers to post large code parts
August 26, 20214 yr Author I checked my code and my mod id was lowercase. There must have been an error when I copy and pasted it. I fixed my issue. The setup was not being called for some reason so I tweaked my code a bit and it now works. Thanks you for your help.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.