Skip to content

Commit 93ca2d8

Browse files
Update MDK with new output from mod generator (#8)
* Update MDK with new output from mod generator * Update MDK with new output from mod generator * Update MDK with new output from mod generator --------- Co-authored-by: NeoForge MDK Automation <173375039+neoforge-mdk-automation[bot]@users.noreply.github.com>
1 parent 812a12b commit 93ca2d8

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'maven-publish'
4-
id 'net.neoforged.moddev' version '2.0.96'
4+
id 'net.neoforged.moddev' version '2.0.99'
55
id 'idea'
66
}
77

src/main/java/com/example/examplemod/ExampleMod.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import com.mojang.logging.LogUtils;
66

7-
import net.minecraft.client.Minecraft;
87
import net.minecraft.core.registries.BuiltInRegistries;
98
import net.minecraft.core.registries.Registries;
109
import net.minecraft.network.chat.Component;
@@ -20,11 +19,9 @@
2019
import net.neoforged.api.distmarker.Dist;
2120
import net.neoforged.bus.api.IEventBus;
2221
import net.neoforged.bus.api.SubscribeEvent;
23-
import net.neoforged.fml.ModContainer;
24-
import net.neoforged.fml.common.EventBusSubscriber;
2522
import net.neoforged.fml.common.Mod;
2623
import net.neoforged.fml.config.ModConfig;
27-
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
24+
import net.neoforged.fml.ModContainer;
2825
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
2926
import net.neoforged.neoforge.common.NeoForge;
3027
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
@@ -40,7 +37,7 @@ public class ExampleMod {
4037
// Define mod id in a common place for everything to reference
4138
public static final String MODID = "examplemod";
4239
// Directly reference a slf4j logger
43-
private static final Logger LOGGER = LogUtils.getLogger();
40+
public static final Logger LOGGER = LogUtils.getLogger();
4441
// Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace
4542
public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(MODID);
4643
// Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace
@@ -117,15 +114,4 @@ public void onServerStarting(ServerStartingEvent event) {
117114
// Do something when the server starts
118115
LOGGER.info("HELLO from server starting");
119116
}
120-
121-
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
122-
@EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
123-
public static class ClientModEvents {
124-
@SubscribeEvent
125-
public static void onClientSetup(FMLClientSetupEvent event) {
126-
// Some client setup code
127-
LOGGER.info("HELLO FROM CLIENT SETUP");
128-
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
129-
}
130-
}
131117
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
package com.example.examplemod;
22

3+
import net.minecraft.client.Minecraft;
34
import net.neoforged.api.distmarker.Dist;
5+
import net.neoforged.bus.api.SubscribeEvent;
46
import net.neoforged.fml.ModContainer;
7+
import net.neoforged.fml.common.EventBusSubscriber;
58
import net.neoforged.fml.common.Mod;
9+
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
610
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
711
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
812

913
// This class will not load on dedicated servers. Accessing client side code from here is safe.
1014
@Mod(value = ExampleMod.MODID, dist = Dist.CLIENT)
15+
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
16+
@EventBusSubscriber(modid = ExampleMod.MODID, value = Dist.CLIENT)
1117
public class ExampleModClient {
1218
public ExampleModClient(ModContainer container) {
1319
// Allows NeoForge to create a config screen for this mod's configs.
1420
// The config screen is accessed by going to the Mods screen > clicking on your mod > clicking on config.
1521
// Do not forget to add translations for your config options to the en_us.json file.
1622
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
1723
}
18-
}
24+
25+
@SubscribeEvent
26+
static void onClientSetup(FMLClientSetupEvent event) {
27+
// Some client setup code
28+
ExampleMod.LOGGER.info("HELLO FROM CLIENT SETUP");
29+
ExampleMod.LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
30+
}
31+
}

0 commit comments

Comments
 (0)