Fallback to uncompressed when reading player data (paulevsGitch/BetterNether#436)

This commit is contained in:
Frank 2021-11-06 21:26:32 +01:00
parent 07d8c56e18
commit 60574d5b75

View file

@ -41,6 +41,7 @@ import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.zip.ZipException;
/**
* API to manage Patches that need to get applied to a world
@ -397,7 +398,8 @@ public class DataFixerAPI {
private static void fixPlayer(MigrationProfile data, State state, File file) {
try {
LOGGER.info("Inspecting " + file);
CompoundTag player = NbtIo.readCompressed(file);
CompoundTag player = readNbt(file);
boolean[] changed = { false };
fixPlayerNbt(player, changed, data);
@ -599,4 +601,12 @@ public class DataFixerAPI {
Patch.getALL().add(patch.get());
}
private static CompoundTag readNbt(File file) throws IOException {
try {
return NbtIo.readCompressed(file);
} catch (ZipException e){
return NbtIo.read(file);
}
}
}