diff --git a/CHANGELOG.md b/CHANGELOG.md index 77609e28..44cce9de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # You're in Grave Danger 2.4.6 +### Fixes +* Fixed issue with graves clearing inventories if the player had more trinkets equipped + in the grave than when claiming a grave + --- # You're in Grave Danger 2.4.5 diff --git a/src/main/java/com/b1n_ry/yigd/compat/AccessoriesCompat.java b/src/main/java/com/b1n_ry/yigd/compat/AccessoriesCompat.java index baee4d7e..27e854da 100644 --- a/src/main/java/com/b1n_ry/yigd/compat/AccessoriesCompat.java +++ b/src/main/java/com/b1n_ry/yigd/compat/AccessoriesCompat.java @@ -151,9 +151,14 @@ public DefaultedList merge(CompatComponent mergingComponent, Serve for (int i = 0; i < mergingSlot.normal.size(); i++) { Pair mergingPair = mergingSlot.normal.get(i); - ItemStack mergingStack = mergingPair.getLeft(); + ItemStack mergingStack = mergingPair.getLeft().copy(); if (mergingStack.isEmpty()) continue; + if (thisSlot.normal.size() <= i) { + extraItems.add(mergingStack); + continue; + } + Pair currentPair = thisSlot.normal.get(i); ItemStack thisStack = currentPair.getLeft(); if (YigdConfig.getConfig().graveConfig.treatBindingCurse && !AccessoriesAPI.getOrDefaultAccessory(mergingStack).canUnequip(mergingStack, SlotReference.of(merger, key, i))) { @@ -171,9 +176,14 @@ public DefaultedList merge(CompatComponent mergingComponent, Serve } for (int i = 0; i < mergingSlot.cosmetic.size(); i++) { Pair mergingPair = mergingSlot.cosmetic.get(i); - ItemStack mergingStack = mergingPair.getLeft(); + ItemStack mergingStack = mergingPair.getLeft().copy(); if (mergingStack.isEmpty()) continue; + if (thisSlot.cosmetic.size() <= i) { + extraItems.add(mergingStack); + continue; + } + Pair currentPair = thisSlot.cosmetic.get(i); ItemStack thisStack = currentPair.getLeft(); if (YigdConfig.getConfig().graveConfig.treatBindingCurse && !AccessoriesAPI.getOrDefaultAccessory(mergingStack).canUnequip(mergingStack, SlotReference.of(merger, key, i))) { @@ -245,16 +255,18 @@ public DefaultedList storeToPlayer(ServerPlayerEntity player) { ExpandedSimpleContainer cosmeticAccessories = container.getCosmeticAccessories(); for (int i = 0; i < inventorySlot.normal.size(); i++) { Pair pair = inventorySlot.normal.get(i); - if (i > normalAccessories.size()) { + if (i >= normalAccessories.size()) { extraItems.add(pair.getLeft()); + continue; } normalAccessories.setStack(i, pair.getLeft()); } for (int i = 0; i < inventorySlot.cosmetic.size(); i++) { Pair pair = inventorySlot.cosmetic.get(i); - if (i > cosmeticAccessories.size()) { + if (i >= cosmeticAccessories.size()) { extraItems.add(pair.getLeft()); + continue; } cosmeticAccessories.setStack(i, pair.getLeft()); diff --git a/src/main/java/com/b1n_ry/yigd/compat/TrinketsCompat.java b/src/main/java/com/b1n_ry/yigd/compat/TrinketsCompat.java index efd7ad81..87f1e975 100644 --- a/src/main/java/com/b1n_ry/yigd/compat/TrinketsCompat.java +++ b/src/main/java/com/b1n_ry/yigd/compat/TrinketsCompat.java @@ -203,6 +203,11 @@ public DefaultedList merge(CompatComponent mergingComponent, Serve Pair pair = mergingItems.get(i); ItemStack mergingStack = pair.getLeft().copy(); // Solves the issue where the itemstacks are the same instance + if (stacks.size() <= i) { + extraItems.add(mergingStack); + continue; + } + Pair currentPair = stacks.get(i); if (YigdConfig.getConfig().graveConfig.treatBindingCurse && !this.canUnequip(trinketComponent.orElse(null), slotName, groupName, i, mergingStack, merger)) { extraItems.add(currentPair.getLeft()); // Add the current item to extraItems (as it's being replaced) @@ -210,7 +215,7 @@ public DefaultedList merge(CompatComponent mergingComponent, Serve continue; // Already set the item, so we can skip the rest } - if (stacks.size() <= i || !currentPair.getLeft().isEmpty()) { + if (!currentPair.getLeft().isEmpty()) { extraItems.add(mergingStack); continue; }