Posted November 11, 20177 yr 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 November 11, 20177 yr by ejer
November 11, 20177 yr Do a bit of reading on variable scope. You can't declare a variable in one method, and have it accessible in another method.
November 11, 20177 yr 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.
November 11, 20177 yr 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 November 11, 20177 yr by Differentiation
November 13, 20177 yr 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)
November 13, 20177 yr 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...
November 13, 20177 yr 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
November 13, 20177 yr The 'tutorial' you're using wants you to put the totalCoins outside of the method. Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
November 13, 20177 yr 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 because "int totalCoins = 0; totalCoins = totalCoins + coins;" is blatantly wrong. Edited November 13, 20177 yr 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.