Mechanical saw won't process items properly
fabien-gigante opened this issue ยท 6 comments
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
- Place a mechanical saw between two conveyor belts
- Power the mechanical saw and the conveyor belts (with opposite rotations as it should be)
- Place a entire stack of 64 wood logs on the input conveyor
- Wait until the whole stack is processed
- 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
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
Similar problem without the conveyor belts.
Reproduction Steps
- Place & power a mechanical saw
- Set a filter on a saw : striped wood log
- Drop a entire stack of 64 wood logs on top the mechanical saw
- Wait until the whole stack is processed
- 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
Additional comparison test between 0.5.1-d and 0.5.1-f that can help pinpoint the issue.
Version 0.5.1-d
- Place & power a mechanical saw
- Drop a stack of 8 wood logs on top the mechanical saw
- Observe that :
- a stack of 7 wood log remains on top
- 1 wood log is taken by the saw inventory
- Immediately break the saw block (while it's still processing)
- 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)
- Place & power a mechanical saw
- Drop a stack of 8 wood logs on top the mechanical saw
- Observe that :
- the entire stack of 8 is taken by the saw inventory
- Immediately break the saw block (while it's still processing)
- 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.
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...
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
.
Same fix should probably be applied to SchematicannonInventory
and ToolboxInventory
.