Jump to content

Recommended Posts

Posted

Assume a player creates a new world.

 

After the world has done its initial generation, either right before the player joins the world or right after, I want to execute my arbitrary code.

 

Let's say print "Hello World" once to the console.

 

How would I go about doing this?

 

Client side only, don't care about server.

 

 

Posted

Understood, thank you!

 

Let me readjust my question in that case :)

 

I would like to execute arbitrary code once the world gen has finished, ie "Hello world".

Posted (edited)

it's hard to answer without knowing what you need, but maybe you are yet to determine what you need...

 

try this: respond to "join world" event; if the entity that fired event is a player, do your stuff and leave a simple signature in player's extra data (nbt). check for that signature at the start of "join world" event handler and don't do anything if it's not the first time for player to join.

things to note: 1) the event mentioned above fires for every player on the server instance and on any number of client instances. you may want to check whether world is remote (meaning client).  2) your signature (if it's a nbt string) needs to be below "persisted_nbt_tag" so that you wouldn't need to handle player "clone" event and copy the signature (i haven't checked whether that's still a thing in 1.15, but i'm willing to bet it is).

 

give it a try. if it's too early for you, there are ways of delaying things for a few seconds...

Edited by MFMods

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.