Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Pregenerator #121

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

Cardinalstars
Copy link

More work will eventually be needed to make it better, but this works to generate a circle for now.

Will want to make a GUI to select the areas specifically and add a square generation area.

@Dream-Master Dream-Master requested review from Lyfts and a team October 3, 2024 08:18

public PregeneratorFileManager(MinecraftServer server, double xLoc, double zLoc, int radius, int dimensionID)
throws IOException {
Path temporaryFileSaveFolder = Paths.get("saves").resolve(getWorldFolderPath(server).resolve(COMMAND_FOLDER));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if the temp files are made in some subfolder of the serverutilities folder, if they're in the world folder and backups are running then all of the temp files will be zipped up.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I'll be sure to move those over. Just had it there for the moment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if the temp files are made in some subfolder of the serverutilities folder, if they're in the world folder and backups are running then all of the temp files will be zipped up.

So for pregeneration PR I have made, you mentioned you prefered to have the temp files in the server utilties folder. I think I'll need to make a separate folder in the serverutilties/server folder for each world. For servers this isn't an issue because there's only one world, but for clients that have multiple saves this would be an issue. So I can put it in the serverutilties/server/saves folder and have a folder for each save if you want. I don't know what's best so I thought I'd ask you.

Also, is having it in each backup not fine? If you're doing a pregen and you have to load the backup, you will still need to finish the pregen. Not sure on this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really mind it being in the world folder that much, but right now it's only in there in SP. Servers don't have a saves folder.

Copy link
Member

@Lyfts Lyfts Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want it in the world folder you can use DimensionManager.getCurrentSaveRootDirectory() to get the actual root folder.

You can also use World.getSaveHandler().getWorldDirectory() if you want it in the dim folder

src/main/resources/assets/serverutilities/lang/en_US.lang Outdated Show resolved Hide resolved
@Lyfts
Copy link
Member

Lyfts commented Oct 3, 2024

This is using impressively little ram to the point that there is definitely some wiggle room if you ever wanted it to go faster.

@chochem chochem added the ongoing freeze - do not merge Not just a bug fix and thus affected by a current freeze for a upcoming version label Oct 3, 2024
@Cardinalstars
Copy link
Author

Cardinalstars commented Oct 6, 2024

This is using impressively little ram to the point that there is definitely some wiggle room if you ever wanted it to go faster.

Weird things start happening when I up to 2 chunks per tick. I can do something like 2 chunks every other tick. Most testing will be required before I'm happy upping the speed. I can maybe add a config for how fast? It really might just depend on your system speed.

@StoneLegion
Copy link

IDK how hard it is, but all the in game generators have sucked tbh. They always miss something like lighting checks fluids movement, witchery walls around towns, etc.

The best one I found just rcon teleport the player around. That being said I wish that was just in game with SU doing the same idea without needing to use a tool. It be better at keeping track the player / position and such as well in case something derps up, etc.

@Dream-Master Dream-Master requested a review from a team November 28, 2024 18:09
this.fileManager = fileManager;
}

public void processLoadChunk(MinecraftServer server, int dimensionId, Long chunk) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be a primitive long

decisionTracker += 2 * (z - x) + 1;
}
}
System.out.printf("Found %s chunks to load", chunksToLoad.size());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be replaced with a proper logger


public PregeneratorFileManager(MinecraftServer server, double xLoc, double zLoc, int radius, int dimensionID)
throws IOException {
Path temporaryFileSaveFolder = Paths.get("saves").resolve(getWorldFolderPath(server).resolve(COMMAND_FOLDER));
Copy link
Member

@Lyfts Lyfts Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want it in the world folder you can use DimensionManager.getCurrentSaveRootDirectory() to get the actual root folder.

You can also use World.getSaveHandler().getWorldDirectory() if you want it in the dim folder

Comment on lines +92 to +96
if (sender instanceof MinecraftServer) {
return "commands." + ICommandWithParent.getCommandPath(this) + ".usage_server";
}

return "commands." + ICommandWithParent.getCommandPath(this) + ".usage_client";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lang keys don't actually exist in the lang file

@Lyfts
Copy link
Member

Lyfts commented Dec 2, 2024

[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: java.nio.file.FileSystemException: saves\New World-------------------\pregenerationFiles\fileIteration.tmp -> saves\New World-------------------\pregenerationFiles\fileIteration: The process cannot access the file because it is being used by another process
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:328)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:291)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at java.base/java.nio.file.Files.move(Files.java:1430)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//serverutils.pregenerator.filemanager.readwriters.SafeFileReadWriter.commit(SafeFileReadWriter.java:51)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//serverutils.pregenerator.filemanager.readwriters.SafeFileReadWriter.writeAndCommitIntAfterIterations(SafeFileReadWriter.java:30)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//serverutils.pregenerator.filemanager.PregeneratorFileManager.saveIteration(PregeneratorFileManager.java:68)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//serverutils.pregenerator.ChunkLoader.lambda$processLoadChunk$0(ChunkLoader.java:28)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraftforge.common.chunkio.ChunkIOProvider.callStage3(ChunkIOProvider.java:56)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraftforge.common.chunkio.ChunkIOProvider.callStage3(ChunkIOProvider.java:12)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraftforge.common.util.AsynchronousExecutor$Task.finish(AsynchronousExecutor.java:196)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraftforge.common.util.AsynchronousExecutor.finishActive(AsynchronousExecutor.java:354)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraftforge.common.chunkio.ChunkIOExecutor.tick(ChunkIOExecutor.java:30)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:663)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
[17:08:14] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:787]: 	at Launch//net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
[17:08:14] [Server thread/ERROR] [FML]: Exception caught during firing event cpw.mods.fml.common.gameevent.TickEvent$ServerTickEvent@2fb6e890:
java.lang.IndexOutOfBoundsException: Index (27648) is greater than or equal to list size (27648)
	at Launch//it.unimi.dsi.fastutil.longs.LongArrayList.getLong(LongArrayList.java:341) ~[LongArrayList.class:?]
	at Launch//serverutils.pregenerator.ChunkLoaderManager.queueChunks(ChunkLoaderManager.java:156) ~[ChunkLoaderManager.class:?]
	at Launch//serverutils.handlers.ServerUtilitiesServerEventHandler.onServerTick(ServerUtilitiesServerEventHandler.java:240) ~[ServerUtilitiesServerEventHandler.class:?]
	at cpw.mods.fml.common.eventhandler.ASMEventHandler_25_ServerUtilitiesServerEventHandler_onServerTick_ServerTickEvent.invoke(.dynamic) ~[?:?]
	at Launch//cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?]
	at Launch//cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
	at Launch//cpw.mods.fml.common.FMLCommonHandler.onPostServerTick(FMLCommonHandler.java:247) [FMLCommonHandler.class:?]
	at Launch//net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:657) [MinecraftServer.class:?]
	at Launch//net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?]
	at Launch//net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
	at Launch//net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]

crash-2024-12-02_17.08.14-server.txt
fml-client-3.log

I crashed when reloading a world that had a pregen running. It seems to happen consistently in SP if you exit to main menu and reload the world.

@Lyfts
Copy link
Member

Lyfts commented Dec 2, 2024

You can also simplify the chunk queuing a bit by using a LongArrayFIFOQueue aecaf5b

This both fixes the crash and provides an early return so that it won't find 500k chunks to load if only 10k of those still need to be loaded.

@Dream-Master Dream-Master removed the ongoing freeze - do not merge Not just a bug fix and thus affected by a current freeze for a upcoming version label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants