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

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;
	}
	}
}



"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.

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.