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

Hi!

I'm new in Minecraft modding and currently trying to make my first mod.

So, the server sends to players some random numbers from 1 to 7 to their title bar. If there's currently "6" or "7" at the player's screen, the mod should simulate right-clicking at the held thing in the player's hand. I've tried to write some lines of code but the mod does nothing. There are the lines of my code:

public static String getCurrentTitle(FML) {
        try {
            String title = (String) ReflectionHelper.findField(GuiIngame.class, "displayedTitle", "field_175201_x").get(Minecraft.getMinecraft().ingameGUI);
            return title;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

public static void rightClick(World worldIn, EntityPlayer player, EnumHand handIn){
        if (getCurrentTitle() == "7" || getCurrentTitle() == "6") {
            ItemStack I = player.getHeldItem(handIn);
            I.useItemRightClick(worldIn, player, handIn);
        }
    }

The first function I just copypasted from web, the other one I've written by myself. I'm new at this and honestly don't understand how it should be. So I need some help.

The version is 1.12.2 if it makes a difference.

 

Thankfully,

- axyqu.

 

The version you are using is no longer supported on this forum.

Please update to a modern version of Minecraft to receive support.

Currently supported versions are 1.19.2 (Latest) and 1.18.2 (LTS).

Guest
This topic is now closed to further replies.

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.