summaryrefslogtreecommitdiff
path: root/src/main/java/com/example/examplemod/ExampleMod.java
diff options
context:
space:
mode:
authorBrennan Ward <3682588+Shadows-of-Fire@users.noreply.github.com>2024-04-27 23:35:22 -0700
committerBrennan Ward <3682588+Shadows-of-Fire@users.noreply.github.com>2024-04-27 23:35:22 -0700
commit8e4a898238014d10c934417848596816920e00ad (patch)
tree493123edd6d761fc0093110b3527bd5b2f12d4f2 /src/main/java/com/example/examplemod/ExampleMod.java
parenta780f5831b35b386cd59d958641bec98107fdfd9 (diff)
Update to 1.20.5
Diffstat (limited to 'src/main/java/com/example/examplemod/ExampleMod.java')
-rw-r--r--src/main/java/com/example/examplemod/ExampleMod.java15
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