整理代码 and 使用配置文件保存配置

This commit is contained in:
xzb23 committed 2026-08-19 15:11:40 +08:00
1 parent feb96541ff
commit 445a2addcd
3 files changed
+32 -54

No files matched your search

@@ -70,7 +70,7 @@ public class stopcheat {
// 只在专用服务端执行
NeoForge.EVENT_BUS.register(CommandInterceptor.class);
// // Register the commonSetup method for modloading
// modEventBus.addListener(this::commonSetup);
modEventBus.addListener(this::commonSetup);
//
// // Register the Deferred Register to the mod event bus so blocks get registered
// BLOCKS.register(modEventBus);
@@ -88,33 +88,12 @@ public class stopcheat {
// 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);
modContainer.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
}
private void commonSetup(FMLCommonSetupEvent event) {
// Some common setup code
LOGGER.info("HELLO FROM COMMON SETUP");
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());
Config.ITEM_STRINGS.get().forEach((item) -> LOGGER.info("ITEM >> {}", item));
// hello
LOGGER.info("HELLO FROM STOPCHEAT");
}
// Add the example block item to the building blocks tab
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) {
// Do something when the server starts
LOGGER.info("HELLO from server starting");
}
}