[Change] Adapted to new Nbt-API

This commit is contained in:
Frank 2023-12-05 17:30:32 +01:00
parent 0d6d538efe
commit 1061102073
3 changed files with 8 additions and 5 deletions

View file

@ -8,6 +8,7 @@ import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtAccounter;
import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
@ -204,7 +205,7 @@ public class StructureNBT {
}
private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
CompoundTag nbttagcompound = NbtIo.readCompressed(stream, NbtAccounter.unlimitedHeap());
StructureTemplate template = new StructureTemplate();

View file

@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtAccounter;
import net.minecraft.nbt.NbtIo;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
@ -65,7 +66,7 @@ public class StructureHelper {
}
private static StructureTemplate readStructureFromStream(InputStream stream) throws IOException {
CompoundTag nbttagcompound = NbtIo.readCompressed(stream);
CompoundTag nbttagcompound = NbtIo.readCompressed(stream, NbtAccounter.unlimitedHeap());
StructureTemplate template = new StructureTemplate();
template.load(BuiltInRegistries.BLOCK.asLookup(), nbttagcompound);

View file

@ -6,6 +6,7 @@ import org.betterx.worlds.together.world.event.WorldBootstrap;
import net.minecraft.Util;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtAccounter;
import net.minecraft.nbt.NbtIo;
import net.fabricmc.loader.api.FabricLoader;
@ -50,7 +51,7 @@ public class WorldConfig {
CompoundTag root = new CompoundTag();
if (file.exists()) {
try {
root = NbtIo.readCompressed(file);
root = NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap());
} catch (IOException e) {
WorldsTogether.LOGGER.error("World data loading failed", e);
}
@ -140,11 +141,11 @@ public class WorldConfig {
final File tempFile = new File(dataDir, modID + "_temp.nbt");
NbtIo.writeCompressed(tag, tempFile);
NbtIo.writeCompressed(tag, tempFile.toPath());
final File oldFile = new File(dataDir, modID + "_old.nbt");
final File dataFile = new File(dataDir, modID + ".nbt");
Util.safeReplaceFile(dataFile, tempFile, oldFile);
Util.safeReplaceFile(dataFile.toPath(), tempFile.toPath(), oldFile.toPath());
} catch (IOException e) {
WorldsTogether.LOGGER.error("World data saving failed", e);
}