| 1 | package net.minecraft.world.chunk.storage;
|
| 2 |
|
| 3 | import java.io.File;
|
| 4 | import net.minecraft.nbt.NBTTagCompound;
|
| 5 | import net.minecraft.world.WorldProvider;
|
| 6 | import net.minecraft.world.WorldProviderEnd;
|
| 7 | import net.minecraft.world.WorldProviderHell;
|
| 8 | import net.minecraft.world.storage.SaveHandler;
|
| 9 | import net.minecraft.world.storage.ThreadedFileIOBase;
|
| 10 | import net.minecraft.world.storage.WorldInfo;
|
| 11 |
|
| 12 | public class AnvilSaveHandler extends SaveHandler
|
| 13 | {
|
| 14 | public AnvilSaveHandler(File savesDirectory, String directoryName, boolean storePlayerdata)
|
| 15 | {
|
| 16 | super(savesDirectory, directoryName, storePlayerdata);
|
| 17 | }
|
| 18 |
|
| 19 | /**
|
| 20 | * initializes and returns the chunk loader for the specified world provider
|
| 21 | */
|
| 22 | public IChunkLoader getChunkLoader(WorldProvider provider)
|
| 23 | {
|
| 24 | File file1 = this.getWorldDirectory();
|
| 25 |
|
| 26 | if (provider instanceof WorldProviderHell)
|
| 27 | {
|
| 28 | File file3 = new File(file1, "DIM-1");
|
| 29 | file3.mkdirs();
|
| 30 | return new AnvilChunkLoader(file3);
|
| 31 | }
|
| 32 | else if (provider instanceof WorldProviderEnd)
|
| 33 | {
|
| 34 | File file2 = new File(file1, "DIM1");
|
| 35 | file2.mkdirs();
|
| 36 | return new AnvilChunkLoader(file2);
|
| 37 | }
|
| 38 | else
|
| 39 | {
|
| 40 | return new AnvilChunkLoader(file1);
|
| 41 | }
|
| 42 | }
|
| 43 |
|
| 44 | /**
|
| 45 | * Saves the given World Info with the given NBTTagCompound as the Player.
|
| 46 | */
|
| 47 | public void saveWorldInfoWithPlayer(WorldInfo worldInformation, NBTTagCompound tagCompound)
|
| 48 | {
|
| 49 | worldInformation.setSaveVersion(19133);
|
| 50 | super.saveWorldInfoWithPlayer(worldInformation, tagCompound);
|
| 51 | }
|
| 52 |
|
| 53 | /**
|
| 54 | * Called to flush all changes to disk, waiting for them to complete.
|
| 55 | */
|
| 56 | public void flush()
|
| 57 | {
|
| 58 | try
|
| 59 | {
|
| 60 | ThreadedFileIOBase.getThreadedIOInstance().waitForFinish();
|
| 61 | }
|
| 62 | catch (InterruptedException interruptedexception)
|
| 63 | {
|
| 64 | interruptedexception.printStackTrace();
|
| 65 | }
|
| 66 |
|
| 67 | RegionFileCache.clearRegionFileReferences();
|
| 68 | }
|
| 69 | }
|
| 70 |
|