Skip to content

Commit

Permalink
Fix Quantum Chest Export Slot Checking (#2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzdude authored Nov 17, 2023
1 parent ba8318e commit 41ae07b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,17 @@ public ItemStack insertItem(int slot, @Nonnull ItemStack insertedStack, boolean
return ItemStack.EMPTY;
}

ItemStack exportItems = getExportItems().getStackInSlot(0);

// If there is a virtualized stack and the stack to insert does not match it, do not insert anything
if (itemsStoredInside > 0L &&
!virtualItemStack.isEmpty() && (
!areItemStackIdentical(virtualItemStack, insertedStack) ||
!areItemStackIdentical(exportItems, insertedStack))) {
!virtualItemStack.isEmpty() &&
!areItemStackIdentical(virtualItemStack, insertedStack)) {
return insertedStack;
}

ItemStack exportItems = getExportItems().getStackInSlot(0);

// if there is an item in the export slot and the inserted stack does not match, do not insert
if (!exportItems.isEmpty() && !areItemStackIdentical(exportItems, insertedStack)) {
return insertedStack;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ public void Test_Stack_In_Slot() {
}
}

@Test
public void Test_Export_Checking() {
for (var quantumChest : createInstances()) {
IItemHandler itemHandler = quantumChest.getCombinedInventory();
insertItem(itemHandler, GRAVEL.copy(), false);

ItemStack export = quantumChest.getExportItems().getStackInSlot(0);

insertItem(itemHandler, SAND.copy(), false);
insertItem(itemHandler, SAND.copy(), false);

insertItem(itemHandler, GRAVEL.copy(), false);


String reason = "The virtualized stack is not the same as the export slot!";
boolean isEqual = ItemStack.areItemsEqual(export, quantumChest.virtualItemStack) && export.getMetadata() == quantumChest.virtualItemStack.getMetadata();
assertThat(reason, isEqual, is(true));
}
}

@Test
public void Test_Multiple_Insertions() {
for (var quantumChest : createInstances()) {
Expand Down

0 comments on commit 41ae07b

Please sign in to comment.