-
Notifications
You must be signed in to change notification settings - Fork 10
filesize and fileformat of generated files #2
Comments
I can't test right now, but does this happen if you
Weird. Could you set your launcher to reopen when the game closes and see if there are any warnings or errors in the log? I am still trying ti maintain this library, it's a bit behind in terms of the new entities and such but most things should work. I'll look into your issues when I have time, I can't really think why they would happen. |
Actually another thing to note here is the javadoc on Region.WriteChunk:
Not sure if this comes into play here or not. |
Short summary: I used the lib in the wrong way, now it works like a charm and both problems are solved :) I forgot to mention that the target file in my first post does not exist. Reading your comments I reconsidered my code and came to the solution you can see below. Thank you very much for your fast help :) import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import mcmodify.nbt.minecraft.Chunk;
import mcmodify.nbt.minecraft.IDs;
import mcmodify.nbt.minecraft.Region;
public class MinimalExample4
{
public static void main(String[] args)
{
try
{
//Region region = new Region(new File("flatworld_master_r.0.0.mca"));
String filename = "r.0.0.mca";
//===================================================
//the missing line that solved both problems
copyFile("flatworld_master_r.0.0.mca",filename);
//===================================================
Region newregion = new Region(new File(filename));
for (int x = 0; x < 32; x++)
{
for (int y = 0; y < 32; y++)
{
Chunk chunk = newregion.ReadChunk(x, y);
for (int k = 0; k < 16; k++)
{
for (int k2 = 0; k2 < 16; k2++)
{
chunk.BlockID(k, 0, k2, IDs.Bedrock);
chunk.BlockID(k, 1, k2, IDs.Grass);
}
}
newregion.WriteChunk(x, y, chunk);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void copyFile(String sourceName, String targetName) throws IOException
{
File sourceFile = new File(sourceName);
File destFile = new File(targetName);
if (!destFile.exists())
{
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try
{
source = new RandomAccessFile(sourceFile, "rw").getChannel();
destination = new RandomAccessFile(destFile, "rw").getChannel();
long position = 0;
long count = source.size();
source.transferTo(position, count, destination);
}
finally
{
if (source != null)
{
source.close();
}
if (destination != null)
{
destination.close();
}
}
}
} |
Ah, I don't remember how well creating new regions from scratch works. I'll have to look into that. Glad you got it to work for you! |
I managed to get this library working with my worldgenerator but there are two things that bother me:
This is how I produced the "not so good" regionfile:
flatworld_master_r.0.0.mca.zip
The masterfile can be rendered but the generated one not.
As a footnote:
I really apreciate your work with this library, it is easy to use and saved me from being forced to create something similar on my own :)
The worlds i am creating are very huge (mostly 20kmx20km and bigger) and that is why it is essential for me to have regionfiles that are not bigger than necessary and a map to navigate fast on these worlds.
This is the code example which I used to generate the second file:
The text was updated successfully, but these errors were encountered: