public void writeWorldData() throws IOException { Map<String, Tag> out = new HashMap<String, Tag>(); File uuidFile = new File(dir, "uid.dat"); if (!uuidFile.exists()) { try { uuidFile.createNewFile(); } catch (IOException e) { handleWorldException("uid.dat", e); } } else { UUID uuid = world.getUID(); DataOutputStream str = new DataOutputStream(new FileOutputStream(uuidFile)); str.writeLong(uuid.getLeastSignificantBits()); str.writeLong(uuid.getMostSignificantBits()); str.close(); } out.putAll(unknownTags); unknownTags.clear(); // Normal level data out.put("thundering", new ByteTag("thundering", (byte) (world.isThundering() ? 1 : 0))); out.put("RandomSeed", new LongTag("RandomSeed", world.getSeed())); out.put("Time", new LongTag("Time", world.getTime())); out.put("raining", new ByteTag("raining", (byte) (world.hasStorm() ? 1 : 0))); out.put("thunderTime", new IntTag("thunderTime", world.getThunderDuration())); out.put("rainTime", new IntTag("rainTime", world.getWeatherDuration())); Location loc = world.getSpawnLocation(); out.put("SpawnX", new IntTag("SpawnX", loc.getBlockX())); out.put("SpawnY", new IntTag("SpawnY", loc.getBlockY())); out.put("SpawnZ", new IntTag("SpawnZ", loc.getBlockZ())); // Format-specific out.put("LevelName", new StringTag("LevelName", world.getName())); out.put("LastPlayed", new LongTag("LastPlayed", Calendar.getInstance().getTimeInMillis())); out.put("version", new IntTag("version", 19132)); if (!out.containsKey("SizeOnDisk")) out.put( "SizeOnDisk", new LongTag("SizeOnDisk", 0)); // Not sure how to calculate this, so ignoring for now try { NBTOutputStream nbtOut = new NBTOutputStream(new FileOutputStream(new File(dir, "level.dat"))); nbtOut.writeTag(new CompoundTag("Data", out)); nbtOut.close(); } catch (IOException e) { handleWorldException("level.dat", e); } }