Posted July 24, 20178 yr I'm toying with adding a dimension to my mod. I'd like the dimension to be from an existing limited map, no seed/generation rules needed. Picture a sky island, for example. Before I start writing a custom IWorldGenerator to solve this, I thought there might be a solution, or a way to simplify the process. One thought I had was to use a structure_block, maybe subclassed to bypass the 32x32x32 limit. Thanks in advance. 0d
December 27, 20186 yr I just tried doing that, but instead got stuck in a unreal dimension with not any sun or moon, while being console-spammed of that: [File IO Thread/ERROR] [minecraft/AnvilChunkLoader]: Failed to save chunk Escaping the dimension and re-entering it results in a complete blank world. Here's the line for getSaveFolder: @Override public String getSaveFolder() { return Reference.MODID + ":worlds/wol"; } Here's the entire dimension file and the world folder. Edited December 27, 20186 yr by Hugman Precision
December 27, 20186 yr 2 minutes ago, diesieben07 said: You need to return the path to a physical folder on disk, not a resource location. Then it must be assets\mubble\worlds\wol?
December 27, 20186 yr So I must copy the dimension worlds files to a temporary location in, for example, .minecraft/mubble/worlds, and then I must copy those files to the world file?
December 27, 20186 yr I've done this FileMover class: public class FileMover { public static Path createTempDirectory(Path dir, String prefix, FileAttribute<?>... attrs) throws IOException { return dir; } } But then? How do I get the path to the world file itself, at dir in FileMover.createTempDirectory(dir, prefix, attrs);?
December 27, 20186 yr Oh okay, misunderstood, got it now. But still, how may I find the world file and put it as dir in Files.createTempDirectory(dir, prefix, attrs);?
December 27, 20186 yr Yes, but I want this directory to be the dimension folder that is directly put into the world folder itself.
December 27, 20186 yr On 12/27/2018 at 7:10 PM, diesieben07 said: What? What "world folder"? .minecraft\saves\<world> So I can put the dimension world directory in .minecraft\saves\<world>\DIM64 (as my dimension's ID is 64) Edited December 28, 20186 yr by Hugman
December 27, 20186 yr No, I want to have a dimension but it's actually a pre-built map. I want to copy the dimension world files I got in the .jar to the world directory so I can actually load the map.
December 27, 20186 yr Completely editable, changes persists, like a normal dimension, but the base map is already built.
December 28, 20186 yr 19 hours ago, diesieben07 said: Yes, then you have to copy it to the folder before creating the dimension. Then I must copy the files to .minecraft\saves\<world>\DIM64, am I right? Edited December 28, 20186 yr by Hugman
December 29, 20186 yr 11 hours ago, diesieben07 said: That would be the default location, provided your dimension ID is 64 (it should be configurable). Yes, sure, that's what I want. public final class CopyFiles { public static void toWorld(String FROM_s) throws IOException { Path FROM = Paths.get(FROM_s); Path TO = DimensionManager.getCurrentSaveRootDirectory().toPath(); CopyOption[] options = new CopyOption[] { StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES }; Files.copy(FROM, TO, options); } } I've made this class, but now I must get the path to my map in the .jar for the var Path, how can I do this? Edited December 29, 20186 yr by Hugman
December 30, 20186 yr Hey again! I actually progressed very well since yetersday and found a way to do it properly, but I still need to solve an issue. Firstly, here's my new method: public final class CopyFiles { public static void toWorld(String dir, String file, int dim) throws IOException { Path FROM = new File(new ResourceLocation(Reference.MODID + ":worlds/" + dir + "/" + file).getPath()).toPath(); Path TO = new File(DimensionManager.getCurrentSaveRootDirectory(), "DIM-64/" + file).toPath(); CopyOption[] options = new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES }; Files.copy(FROM, TO, options); } } But upon loading the world, the game crashes and reports: java.nio.file.NoSuchFileException: worlds\wol\region\r.0.0.mca which I interpretate as an error with the FROM variable. Anything helping would be very cool, thanks in advance. EDIT: Woops, didn't saw the thread had a second page, currently looking at what you said, this very comment is useless, do like if you didn't saw it. Edited December 30, 20186 yr by Hugman
December 30, 20186 yr Following what you've said,here's my new-new method: public final class CopyFiles { public static void toWorld(String dir, String file, int dim) throws IOException { InputStream FROM = CopyFiles.class.getResourceAsStream("assets/mubble/worlds" + dir + "/" + file); //Path FROM = new File(new ResourceLocation(Reference.MODID + ":worlds/" + dir + "/" + file).getPath()).toPath(); Path TO = new File(DimensionManager.getCurrentSaveRootDirectory(), "DIM-64/" + file).toPath(); CopyOption[] options = new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES }; Files.copy(FROM, TO, options); } } The game crashes, FROM is null. I don't think I understood how to use getResourceAsStream, could you explain please?
December 30, 20186 yr You should use a resource location and look at how vanilla turns them into real paths. You should also use the ResourceLocation constructor that takes a domain and a path, not put it together manually with domain + ":" + path About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
December 31, 20186 yr 9 hours ago, diesieben07 said: https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getResourceAsStream-java.lang.String- So at the end, how the FROM variable will look like? I'm sorry, I still don't really understand from which class I must do the getResourceAsStream neither what to put in it. Also, my region folder is located here: Edited December 31, 20186 yr by Hugman
December 31, 20186 yr Okay so apparently InputStream FROM = CopyFiles.class.getClassLoader().getResourceAsStream("assets/mubble/worlds/" + dir + "/" + file); seems to work, but now the game crashes because the StandardCopyOption.COPY_ATTRIBUTES is not supported, should I just remove it?
December 31, 20186 yr Okay, it works now. For anyone interested, here's my class: public final class MoveFiles { public static void copyToWorld(String dir, String file, int dim) throws IOException { InputStream FROM = MoveFiles.class.getClassLoader().getResourceAsStream("assets/mubble/worlds/" + dir + "/" + file); Path TO = new File(Minecraft.getMinecraft().gameDir + "/saves/" + Minecraft.getMinecraft().getIntegratedServer().getFolderName(), "/DIM" + dim + "/" + file).toPath(); CopyOption[] options = new CopyOption[] { }; Path parentDir = TO.getParent(); if (!Files.exists(parentDir)) Files.createDirectories(parentDir); if (Files.exists(TO)) return; Files.copy(FROM, TO, options); } } Edited December 31, 20186 yr by Hugman
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.