Posted April 3, 20214 yr To make a zoom key, you need to add some event listeners. We can do it this way. Here is the event listener code: @SubscribeEvent public static void onFovChange(FOVUpdateEvent fovEvent) { // Update the original FOV variable if(YourMainClass.originalFov != fovEvent.getNewfov() && fovEvent.getNewfov() != YourMainClass.zoomedInFOV) YourMainClass.originalFov=fovEvent.getNewfov(); } @SubscribeEvent public static void onKeyPress(KeyboardKeyPressedEvent keyEvent) { if(keyEvent.getKeyCode()==YourMainClass.zoomKeyCode) YourMainClass.mc.gameSettings.fov=YourMainClass.zoomedInFOV; } @SubscribeEvent public static void onKeyRelease(KeyboardKeyReleasedEvent keyEvent) { if(keyEvent.getKeyCode()==YourMainClass.zoomKeyCode) YourMainClass.mc.gameSettings.fov=YourMainClass.originalFov; } Now we need to define some variables in our main class. This is the code: public static Minecraft mc=Minecraft.getInstance(); public final static int zoomKeyCode=GLFW.GLFW_KEY_(key here); public final static int zoomedInFOV=40; // The next line of code goes in the FMLCommonSetupEvent event function originalFov=mcInstance.gameSettings.fov; Wait, we also need to register some events. If you are making the SubscribeEvent functions static, you can do it with this: MinecraftForge.EVENT_BUS.register(YourEventListener.class) If you are making the SubscribeEvent functions non-static, you can do it with this: MinecraftForge.EVENT_BUS.register(new YourEventListener()) There we go! This is a custom zoom key. Edited April 14, 20214 yr by andrussy44 Make it meet the "tutorial requirements". For example, I used "wee
April 3, 20214 yr 1. This is problematic for sidedness. 2. Minecraft uses GLFW keybindings, not AWT KeyEvent. Use a KeyBinding regardless. 3. This is not a tutorial. Nothing is explained, just copy this and get a result.
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.