Skip to content

Commit 04b9c8b

Browse files
committed
only clear owner when new empty card is swapped but not after load
fix #664
1 parent 6888ed5 commit 04b9c8b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,19 @@ public boolean canPlaceItemThroughFace(int index, @NotNull ItemStack itemStackIn
5252

5353
@Override
5454
public void setItem(int index, @NotNull ItemStack stack) {
55-
if (stack.getItem() instanceof MemoryCardItem && stack.hasTag() && stack.getTag().contains("ownerId")) {
56-
UUID owner = stack.getTag().getUUID("ownerId");
57-
this.owner = owner;
58-
stack.getTag().remove("ownerId");
59-
stack.getTag().remove("owner");
55+
if (index != 0) {
56+
throw new IndexOutOfBoundsException("Inventory manager's index can only be zero");
57+
}
58+
if (stack.getItem() instanceof MemoryCardItem) {
59+
if (stack.hasTag() && stack.getTag().contains("ownerId")) {
60+
UUID owner = stack.getTag().getUUID("ownerId");
61+
this.owner = owner;
62+
stack.getTag().remove("ownerId");
63+
stack.getTag().remove("owner");
64+
} else if (stack != this.getItem(index)) {
65+
// Only clear owner when the new card item is not the current item
66+
this.owner = null;
67+
}
6068
} else {
6169
this.owner = null;
6270
}

0 commit comments

Comments
 (0)