Refined Pipes

Refined Pipes

6M Downloads

Extractor ignores item slot 1 if item slot 0 can't be extracted

BananaBabyBoss opened this issue ยท 4 comments

commented

this was causing an issue with pulling items out of a TileEntity that had used item index 0 to insert and index 1 to extract on the same face.

Below i've included the fix.
In ExtractorAttachment.java >> the method 'getSlotToExtractFrom'

in the getSlotToExtractFrom method add the lines that are stared '**'

private int getSlotToExtractFrom(IItemHandler handler) {
	for (int i = 0; i < handler.getSlots(); ++i) {
		ItemStack stack = handler.getStackInSlot(i);
		if (!stack.isEmpty() && acceptsItem(stack)) {
**			ItemStack extracted = handler.extractItem(i, stackSize, true);
**			if (!extracted.isEmpty()) {
				return i;
**			}
		}
	}
	return -1;
}

and in the update method replace

ItemStack extracted = source.extractItem(firstSlot, stackSize, true);

with

ItemStack extracted = source.getStackInSlot(firstSlot).copy();
extracted.setCount(Math.min(extracted.getCount(), stackSize));

that's so extractItem isn't run twice.

the reason? handler.extractItem calls canExtractItem on TileEntities with a IItemHandler of SidedInvWrapper.
if canExtractItem returns false then your code would just ignore the other slots, where as this checks the other slots because even if the first slot can not be extracted it doesn't mean the other slots would not extract.

for example TileEntities that use the same SidedInvWrapper to insert and extract on the same Face of the block, item index 0 to insert and item index 1 to extract. you code would just ignore slot 1 if slot 0 fails.

hope this is of use.

commented

I think I can confirm this. I tried using the item pipes to transfer items from a Basic Crusher to an Electric Furnace (both from Silent's Mechanisms), and then from the furnace to a chest. Both of them don't pull any items out unless the source machine's input slot is empty.

commented

Oh good, it's not just me. I just noticed similar; I've got Chest --> Crusher --> Crusher --> Electric Furnace --> Chest for ore processing, also using Silent's Mechanisms, and the extractor won't pull an item from either Crusher until the items in the input slot finish processing. However in my case, it's pulling items from the final Furnace into the chest while it's still processing items in the input slot.

Additionally, in my setup, the second crusher is slower than the first, since I have some output upgrades instead of speed upgrades on that one. So after a bit, the four output slots of the first Crusher fill, and the input slot can't process. Once it gets to this state, I have to manually pull items out in order to get it started again. I've been able to work around this by putting a buffer chest in between the two.

Minecraft: 1.15.2
Forge: 31.2.30
RefinedPipes: 0.4.2
SilentMechanisms 1.15.2-0.7.2+52

commented

I believe this addresses issue #3 as well

commented

The difference between this issue and #13 is that:

#13 is about failing when the first item can't be extracted
#3 is about failing when the selected item to extract can't be inserted into a connected inventory (and not searching a next inventory)

Either way, I think I have a fix that tackles both issues.