Skip to content

Commit

Permalink
Save vein cache using IO thread (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts authored Jan 10, 2025
1 parent a7f49b2 commit e494973
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/com/sinthoras/visualprospecting/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.storage.ThreadedFileIOBase;

import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -141,11 +142,14 @@ public static void writeMapToFile(File file, Map<String, Short> map) {
}

public static void writeNBT(File file, NBTTagCompound tag) {
try (FileOutputStream stream = new FileOutputStream(newFile(file))) {
CompressedStreamTools.writeCompressed(tag, stream);
} catch (Exception ex) {
ex.printStackTrace();
}
ThreadedFileIOBase.threadedIOInstance.queueIO(() -> {
try (FileOutputStream stream = new FileOutputStream(newFile(file))) {
CompressedStreamTools.writeCompressed(tag, stream);
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
});
}

public static File newFile(File file) {
Expand Down

0 comments on commit e494973

Please sign in to comment.