Jump to content

Recommended Posts

Posted

I have a need in one of my mods to regenerate a world automatically.  This could be while running or on a server restart.  I could make either work.

 

 

I've done a lot of searching and I can't figure out how to do this.  Any advice?

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

That is an idea.  I would have to figure out where the folder is at from the code and then deleting it if nobody is in it, should be easy.  It would regen the next time entered.

 

Any idea how to get the location of the world folders?

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

I searched through the code and I'm having trouble finding where the hardcore mode locks or deletes a world.

 

Anyone found it before?

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

I searched through the code and I'm having trouble finding where the hardcore mode locks or deletes a world.

 

Anyone found it before?

 

To get the world's save directory (the folder where the level.dat is in), use this:

worldObj.getSaveHandler().getWorldDirectory()

 

It returns a File instance.

Append the dimension folder name upon that. To get the name of the dimension (if you're uncertain what the name is, if you wanna delete a dimension from a mod or whatever), use this:

this.worldObj.provider.getSaveFolder()

Please note that this can return null, when it's the Overworld.

 

Also I strongly recommend to check if a player is in the dimension, and only delete it if it's not the case.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

I'll do that. 

 

I already have the code build trolling for players in dimensions that would cause problems.  I search offline players to move them to a safe dimension if the dimension no longer exists, ect.  This would be simpler since just need to look for live players.

 

Thanks for the help.  I'll work on it tonight and post how it went.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

That worked. 

 

The problem now is determining if the Enderdragon exists.  Easy to do if the relevant chunk is loaded, not sure how to if not.

 

I could just check for a player to be present, do a scan to see if dragon is alive, then delete the world when it is devoid of players (probably best on next reboot).  This could cause issues if player isn't near enough to load the chunk.  Unlikely, but someone could have built a walkway.

 

Anyone know of a way to determine if the Enderdragon is there without its chunk being loaded?

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

I'll try it, but I think it is the same issue.  Needs to be loaded.

Long time Bukkit & Forge Programmer

Happy to try and help

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.