Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by andrussy44
Make it meet the "tutorial requirements". For example, I used "wee

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.