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 guys

So, I try to notice whenever a day ends.

Is there an event for that? (guess no)

Or is there an event that gets called whenever the time gets set to something new or anything reliable like that?

Thanks for help

  • Author

Uhm,

	@SubscribeEvent
public void onTick(TickEvent event)
{
	System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
}

isnt doing anything (other events are working)

And how can i get the world from TickEvent?

Why....

You can just calculate it by using the world time.

IIRC 24000 ticks is a minecraft day, so just get the world time, do a little math and you have the day count.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

So, when a day ends at 2400, doesnt it get set to 0 again? cuz thats what i thought it does, or does it just continue with 2401? But anyway I would get into trouble when you use "/time set day" since then I would be at day 1 again

It continues on.

As for time being changed by /time set, you have to allocate for that in your time comparison.

When it changes, you're pretty much screwed anyway for getting real numbers, so you just have to deal.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

Ok, that solves my 1st Problem, but i still need a reliable event thats getting called once a minute or more often  ::)

How about?

 

@SubscribeEvent
public void onTickEvent(WorldTickEvent event)
{
	// Overworld only
	if(event.world.provider.dimensionId != 0)
	{
		return;
	}

	// What time is it?
	long worldTime = event.world.getWorldTime();

	// 24000 ticks is one minecraft day
	if(worldTime%24000 != 0)
	{
		return;
	}

	// Do something
}

 

The event is https://docs.larry1123.net/forge/1060/cpw/mods/fml/common/gameevent/TickEvent.WorldTickEvent.html

 

You need to register FMLCommonHandler.instance().bus().register(new yourClass());

  • Author

You need to register FMLCommonHandler.instance().bus().register(new yourClass());

Alright, got the problem I was using this:

MinecraftForge.EVENT_BUS.register(new yourClass());

Now its actually working, thanks a lot :)

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.