Jump to content

[1.15.2] Event for Creating Single Player World


PulseBeat_02

Recommended Posts

Hi, I was looking around for an event which would could be used while the user is creating a single player world. (For example, methods with this event would be called when the user is creating a single player world). Does anyone know a possible event which exists? If there isn't an event, please tell me a way to do this without using the event.

Edited by PulseBeat_02
Link to comment
Share on other sites

Ah. I see. Thank you for helping me find what the other events are that I needed to use. That means that if I want to check if a user is creating a fresh world, I would have to make a new class which extends WorldSavedData (which would contain a constructor that would be invoked if the player is creating a new world). Here is my code, (and the method used to determine if a world is newly created is inside the class):
 

import org.kingmammoth.kmcutscenes.KingMammothCutScenes;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.storage.WorldSavedData;
import net.minecraftforge.fml.client.FMLClientHandler;

public class FreshWorldCreation extends WorldSavedData {

	private static final String DATA_NAME = KingMammothCutScenes.MODID + "_CUTSCENEDATA";

	public FreshWorldCreation() {
		super(DATA_NAME);
	}

	@Override
	public void readFromNBT(NBTTagCompound nbt) {

	}

	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound compound) {
		return null;
	}

	public static boolean isFreshlyCreated() {

		FreshWorldCreation instance = (FreshWorldCreation) FMLClientHandler.instance().getWorldClient().getMapStorage()
				.getOrLoadData(FreshWorldCreation.class, DATA_NAME);

		return instance == null ? true : false;

	}

}

 

Is that correct?

Edited by PulseBeat_02
Included code
Link to comment
Share on other sites

3 hours ago, diesieben07 said:

No, you cannot use the client world. The client world does not store data at all.

 

Oh yeah, I forgot lol. If I recall properly, I would need to use the MinecraftServer.getServer().worldServers method (Unless it was changed in the recent versions of forge). This would return an array of all loaded Worlds. I would then change the method to a loop which would run through all of the loaded worlds. 

Edited by PulseBeat_02
Link to comment
Share on other sites

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.