Fallback to uncompressed when reading player data (paulevsGitch/BetterNether#436)
This commit is contained in:
parent
07d8c56e18
commit
60574d5b75
1 changed files with 13 additions and 3 deletions
|
@ -41,6 +41,7 @@ import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import java.util.zip.ZipException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API to manage Patches that need to get applied to a world
|
* API to manage Patches that need to get applied to a world
|
||||||
|
@ -393,11 +394,12 @@ public class DataFixerAPI {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fixPlayer(MigrationProfile data, State state, File file) {
|
private static void fixPlayer(MigrationProfile data, State state, File file) {
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Inspecting " + file);
|
LOGGER.info("Inspecting " + file);
|
||||||
CompoundTag player = NbtIo.readCompressed(file);
|
|
||||||
|
CompoundTag player = readNbt(file);
|
||||||
boolean[] changed = { false };
|
boolean[] changed = { false };
|
||||||
fixPlayerNbt(player, changed, data);
|
fixPlayerNbt(player, changed, data);
|
||||||
|
|
||||||
|
@ -413,7 +415,7 @@ public class DataFixerAPI {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fixPlayerNbt(CompoundTag player, boolean[] changed, MigrationProfile data) {
|
private static void fixPlayerNbt(CompoundTag player, boolean[] changed, MigrationProfile data) {
|
||||||
//Checking Inventory
|
//Checking Inventory
|
||||||
ListTag inventory = player.getList("Inventory", Tag.TAG_COMPOUND);
|
ListTag inventory = player.getList("Inventory", Tag.TAG_COMPOUND);
|
||||||
|
@ -599,4 +601,12 @@ public class DataFixerAPI {
|
||||||
Patch.getALL().add(patch.get());
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue