Posted May 7, 20232 yr public class ClientEvents { @Mod.EventBusSubscriber(modid = Mymod.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.FORGE) public static class ClientForgeEvents{ @SubscribeEvent // Event is on the Forge event bus only on the physical client public void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.END) { // Only call code once as the tick event is called twice every tick while (KeyBinding.SET_ITEM_KEY.consumeClick()) { // Execute logic to perform on click here Minecraft.getInstance().player.sendSystemMessage(Component.literal("Key is pressed!")); } } } } @Mod.EventBusSubscriber(modid = Mymod.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) public static class ClientModEvents{ @SubscribeEvent public static void onKeyRegister(RegisterKeyMappingsEvent event){ event.register(KeyBinding.SET_ITEM_KEY); } @SubscribeEvent public void gatherData(GatherDataEvent event) { } } } Nothing appends when I press the key I set. I followed the forge docs. Did I make mistakes? Help needed. THANK YOU!
May 7, 20232 yr Quote public static class ClientForgeEvents{ @SubscribeEvent // Event is on the Forge event bus only on the physical client - public void onClientTick(TickEvent.ClientTickEvent event) { + public static void onClientTick(TickEvent.ClientTickEvent event) { https://forge.gemwire.uk/wiki/Events#/media/File:Guide_to_Event_Handlers.png Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
May 9, 20232 yr Just use KeyInputEvent and if you have server side logic just send a packet to server.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.