按键注册改用构造函数注册
This commit is contained in:
parent
de9ee53640
commit
f382cd848c
|
|
@ -1,7 +1,9 @@
|
|||
package com.extendedae_plus;
|
||||
|
||||
import com.extendedae_plus.client.ModKeybindings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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;
|
||||
|
|
@ -11,25 +13,25 @@ import net.neoforged.neoforge.client.gui.ConfigurationScreen;
|
|||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
import net.neoforged.fml.ModList;
|
||||
|
||||
// This class will not load on dedicated servers. Accessing client side code from here is safe.
|
||||
@Mod(value = ExtendedAEPlus.MODID, dist = Dist.CLIENT)
|
||||
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
|
||||
@EventBusSubscriber(modid = ExtendedAEPlus.MODID, value = Dist.CLIENT)
|
||||
public class ExtendedAEPlusClient {
|
||||
public ExtendedAEPlusClient(ModContainer container) {
|
||||
// Allows NeoForge to create a config screen for this mod's configs.
|
||||
// The config screen is accessed by going to the Mods screen > clicking on your mod > clicking on config.
|
||||
// Do not forget to add translations for your config options to the en_us.json file.
|
||||
public ExtendedAEPlusClient(ModContainer container, IEventBus modEventBus) {
|
||||
|
||||
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
|
||||
|
||||
// 注册按键绑定
|
||||
modEventBus.addListener((net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent event) -> {
|
||||
event.register(ModKeybindings.CREATE_PATTERN_KEY);
|
||||
event.register(ModKeybindings.FILL_SEARCH_KEY);
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
static void onClientSetup(FMLClientSetupEvent event) {
|
||||
// Some client setup code
|
||||
ExtendedAEPlus.LOGGER.info("HELLO FROM CLIENT SETUP");
|
||||
ExtendedAEPlus.LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
|
||||
|
||||
// Register JEI-dependent input handlers only when JEI is present
|
||||
if (ModList.get().isLoaded("jei")) {
|
||||
try {
|
||||
Class<?> bootstrap = Class.forName("com.extendedae_plus.integration.jei.JeiClientBootstrap");
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@ package com.extendedae_plus.client;
|
|||
import com.extendedae_plus.ExtendedAEPlus;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.neoforged.neoforge.client.settings.KeyConflictContext;
|
||||
import net.neoforged.neoforge.client.settings.KeyModifier;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
|
@ -14,7 +10,6 @@ import org.lwjgl.glfw.GLFW;
|
|||
/**
|
||||
* ExtendedAE Plus 快捷键定义
|
||||
*/
|
||||
@EventBusSubscriber(modid = ExtendedAEPlus.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public final class ModKeybindings {
|
||||
private ModKeybindings() {
|
||||
}
|
||||
|
|
@ -41,11 +36,5 @@ public final class ModKeybindings {
|
|||
GLFW.GLFW_KEY_F,
|
||||
"key.categories.extendedae_plus"
|
||||
);
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegisterKeyMappingsEvent event) {
|
||||
event.register(CREATE_PATTERN_KEY);
|
||||
event.register(FILL_SEARCH_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user