From 04b9c8bdc6ac358aab6a503dc7b769beba24ac05 Mon Sep 17 00:00:00 2001 From: zyxkad Date: Tue, 29 Oct 2024 12:39:46 -0600 Subject: [PATCH 1/2] only clear owner when new empty card is swapped but not after load fix #664 --- .../blockentities/InventoryManagerEntity.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java index c973be0ae..115ea23d2 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java @@ -52,11 +52,19 @@ public boolean canPlaceItemThroughFace(int index, @NotNull ItemStack itemStackIn @Override public void setItem(int index, @NotNull ItemStack stack) { - if (stack.getItem() instanceof MemoryCardItem && stack.hasTag() && stack.getTag().contains("ownerId")) { - UUID owner = stack.getTag().getUUID("ownerId"); - this.owner = owner; - stack.getTag().remove("ownerId"); - stack.getTag().remove("owner"); + if (index != 0) { + throw new IndexOutOfBoundsException("Inventory manager's index can only be zero"); + } + if (stack.getItem() instanceof MemoryCardItem) { + if (stack.hasTag() && stack.getTag().contains("ownerId")) { + UUID owner = stack.getTag().getUUID("ownerId"); + this.owner = owner; + stack.getTag().remove("ownerId"); + stack.getTag().remove("owner"); + } else if (stack != this.getItem(index)) { + // Only clear owner when the new card item is not the current item + this.owner = null; + } } else { this.owner = null; } From 54333115eb3e5df8163d68a5ff28ca97853615e3 Mon Sep 17 00:00:00 2001 From: zyxkad Date: Tue, 29 Oct 2024 12:41:39 -0600 Subject: [PATCH 2/2] remove index check --- .../common/blocks/blockentities/InventoryManagerEntity.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java index 115ea23d2..b6dfde03f 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java +++ b/src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/InventoryManagerEntity.java @@ -52,9 +52,6 @@ public boolean canPlaceItemThroughFace(int index, @NotNull ItemStack itemStackIn @Override public void setItem(int index, @NotNull ItemStack stack) { - if (index != 0) { - throw new IndexOutOfBoundsException("Inventory manager's index can only be zero"); - } if (stack.getItem() instanceof MemoryCardItem) { if (stack.hasTag() && stack.getTag().contains("ownerId")) { UUID owner = stack.getTag().getUUID("ownerId");