diff options
Diffstat (limited to 'src/main/java/com/example/examplemod/ExampleMod.java')
| -rw-r--r-- | src/main/java/com/example/examplemod/ExampleMod.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java index 9096c03..259b3da 100644 --- a/src/main/java/com/example/examplemod/ExampleMod.java +++ b/src/main/java/com/example/examplemod/ExampleMod.java @@ -1,6 +1,9 @@ package com.example.examplemod; +import org.slf4j.Logger; + import com.mojang.logging.LogUtils; + import net.minecraft.client.Minecraft; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; @@ -17,7 +20,8 @@ import net.minecraft.world.level.material.MapColor; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.IEventBus; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.Mod; import net.neoforged.fml.config.ModConfig; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; @@ -29,7 +33,6 @@ import net.neoforged.neoforge.registries.DeferredBlock; import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; -import org.slf4j.Logger; // The value here should match an entry in the META-INF/mods.toml file @Mod(ExampleMod.MODID) @@ -53,7 +56,7 @@ public class ExampleMod // Creates a new food item with the id "examplemod:example_id", nutrition 1 and saturation 2 public static final DeferredItem<Item> EXAMPLE_ITEM = ITEMS.registerSimpleItem("example_item", new Item.Properties().food(new FoodProperties.Builder() - .alwaysEat().nutrition(1).saturationMod(2f).build())); + .alwaysEdible().nutrition(1).saturationModifier(2f).build())); // Creates a creative tab with the id "examplemod:example_tab" for the example item, that is placed after the combat tab public static final DeferredHolder<CreativeModeTab, CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder() @@ -66,7 +69,7 @@ public class ExampleMod // The constructor for the mod class is the first code that is run when your mod is loaded. // FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically. - public ExampleMod(IEventBus modEventBus) + public ExampleMod(IEventBus modEventBus, ModContainer modContainer) { // Register the commonSetup method for modloading modEventBus.addListener(this::commonSetup); @@ -87,7 +90,7 @@ public class ExampleMod modEventBus.addListener(this::addCreative); // Register our mod's ModConfigSpec so that FML can create and load the config file for us - ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC); + modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC); } private void commonSetup(final FMLCommonSetupEvent event) @@ -119,7 +122,7 @@ public class ExampleMod } // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent - @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) + @EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public static class ClientModEvents { @SubscribeEvent |
