feat: 调整

This commit is contained in:
C-H716 2025-09-12 00:53:28 +08:00
parent 9d98324078
commit ac58fc66bd
3 changed files with 22 additions and 17 deletions

View File

@ -1,10 +1,7 @@
package com.extendedae_plus; package com.extendedae_plus;
import appeng.init.client.InitScreens;
import appeng.menu.locator.MenuLocators; import appeng.menu.locator.MenuLocators;
import com.extendedae_plus.ae.menu.EntitySpeedTickerMenu; import com.extendedae_plus.client.ClientRegistrar;
import com.extendedae_plus.ae.screen.EntitySpeedTickerScreen;
import com.extendedae_plus.client.ClientProxy;
import com.extendedae_plus.config.ModConfigs; import com.extendedae_plus.config.ModConfigs;
import com.extendedae_plus.init.*; import com.extendedae_plus.init.*;
import com.extendedae_plus.menu.locator.CuriosItemLocator; import com.extendedae_plus.menu.locator.CuriosItemLocator;
@ -37,7 +34,7 @@ public class ExtendedAEPlus {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
// 在客户端尽早注册内置模型保证首次资源加载前映射已建立仿照 AE2 AppEngClient 构造期注册 // 在客户端尽早注册内置模型保证首次资源加载前映射已建立仿照 AE2 AppEngClient 构造期注册
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> ClientProxy::initBuiltInModels); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> ClientRegistrar::initBuiltInModels);
// 注册mod初始化事件 // 注册mod初始化事件
modEventBus.addListener(this::commonSetup); modEventBus.addListener(this::commonSetup);
@ -57,9 +54,6 @@ public class ExtendedAEPlus {
// 注册通用配置 // 注册通用配置
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ModConfigs.COMMON_SPEC); ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ModConfigs.COMMON_SPEC);
// 客户端侧延迟注册 FMLClientSetupEvent 阶段执行包含 MenuScreens 绑定等
// 由下面的 ClientModEvents 负责在客户端总线上接收事件并委派
} }
/** /**
@ -97,20 +91,19 @@ public class ExtendedAEPlus {
public static void onClientSetup(final FMLClientSetupEvent event) { public static void onClientSetup(final FMLClientSetupEvent event) {
// 直接在此处执行客户端一次性注册UI/屏幕/渲染器绑定 // 直接在此处执行客户端一次性注册UI/屏幕/渲染器绑定
// 注册客户端配置界面 // 注册客户端配置界面
ClientProxy.registerConfigScreen(); ClientRegistrar.registerConfigScreen();
InitScreens.register(ModMenuTypes.ENTITY_TICKER_MENU.get(), // InitScreens 的注册委托给 ClientRegistrar便于集中管理客户端注册逻辑
EntitySpeedTickerScreen<EntitySpeedTickerMenu>::new, ClientRegistrar.registerInitScreens();
"/screens/entity_speed_ticker.json");
// 菜单 -> 屏幕 绑定 // 菜单 -> 屏幕 绑定
ClientProxy.registerMenuScreens(); ClientRegistrar.registerMenuScreens();
} }
@SubscribeEvent @SubscribeEvent
public static void onRegisterGeometryLoaders(final ModelEvent.RegisterGeometryLoaders evt) { public static void onRegisterGeometryLoaders(final ModelEvent.RegisterGeometryLoaders evt) {
try { try {
ClientProxy.initBuiltInModels(); ClientRegistrar.initBuiltInModels();
// 注册 AE2 部件模型例如 entity_ticker_part_item仿照 CrazyAddons 的做法 // 注册 AE2 部件模型例如 entity_ticker_part_item仿照 CrazyAddons 的做法
ModItems.registerPartModels(); ModItems.registerPartModels();
} catch (Exception ignored) {} } catch (Exception ignored) {}

View File

@ -22,6 +22,6 @@ public final class ClientModelEvents {
event.register(ExtendedAEPlus.id("block/crafting/64x_accelerator_formed_v2")); event.register(ExtendedAEPlus.id("block/crafting/64x_accelerator_formed_v2"));
event.register(ExtendedAEPlus.id("block/crafting/256x_accelerator_formed_v2")); event.register(ExtendedAEPlus.id("block/crafting/256x_accelerator_formed_v2"));
event.register(ExtendedAEPlus.id("block/crafting/1024x_accelerator_formed_v2")); event.register(ExtendedAEPlus.id("block/crafting/1024x_accelerator_formed_v2"));
ClientProxy.initBuiltInModels(); ClientRegistrar.initBuiltInModels();
} }
} }

View File

@ -1,7 +1,10 @@
package com.extendedae_plus.client; package com.extendedae_plus.client;
import appeng.client.render.crafting.CraftingCubeModel; import appeng.client.render.crafting.CraftingCubeModel;
import appeng.init.client.InitScreens;
import com.extendedae_plus.ExtendedAEPlus; import com.extendedae_plus.ExtendedAEPlus;
import com.extendedae_plus.ae.menu.EntitySpeedTickerMenu;
import com.extendedae_plus.ae.screen.EntitySpeedTickerScreen;
import com.extendedae_plus.client.render.crafting.EPlusCraftingCubeModelProvider; import com.extendedae_plus.client.render.crafting.EPlusCraftingCubeModelProvider;
import com.extendedae_plus.client.screen.GlobalProviderModesScreen; import com.extendedae_plus.client.screen.GlobalProviderModesScreen;
import com.extendedae_plus.content.crafting.EPlusCraftingUnitType; import com.extendedae_plus.content.crafting.EPlusCraftingUnitType;
@ -14,8 +17,8 @@ import net.minecraftforge.fml.ModLoadingContext;
/** /**
* 客户端模型注册 formed 模型注册为内置模型 * 客户端模型注册 formed 模型注册为内置模型
*/ */
public final class ClientProxy { public final class ClientRegistrar {
private ClientProxy() {} private ClientRegistrar() {}
private static boolean REGISTERED = false; private static boolean REGISTERED = false;
@ -54,6 +57,15 @@ public final class ClientProxy {
MenuScreens.register(ModMenuTypes.NETWORK_PATTERN_CONTROLLER.get(), GlobalProviderModesScreen::new); MenuScreens.register(ModMenuTypes.NETWORK_PATTERN_CONTROLLER.get(), GlobalProviderModesScreen::new);
} }
/**
* 注册由 AE2 InitScreens 所需的屏幕资源映射用于内置 JSON 屏幕注册
*/
public static void registerInitScreens() {
InitScreens.register(ModMenuTypes.ENTITY_TICKER_MENU.get(),
EntitySpeedTickerScreen<EntitySpeedTickerMenu>::new,
"/screens/entity_speed_ticker.json");
}
/** /**
* 仅客户端 Mods 菜单注册配置界面入口 * 仅客户端 Mods 菜单注册配置界面入口
* 将对 Screen 的引用限制在客户端侧避免服务端类加载 * 将对 Screen 的引用限制在客户端侧避免服务端类加载