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
public class Coins {
    @SubscribeEvent
    public void xd(ClientChatReceivedEvent event) {
        String message = event.message.getUnformattedText();
        //message is the message which the client receives.
        if(message.startsWith("+") && message.contains("coins") && !message.endsWith("for being generous")) {
            //Checks if the coin message you got isn't the tip message   
            String[] splittedMessage = message.split("coins");
            message = splittedMessage[0].replace("+", "");
            message = message.replace(" ", "");
            int coins = Integer.parseInt(message);
            int totalCoins = 0;
            totalCoins = totalCoins + coins;
        }
    }
    @SubscribeEvent
    public void render(RenderGameOverlayEvent event) {
        if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {
            return;
        }
        FontRenderer fRender = Minecraft.getMinecraft().fontRendererObj;
        fRender.drawString(EnumChatFormatting.GREEN + "Coins: " + EnumChatFormatting.WHITE + totalCoins, 5, 5, 0);
    }
}

totalCoins = totalCoins + coins;

totalCoins cannot be resolved to a variable

 

fRender.drawString(EnumChatFormatting.GREEN + "Coins: " + EnumChatFormatting.WHITE + totalCoins, 5, 5, 0);

totalCoins cannot be resolved to a variable

Edited by ejer

            int totalCoins = 0;
            totalCoins = totalCoins + coins;

Wot

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

10 hours ago, ejer said:

totalCoins = totalCoins + coins;

wtf is this?

Do you even know how to handle variables? Where did you get this code from?

Again, you should learn some basic Java before starting your project.

Edited by Differentiation

  • Author
On 11.11.2017 at 8:43 PM, Differentiation said:

wtf is this?

Do you even know how to handle variables? Where did you get this code from?

Again, you should learn some basic Java before starting your project.

lol idk its not my project its from a forum post i just wanted to know whats wrong ;p

https://hypixel.net/threads/guide-start-coding-minecraft-forge-mods.551741/

(scroll down to the very bottom of the first post)

  • Author
On 11.11.2017 at 0:31 PM, Ugdhar said:

Do a bit of reading on variable scope.

You can't declare a variable in one method, and have it accessible in another method.

yea i thought of that bc the other method doesnt even know what "total coins" is...

  • Author
On 11.11.2017 at 5:44 PM, Draco18s said:

            int totalCoins = 0;
            totalCoins = totalCoins + coins;

Wot

Wot

ok wait

int totalCoins = 0; is not supose to be there lol i was just messing around with the code to try to make it work xD

5 hours ago, ejer said:

lol idk its not my project its from a forum post i just wanted to know whats wrong ;p

https://hypixel.net/threads/guide-start-coding-minecraft-forge-mods.551741/

(scroll down to the very bottom of the first post)

Hypixel Moderators aren't better than Forge experts in code :P because "int totalCoins = 0;    totalCoins = totalCoins + coins;" is blatantly wrong.

Edited by Differentiation

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.