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

Hey, I'm wondering how I get the actual time (in 12 hour time) like the clock, but text instead of a texture.

 

 

For example, ingame the sun would just be rising, so it would be 7:00AM

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

  • Author

I've currently got this:

protected String getTime() {
String time = "";
        for (int j = 0; j < MinecraftServer.getServer().worldServers.length; j++) {
            time = StringUtils.ticksToElapsedTime((int)(MinecraftServer.getServer().worldServers[j].getWorldTime()));
        }
        return time;
    }

 

Which is giving me this:

http://prntscr.com/3fo3mv

 

It seems to work well, but it isnt all that accurate. I type: "/time set 23000" which makes it 6:00AM (according to the MC wiki) but it says its 19:10

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

  • Author

Never mind!! I fixed it using this:

 

public void renderTick() {
	Minecraft mc = Minecraft.getMinecraft();
	if(mc.currentScreen instanceof GuiChat) {
		GuiIngame gig = mc.ingameGUI;
		FontRenderer f = mc.fontRenderer;
		ScaledResolution s = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);;
		int h = s.getScaledHeight();
		int w = s.getScaledWidth();
		Long time = Long.valueOf(mc.theWorld.provider.getWorldTime());
		String t = "TIME: " + formatTime(time);
		gig.drawString(f, t, w - f.getStringWidth(t) - 10, h - 20, 16777215);
	}
}

protected String getTime() {
	String time = "";
	for (int j = 0; j < MinecraftServer.getServer().worldServers.length; j++) {
		time = StringUtils.ticksToElapsedTime((int)(MinecraftServer.getServer().worldServers[j].getWorldTime()));
	}
	return time;
}

public static String formatTime(Long time) {
	int hours24 = (int)(time.longValue() / 1000L + 6L) % 24;
	int hours = hours24 % 12;
	int minutes = (int)((float)time.longValue() / 16.666666F % 60.0F);

	String Time = String.format("%02d:%02d %s", new Object[] { Integer.valueOf(hours < 1 ? 12 : hours), Integer.valueOf(minutes), hours24 < 12 ? "AM" : "PM" });
	return Time;
}

 

Took me a while, but i got it! :D

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

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.