aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/item
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-10-25 21:01:06 -0400
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-10-25 21:01:06 -0400
commit1a737c461c0d861028612c0a2615d3f5c0487d74 (patch)
treec1a3e85715fc42b74a3b329299cc609b549a3904 /src/main/java/de/hysky/skyblocker/skyblock/item
parent6c8b6dfa0186c0a50f28562c718a237336b8dfb4 (diff)
downloadSkyblocker-1a737c461c0d861028612c0a2615d3f5c0487d74.tar.gz
Skyblocker-1a737c461c0d861028612c0a2615d3f5c0487d74.tar.bz2
Skyblocker-1a737c461c0d861028612c0a2615d3f5c0487d74.zip
Use profile id
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/item')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java b/src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java
index 18acbaf7..d510d65a 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java
@@ -14,7 +14,10 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.*;
+import net.minecraft.nbt.NbtCompound;
+import net.minecraft.nbt.NbtInt;
+import net.minecraft.nbt.NbtIo;
+import net.minecraft.nbt.NbtList;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
@@ -35,7 +38,7 @@ public class BackpackPreview {
private static final Storage[] storages = new Storage[STORAGE_SIZE];
- private static String loaded = ""; // uuid + sb profile currently loaded
+ private static String loaded = ""; // profile id currently loaded
private static Path save_dir = null;
public static void init() {
@@ -51,15 +54,13 @@ public class BackpackPreview {
if (Utils.isOnSkyblock()) {
// save all dirty storages
saveStorages();
- // update save dir based on uuid and sb profile
- String uuid = MinecraftClient.getInstance().getSession().getUuidOrNull().toString().replaceAll("-", "");
- String profile = Utils.getProfile(); //TODO switch to profile id
- if (!profile.isEmpty()) {
- String loading = uuid + "/" + profile;
- save_dir = FabricLoader.getInstance().getConfigDir().resolve("skyblocker/backpack-preview/" + loading);
+ // update save dir based on sb profile id
+ String profileId = Utils.getProfileId();
+ if (!profileId.isEmpty()) {
+ save_dir = FabricLoader.getInstance().getConfigDir().resolve("skyblocker/backpack-preview/" + profileId);
//noinspection ResultOfMethodCallIgnored
save_dir.toFile().mkdirs();
- if (loaded.equals(loading)) {
+ if (loaded.equals(profileId)) {
// mark currently opened storage as dirty
if (MinecraftClient.getInstance().currentScreen != null) {
String title = MinecraftClient.getInstance().currentScreen.getTitle().getString();
@@ -67,8 +68,8 @@ public class BackpackPreview {
if (index != -1) storages[index].markDirty();
}
} else {
- // load storage again because uuid/profile changed
- loaded = loading;
+ // load storage again because profile id changed
+ loaded = profileId;
loadStorages();
}
}
@@ -197,8 +198,7 @@ public class BackpackPreview {
@NotNull
private static Storage fromNbt(NbtCompound root) {
- SimpleInventory inventory = new SimpleInventory(root.getInt("size"));
- inventory.readNbtList(root.getList("list", NbtCompound.COMPOUND_TYPE));
+ SimpleInventory inventory = new SimpleInventory(root.getList("list", NbtCompound.COMPOUND_TYPE).stream().map(NbtCompound.class::cast).map(ItemStack::fromNbt).toArray(ItemStack[]::new));
return new Storage(inventory, root.getString("name"));
}