Jump to content

Recommended Posts

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

Posted

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?

Posted

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

Posted

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

Posted

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

Posted

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());

Posted

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.