diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/item/BackpackPreview.java | 26 | ||||
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/Utils.java | 14 | ||||
-rw-r--r-- | src/main/resources/assets/skyblocker/textures/gui/inventory_background.png | bin | 577 -> 0 bytes |
3 files changed, 26 insertions, 14 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")); } diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index bbfd1101..f09d16ed 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -44,6 +44,8 @@ public class Utils { @NotNull private static String profile = ""; @NotNull + private static String profileId = ""; + @NotNull private static String server = ""; @NotNull private static String gameType = ""; @@ -89,6 +91,11 @@ public class Utils { return profile; } + @NotNull + public static String getProfileId() { + return profileId; + } + /** * @return the server parsed from /locraw. */ @@ -323,7 +330,7 @@ public class Utils { } /** - * Parses the /locraw reply from the server + * Parses the /locraw reply from the server and updates the player's profile id * * @return not display the message in chat is the command is sent by the mod */ @@ -349,6 +356,11 @@ public class Utils { return shouldFilter; } } + + if (isOnSkyblock && message.startsWith("Profile ID: ")) { + profileId = message.replace("Profile ID: ", ""); + } + return true; } diff --git a/src/main/resources/assets/skyblocker/textures/gui/inventory_background.png b/src/main/resources/assets/skyblocker/textures/gui/inventory_background.png Binary files differdeleted file mode 100644 index fb588907..00000000 --- a/src/main/resources/assets/skyblocker/textures/gui/inventory_background.png +++ /dev/null |