Team-EnderIO / EnderIO

EnderIO Rewritten for Modern Minecraft.
https://enderio.com
The Unlicense
341 stars 107 forks source link

Items are lost during transfer via Item Conduits #898

Open DuraBrite opened 3 hours ago

DuraBrite commented 3 hours ago

Is there an existing issue for this?

Current Behavior

When transferring items using EnderIO Item Conduits, some items are lost during the process. This occurs in both of the current versions for 1.20.1 and 1.21.1.

Expected Behavior

All items transferred through the Item Conduits should arrive in the destination inventory without any losses.

How to Test

A video is attached to demonstrate the setup and how the bug can be reproduced. 10 Red Wool and 10 Cyan Wool are transfered but only 10 Red and 8 Cyan arrive.

https://github.com/user-attachments/assets/dee4af8e-5084-4ee7-a586-728e102f4849

Local Environment

- **Operating System**: tested on Windows and Linux Server
- **Java version**: 17.0.12
- **Minecraft Version**: Forge: 1.20.1 (47.3.12) and NeoForge: 1.21.1
- **Version**: Forge: 6.2.2 and NeoForge: 7.0.9
- **Other Mods**: none

Any Additional Information?

No response

DuraBrite commented 2 hours ago

I adjusted the code and this worked for me. Maybe this can assist you. The issue might be caused by a mismatch between the amount extracted and the amount successfully inserted. The method extractHandler.extractItem should only extract the exact quantity that was successfully inserted.

com/enderio/conduits/common/conduit/type/item/ItemConduitTicker.java:79

ItemStack notInserted = ItemHandlerHelper.insertItem(insert.capability, extractedItem, false);
int successfullyInserted = extractedItem.getCount() - notInserted.getCount();

if (successfullyInserted > 0) {
    extracted += successfullyInserted;
    extractHandler.extractItem(i, successfullyInserted, false);
    if (extracted >= speed) {
        if (sidedExtractData.isRoundRobin) {
            sidedExtractData.rotatingIndex = insertIndex + 1;
        }
        continue toNextExtract;
    } else {
        continue nextItem;
    }
}
CitiesXL2815 commented 2 hours ago

I adjusted the code and this worked for me. Maybe this can assist you. The issue might be caused by a mismatch between the amount extracted and the amount successfully inserted. The method extractHandler.extractItem should only extract the exact quantity that was successfully inserted.

com/enderio/conduits/common/conduit/type/item/ItemConduitTicker.java:79

ItemStack notInserted = ItemHandlerHelper.insertItem(insert.capability, extractedItem, false);
int successfullyInserted = extractedItem.getCount() - notInserted.getCount();

if (successfullyInserted > 0) {
    extracted += successfullyInserted;
    extractHandler.extractItem(i, successfullyInserted, false);
    if (extracted >= speed) {
        if (sidedExtractData.isRoundRobin) {
            sidedExtractData.rotatingIndex = insertIndex + 1;
        }
        continue toNextExtract;
    } else {
        continue nextItem;
    }
}

@DuraBrite Make a Pull Request can also help us as well, so we can just merge it to the build