summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorneoforge-mdk-automation[bot] <173375039+neoforge-mdk-automation[bot]@users.noreply.github.com>2025-06-15 04:31:01 +0000
committerGitHub <noreply@github.com>2025-06-15 04:31:01 +0000
commitf351852d5f47f6669cc497d890aa9d5e868d51eb (patch)
tree29fdeb7f5f450fdac2122abe3701b1d666d16be0 /src/main/java
parentb1ca96692c51ebabc269a3d57c9d4685b7a63b18 (diff)
Update MDK with new output from mod generator (#4)
* 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>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/example/examplemod/Config.java6
-rw-r--r--src/main/java/com/example/examplemod/ExampleMod.java27
2 files changed, 13 insertions, 20 deletions
diff --git a/src/main/java/com/example/examplemod/Config.java b/src/main/java/com/example/examplemod/Config.java
index 6f8636d..358706c 100644
--- a/src/main/java/com/example/examplemod/Config.java
+++ b/src/main/java/com/example/examplemod/Config.java
@@ -14,8 +14,7 @@ import net.neoforged.neoforge.common.ModConfigSpec;
// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
// Demonstrates how to use Neo's config APIs
-public class Config
-{
+public class Config {
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
public static final ModConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
@@ -37,8 +36,7 @@ public class Config
static final ModConfigSpec SPEC = BUILDER.build();
- private static boolean validateItemName(final Object obj)
- {
+ private static boolean validateItemName(final Object obj) {
return obj instanceof String itemName && BuiltInRegistries.ITEM.containsKey(ResourceLocation.parse(itemName));
}
}
diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java
index 5e5a0c1..adc09f4 100644
--- a/src/main/java/com/example/examplemod/ExampleMod.java
+++ b/src/main/java/com/example/examplemod/ExampleMod.java
@@ -36,8 +36,7 @@ import net.neoforged.neoforge.registries.DeferredRegister;
// The value here should match an entry in the META-INF/neoforge.mods.toml file
@Mod(ExampleMod.MODID)
-public class ExampleMod
-{
+public class ExampleMod {
// Define mod id in a common place for everything to reference
public static final String MODID = "examplemod";
// Directly reference a slf4j logger
@@ -69,8 +68,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, ModContainer modContainer)
- {
+ public ExampleMod(IEventBus modEventBus, ModContainer modContainer) {
// Register the commonSetup method for modloading
modEventBus.addListener(this::commonSetup);
@@ -93,13 +91,13 @@ public class ExampleMod
modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
}
- private void commonSetup(final FMLCommonSetupEvent event)
- {
+ private void commonSetup(FMLCommonSetupEvent event) {
// Some common setup code
LOGGER.info("HELLO FROM COMMON SETUP");
- if (Config.LOG_DIRT_BLOCK.getAsBoolean())
+ if (Config.LOG_DIRT_BLOCK.getAsBoolean()) {
LOGGER.info("DIRT BLOCK >> {}", BuiltInRegistries.BLOCK.getKey(Blocks.DIRT));
+ }
LOGGER.info("{}{}", Config.MAGIC_NUMBER_INTRODUCTION.get(), Config.MAGIC_NUMBER.getAsInt());
@@ -107,27 +105,24 @@ public class ExampleMod
}
// Add the example block item to the building blocks tab
- private void addCreative(BuildCreativeModeTabContentsEvent event)
- {
- if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
+ private void addCreative(BuildCreativeModeTabContentsEvent event) {
+ if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS) {
event.accept(EXAMPLE_BLOCK_ITEM);
+ }
}
// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
- public void onServerStarting(ServerStartingEvent event)
- {
+ public void onServerStarting(ServerStartingEvent event) {
// Do something when the server starts
LOGGER.info("HELLO from server starting");
}
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
@EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
- public static class ClientModEvents
- {
+ public static class ClientModEvents {
@SubscribeEvent
- public static void onClientSetup(FMLClientSetupEvent event)
- {
+ public static void onClientSetup(FMLClientSetupEvent event) {
// Some client setup code
LOGGER.info("HELLO FROM CLIENT SETUP");
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());