Create Fabric

Create Fabric

11M Downloads

Mechanical saw won't process items properly

fabien-gigante opened this issue ยท 6 comments

commented

Describe the Bug

A mechanical saw won't process items properly when presented with a stack of more than one item.
Most items in the stack are unsuccefully processed, and only discarded . Only the last processed item actually produces the expected output.

Note : game rule "Bulk Cutting" is false (default)

Reproduction Steps

  1. Place a mechanical saw between two conveyor belts
  2. Power the mechanical saw and the conveyor belts (with opposite rotations as it should be)
  3. Place a entire stack of 64 wood logs on the input conveyor
  4. Wait until the whole stack is processed
  5. Observe that only the last wood log as been successfully processed

Expected Result

All 64 wood logs from the input stack should be processed.

Screenshots and Videos

2024-02-18_23 55 49

Crash Report or Log

None

Operating System

Windows 10

Mod Version

0.5.1f

Minecraft Version

1.20.1

Other Mods

Removed all other mods. Same problem.

Additional Context

Using create-fabric-0.5.1-f-build.1242+mc1.20.1.jar

commented

Similar problem without the conveyor belts.

Reproduction Steps

  1. Place & power a mechanical saw
  2. Set a filter on a saw : striped wood log
  3. Drop a entire stack of 64 wood logs on top the mechanical saw
  4. Wait until the whole stack is processed
  5. Observe that only 4 striped wood log successfully ejected

Expected Result

All 64 wood logs from the input stack should be processed, and 64 striped wood logs should be ejected.

Screenshots and Videos

2024-02-19_00 21 09

commented

Additional comparison test between 0.5.1-d and 0.5.1-f that can help pinpoint the issue.

Version 0.5.1-d

  1. Place & power a mechanical saw
  2. Drop a stack of 8 wood logs on top the mechanical saw
  3. Observe that :
    • a stack of 7 wood log remains on top
    • 1 wood log is taken by the saw inventory
  4. Immediately break the saw block (while it's still processing)
  5. Observe on the ground :
    • the unprocessed stack of 7 wood logs
    • a stack of 1 wood log (the saw inventory was dropped)

Version 0.5.1-f (build 1253)

  1. Place & power a mechanical saw
  2. Drop a stack of 8 wood logs on top the mechanical saw
  3. Observe that :
    • the entire stack of 8 is taken by the saw inventory
  4. Immediately break the saw block (while it's still processing)
  5. Observe on the ground :
    • 8 stacks of 1 wood logs (the saw inventory was dropped)

I suspect that the "extended" inventory of the saw is the root cause of the problem.

commented

The following hack seems to solve the issue for me.

public class ProcessingInventory extends ItemStackHandlerContainer {
...
	public long insert(ItemVariant resource, long maxAmount, TransactionContext transaction) {
                maxAmount = isItemValid(0, resource) ? Math.min(maxAmount, getSlotLimit(0)) : 0;
		return super.insert(resource, maxAmount, transaction);
	}
}

Not sure if neither the right fix nor the right place...

commented

OK, I think I have a clean fix now :

public class ProcessingInventory extends ItemStackHandlerContainer {
...
        @Override
	public boolean isItemValid(int slot, ItemVariant resource, int count) {   // <-- 3rd arg added
		return slot == 0 && isEmpty();
        }
}

In Porting lib source code, the 2 arguments signature of SlottedStackStorage.isItemValid is deprecated, and the 3 arguments signature should be used instead. The new signature needs to be overloaded (not the deprecated one that won't be called).

Same fix should probably be applied to SchematicannonInventory and ToolboxInventory.

commented

Same fix should probably be applied to SchematicannonInventory and ToolboxInventory.

commented

alright