Posted January 17, 201510 yr Hello everyone so i just created a version checker for my own mod. and somehow i register it in my main class and it works(using system print) but one thing i wanna know is how do i make a chat message referring to the newversion. like on player login Me code anyway thankyou package mhfc.heltrato.common.helper.system; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; public class HentaiVersionHelper { public static String urlString; public static String versionString; public static String newVersionStr; public static int newUpdate = 2; public static int noUpdate = 1; public static int offline = 0; public static void init(String url, String version) { urlString = url; versionString = version; } public static int isUpdateAvailable() { try { BufferedReader versionFile = new BufferedReader(new InputStreamReader(new URL(urlString).openStream())); String curVersion = versionFile.readLine(); newVersionStr = curVersion; versionFile.close(); if (!curVersion.equals(versionString)) { return newUpdate; } else { return noUpdate; } } catch(Exception e) { return offline; } } }
January 17, 201510 yr "Hentai" - Dat Mod I am guessing you are executing this class in preInit? There are 3 ways: 1. Subscribe to PlayerLoggedInEvent. - This even is only fired by Server thread. - Send packet that tells player to display his LOCAL version. 2. Subscribe to PlayerLoggedInEvent. - This even is only fired by Server thread. - Send ChatComponent containing mod version this Server thread is running on (you know, client must have same version as server, so it's right to assume that client will have same as server). Note: doesn't matter is you are SP or MP. 3. Do everything on Client thread: - Subscribe to EntityJoinedWorld and make it run only Client side (world.isRemote) - Check if entity == mc.thePlayer (your player entity) - Print ChatComonent client-side. #3rd one is best. 1.7.10 is no longer supported by forge, you are on your own.
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.