Jump to content

Custom Zoom Key

Recommended Posts

To make a zoom key, you need to add some event listeners. We can do it this way. Here is the event listener code:

public static void onFovChange(FOVUpdateEvent fovEvent) {
    // Update the original FOV variable
    if(YourMainClass.originalFov != fovEvent.getNewfov() && fovEvent.getNewfov() != YourMainClass.zoomedInFOV)

public static void onKeyPress(KeyboardKeyPressedEvent keyEvent) {
public static void onKeyRelease(KeyboardKeyReleasedEvent keyEvent) {


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



Wait, we also need to register some events. If you are making the SubscribeEvent functions static, you can do it with this:



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 by andrussy44
Make it meet the "tutorial requirements". For example, I used "wee
Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.