Fix saved data being stored in wrong location.
This commit is contained in:
@@ -70,36 +70,44 @@ public class SaveDataManager {
|
|||||||
if (saveData.isMarkedForSaving()) {
|
if (saveData.isMarkedForSaving()) {
|
||||||
CompoundNBT nbt = new CompoundNBT();
|
CompoundNBT nbt = new CompoundNBT();
|
||||||
saveData.write(nbt);
|
saveData.write(nbt);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writeTagToFile(world, saveData.getName(), nbt);
|
writeTagToFile(world, saveData.getName(), nbt);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Unable to save " + saveData.getName(), e);
|
LOGGER.error("Unable to save " + saveData.getName(), e);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveData.markSaved();
|
saveData.markSaved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File getDataDirectory(ServerWorld world) {
|
||||||
|
return world.getChunkProvider().getSavedData().folder;
|
||||||
|
}
|
||||||
|
|
||||||
private void writeTagToFile(ServerWorld world, String fileName, CompoundNBT nbt) throws IOException {
|
private void writeTagToFile(ServerWorld world, String fileName, CompoundNBT nbt) throws IOException {
|
||||||
String dataDirectory = world.getServer().func_240776_a_(new FolderName("data")).toString();
|
File dataDirectory = getDataDirectory(world);
|
||||||
File backupFile = new File(dataDirectory, fileName + "_backup.dat");
|
File backupFile = new File(dataDirectory, fileName + "_backup.dat");
|
||||||
File file = new File(dataDirectory, fileName + ".dat");
|
File file = new File(dataDirectory, fileName + ".dat");
|
||||||
|
|
||||||
if (backupFile.exists()) {
|
if (backupFile.exists()) {
|
||||||
backupFile.delete();
|
backupFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
CompressedStreamTools.writeCompressed(nbt, new FileOutputStream(backupFile));
|
CompressedStreamTools.writeCompressed(nbt, new FileOutputStream(backupFile));
|
||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
if (!file.delete()) {
|
if (!file.delete()) {
|
||||||
throw new IOException("Cannot delete " + file.getAbsolutePath() + " aborting");
|
throw new IOException("Cannot delete original file " + file.getAbsolutePath() + " to rename the backup file, aborting");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
backupFile.renameTo(file);
|
backupFile.renameTo(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompoundNBT readTagFromFile(ServerWorld world, String fileName) {
|
private CompoundNBT readTagFromFile(ServerWorld world, String fileName) {
|
||||||
String dataDirectory = world.getServer().func_240776_a_(new FolderName("data")).toString();
|
File dataDirectory = getDataDirectory(world);
|
||||||
File backupFile = new File(dataDirectory, fileName + "_backup.dat");
|
File backupFile = new File(dataDirectory, fileName + "_backup.dat");
|
||||||
File file = new File(dataDirectory, fileName + ".dat");
|
File file = new File(dataDirectory, fileName + ".dat");
|
||||||
|
|
||||||
|
@@ -2,3 +2,4 @@ protected net.minecraft.inventory.container.Container field_75153_a # inventoryI
|
|||||||
protected net.minecraft.inventory.container.Container field_75149_d # listeners
|
protected net.minecraft.inventory.container.Container field_75149_d # listeners
|
||||||
protected net.minecraft.client.gui.widget.TextFieldWidget field_146212_n # canLoseFocus
|
protected net.minecraft.client.gui.widget.TextFieldWidget field_146212_n # canLoseFocus
|
||||||
public net.minecraft.client.gui.widget.button.CheckboxButton field_212943_a # checked
|
public net.minecraft.client.gui.widget.button.CheckboxButton field_212943_a # checked
|
||||||
|
public net.minecraft.world.storage.DimensionSavedDataManager field_215759_d # folder
|
Reference in New Issue
Block a user