Skip to content

Commit

Permalink
fix nbt reading
Browse files Browse the repository at this point in the history
  • Loading branch information
Faithcaio committed Nov 25, 2023
1 parent f61dc9c commit 231b81f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package org.spongepowered.common.mixin.core.world.level.storage;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtAccounter;
import net.minecraft.nbt.NbtIo;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.storage.PlayerDataStorage;
Expand Down Expand Up @@ -68,12 +69,12 @@ public abstract class PlayerDataStorageMixin {
((SpongeServer) SpongeCommon.server()).getPlayerDataManager().readPlayerData(compound, null, creationTime);
}

@Redirect(method = "load", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NbtIo;readCompressed(Ljava/io/File;)Lnet/minecraft/nbt/CompoundTag;"))
private CompoundTag impl$wrapFileRead(final File param0) throws IOException {
@Redirect(method = "load", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NbtIo;readCompressed(Ljava/nio/file/Path;Lnet/minecraft/nbt/NbtAccounter;)Lnet/minecraft/nbt/CompoundTag;"))
private CompoundTag impl$wrapFileRead(final Path path, final NbtAccounter accounter) throws IOException {
try {
return NbtIo.readCompressed(param0);
return NbtIo.readCompressed(path, accounter);
} catch (final IOException exception) {
FileUtil.copyCorruptedFile(param0);
FileUtil.copyCorruptedFile(path);
// handled below.
throw exception;
}
Expand Down

0 comments on commit 231b81f

Please sign in to comment.