Ad Astra

Ad Astra

22M Downloads

[Bug]: Wrong slot using in ItemUtils.additem

gisellevonbingen opened this issue ยท 1 comments

commented

Bug Description

private static boolean addItem(Container from, Container to, ItemStack fromStack, int[] toSlots, Direction direction) {
fromStack.setCount(1);
for (int slot : toSlots) {
if (from instanceof WorldlyContainer worldlyContainer) {
if (!worldlyContainer.canTakeItemThroughFace(slot, fromStack, direction)) continue;
}
if (to instanceof WorldlyContainer worldlyContainer) {
int[] slots = worldlyContainer.getSlotsForFace(direction);
if (IntStream.of(slots).noneMatch(i -> i == slot)) continue;
if (!worldlyContainer.canPlaceItemThroughFace(slot, fromStack, direction)) continue;
}

In line 52, passed element of toSlots during call from side's canTakeItemThroughFace(slot, fromStack, direction))

if (!worldlyContainer.canTakeItemThroughFace(slot, fromStack, direction)) continue;

If from's canTakeItemThroughFace returned false, skipped to next slot.
So in to's inventory, items may be pushed in a slot that has been skipped a few offset.

My code
image
image

Ingame screenshot
image
image
image

How to Reproduce?

No response

Expected Behavior

No response

Version

1.15.8

Mod Loader Version

1.20.1 - 0.88.1

Mod Loader

Fabric

Logs or additional context

No response

Code of Conduct

  • I have searched the issue tracker and confirmed that the issue has not been reported
  • I have checked the FAQ (if one is present) and my issue is not listed
  • I have verified that I am using the latest version of the mod
  • I have verified that I have installed all the required dependencies for the mod
  • I have verified that I do not have Optifine installed. We will close issues if we detect Optifine is in your pack. We cannot fix Optifine issues. Please do not report issues with Optifine present.
commented

removing the canTakeItemThroughFace and canPlaceItemThroughFace checks from the method seems to be the best solution. because it also seems to not work with some blocks like furnaces.