Posted August 25, 20205 yr 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 August 25, 20205 yr by PulseBeat_02
August 27, 20205 yr Author Ah. Thank you for the event. I was thinking of if there was more specific events, such as something like onWorldCreate, onWorldLoad, onExitWorld, something like that.
August 28, 20205 yr Author 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 August 29, 20205 yr by PulseBeat_02 Included code
August 29, 20205 yr Author 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 August 29, 20205 yr by PulseBeat_02
August 29, 20205 yr Author That makes way more sense now. I was a bit confused originally because that method return an array of worlds, and I wouldn't know which world that would be currently loading in. Ah. Thank you for your 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.