generated from NeoForgeMDKs/MDK-1.21-ModDevGradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1708875
commit 0a97208
Showing
4 changed files
with
96 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package net.renegadeactual.core; | ||
|
||
import org.slf4j.Logger; | ||
|
||
import com.mojang.logging.LogUtils; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
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; | ||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.neoforged.neoforge.common.NeoForge; | ||
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; | ||
import net.neoforged.neoforge.event.server.ServerStartingEvent; | ||
|
||
// The value here should match an entry in the META-INF/neoforge.mods.toml file | ||
@Mod(RACore.MOD_ID) | ||
public class RACore { | ||
// Define mod id in a common place for everything to reference | ||
public static final String MOD_ID = "ra_core"; | ||
// Directly reference a slf4j logger | ||
private static final Logger LOGGER = LogUtils.getLogger(); | ||
|
||
// 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 RACore(IEventBus modEventBus, ModContainer modContainer) { | ||
// Register the commonSetup method for modloading | ||
modEventBus.addListener(this::commonSetup); | ||
|
||
|
||
|
||
// Register ourselves for server and other game events we are interested in. | ||
// Note that this is necessary if and only if we want *this* class (ExampleMod) to respond directly to events. | ||
// Do not add this line if there are no @SubscribeEvent-annotated functions in this class, like onServerStarting() below. | ||
NeoForge.EVENT_BUS.register(this); | ||
|
||
// Register the item to a creative tab | ||
modEventBus.addListener(this::addCreative); | ||
|
||
// Register our mod's ModConfigSpec so that FML can create and load the config file for us | ||
modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC); | ||
} | ||
|
||
private void commonSetup(final FMLCommonSetupEvent event) { | ||
// Some common setup code | ||
LOGGER.info("HELLO FROM COMMON SETUP"); | ||
|
||
if (Config.logDirtBlock) | ||
LOGGER.info("DIRT BLOCK >> {}", BuiltInRegistries.BLOCK.getKey(Blocks.DIRT)); | ||
|
||
LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber); | ||
|
||
Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString())); | ||
} | ||
|
||
// Add the example block item to the building blocks tab | ||
private void addCreative(BuildCreativeModeTabContentsEvent event) { | ||
|
||
} | ||
|
||
// You can use SubscribeEvent and let the Event Bus discover methods to call | ||
@SubscribeEvent | ||
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 = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) | ||
public static class ClientModEvents { | ||
@SubscribeEvent | ||
public static void onClientSetup(FMLClientSetupEvent event) { | ||
// Some client setup code | ||
LOGGER.info("HELLO FROM CLIENT SETUP"); | ||
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName()); | ||
} | ||
} | ||
} |