Skip to content

Trains lose recipe remainders when burning fuel if inventory is almost full #1887

@purplesyringa

Description

@purplesyringa

Description

Set up a train with a chest, place one lava bucket in the chest, and fill the rest of the slots with cobblestone. Start the train and notice that the lava bucket is consumed, but an empty bucket is not returned to the chest, even though taking out the lava bucket freed up a slot. If there is no cobblestone in the chest, the bucket is returned, but to the second slot rather than the first one.

On Forge, the bucket is always correctly returned to the first empty slot.

Took me a while to debug, but I think I see what is going on. burnFuel looks like this:

try (Transaction t = TransferUtil.getTransaction()) {
for (StorageView<ItemVariant> view : fuelItems.nonEmptyViews()) {
ItemVariant held = view.getResource();
Integer burnTime = FuelRegistry.INSTANCE.get(held.getItem());
if (burnTime == null || burnTime <= 0)
continue;
if (view.extract(held, 1, t) != 1)
continue;
fuelTicks += burnTime;
ItemStack containerItem = held.toStack().getRecipeRemainder();
if (!containerItem.isEmpty())
TransferUtil.insertItem(fuelItems, containerItem);
t.commit();
return;
}
}

In this case, fuelItems is a wrapper that contains an ItemStackHandlerContainer. The call to extract reaches SingleSlotStorage#extract, which eventually calls ItemStackHandlerSlot#setStack to remove the bucket from the list. Notably, this calls setStack, not setNewStack, so while the slot is updated, ItemStackHandler will not become aware of this until t is committed, so for now its lookup field doesn't contain the newly available empty slot. When TransferUtil.insertItem is invoked to insert the empty bucket, it goes through ItemStackHandler#insert, which thinks there are no empty slots yet (and no slots with empty buckets) and fails to insert the bucket.

I can't say exactly how this can be solved, but maybe moving t.commit() upwards can work? This fixes the bug if t is guaranteed to be an outer transaction, but I don't know if that's the case.

Game Log

https://mclo.gs/jmZZYqq

Debug Information

Client Info
Create:
    Mod Version: 6.0.8.1+build.1744-mc1.20.1
    Fabric API Version: 0.92.7+1.20.1
    Ponder Version: 1.0.91
    Minecraft Version: 1.20.1

Graphics:
    Flywheel Version: 1.0.5+1.20.1.build.264
    Flywheel Backend: flywheel:indirect
    OpenGL Renderer: zink Vulkan 1.4(AMD Radeon Graphics (RADV RENOIR) (MESA_RADV))
    OpenGL Version: 4.6 (Core Profile) Mesa 25.3.5 (git-8418351c7c)
    Graphics Mode: fancy
    PojavLauncher Detected: false

System Information:
    Operating System: Linux (amd64) version 6.18.15
    Java Version: 17.0.15, Microsoft
    JVM Flags: 2 total; -Xms512m -Xmx4096m
    Memory: 724533288 bytes (690 MiB) / 2044723200 bytes (1950 MiB) up to 4294967296 bytes (4096 MiB)
    Total Memory: 1326514096 bytes (1265 MiB) / 2044723200 bytes (1950 MiB)
    CPU: AMD Ryzen 5 PRO 4650U with Radeon Graphics @ -0.00 GHz; 6 cores / 12 threads on 1 socket(s)
    Graphics card #0: Renoir [Radeon Vega Series / Radeon Vega Mobile Series] (Advanced Micro Devices, Inc. [AMD/ATI] (0x1002)); 258.00 MB of VRAM

Other Mods:
    core: 3.6.6
    toml: 3.6.6
    jsr305: 3.0.2
    Dripstone Fluid Lib: 3.0.2
    Fabric API Base: 0.4.32+1802ada577
    Fabric API Lookup API (v1): 1.6.37+1802ada577
    Fabric Biome API (v1): 13.0.15+93aa238b77
    Fabric Block API (v1): 1.0.12+1802ada577
    Fabric BlockView API (v2): 1.0.3+924f046a77
    Fabric BlockRenderLayer Registration (v1): 1.1.42+1802ada577
    Fabric Client Tags: 1.1.3+1802ada577
    Fabric Command API (v1): 1.2.35+f71b366f77
    Fabric Command API (v2): 2.2.14+1802ada577
    Fabric Commands (v0): 0.2.52+df3654b377
    Fabric Containers (v0): 0.1.67+df3654b377
    Fabric Content Registries (v0): 4.0.13+1802ada577
    Fabric Convention Tags: 1.5.6+1802ada577
    Fabric Crash Report Info (v1): 0.2.20+1802ada577
    Fabric Data Attachment API (v1): 1.0.2+de0fd6d177
    Fabric Data Generation API (v1): 12.3.7+1802ada577
    Fabric Dimensions API (v1): 2.1.55+1802ada577
    Fabric Entity Events (v1): 1.6.1+1c78457f77
    Fabric Events Interaction (v0): 0.6.5+13a40c6677
    Fabric Events Lifecycle (v0): 0.2.64+df3654b377
    Fabric Game Rule API (v1): 1.0.41+1802ada577
    Fabric Item API (v1): 2.1.29+1802ada577
    Fabric Item Group API (v1): 4.0.14+1802ada577
    Fabric Key Binding API (v1): 1.0.38+1802ada577
    Fabric Key Bindings (v0): 0.2.36+df3654b377
    Fabric Lifecycle Events (v1): 2.2.23+1802ada577
    Fabric Loot API (v2): 1.2.3+1802ada577
    Fabric Loot Tables (v1): 1.1.47+9e7660c677
    Fabric Message API (v1): 5.1.10+1802ada577
    Fabric Mining Level API (v1): 2.1.52+1802ada577
    Fabric Model Loading API (v1): 1.0.4+1802ada577
    Fabric Models (v0): 0.4.3+9386d8a777
    Fabric Networking API (v1): 1.3.14+a158aa0477
    Fabric Networking (v0): 0.3.54+df3654b377
    Fabric Object Builder API (v1): 11.1.5+e35120df77
    Fabric Particles (v1): 1.1.3+1802ada577
    Fabric Recipe API (v1): 1.0.24+1802ada577
    Fabric Registry Sync (v0): 2.3.6+1802ada577
    Fabric Renderer API (v1): 3.2.2+1802ada577
    Fabric Renderer - Indigo: 1.5.3+85287f9f77
    Fabric Renderer Registries (v1): 3.2.47+df3654b377
    Fabric Rendering Data Attachment (v1): 0.3.39+92a0d36777
    Fabric Rendering Fluids (v1): 3.0.29+1802ada577
    Fabric Rendering (v0): 1.1.50+df3654b377
    Fabric Rendering (v1): 3.0.9+1802ada577
    Fabric Resource Conditions API (v1): 2.3.9+1802ada577
    Fabric Resource Loader (v0): 0.11.12+fb82e9d777
    Fabric Screen API (v1): 2.0.9+1802ada577
    Fabric Screen Handler API (v1): 1.3.33+1802ada577
    Fabric Sound API (v1): 1.0.14+1802ada577
    Fabric Transfer API (v1): 3.3.6+8dd72ea377
    Fabric Transitive Access Wideners (v1): 4.3.2+1802ada577
    Fabric Loader: 0.18.4
    Forge Config API Port: 8.0.0
    OpenJDK 64-Bit Server VM: 17
    javax.annotation-api: 1.3.2
    Milk Lib: 1.2.60
    MixinExtras: 0.5.0
    Porting Lib Accessors: 2.3.13+1.20.1
    Porting Lib Attributes: 2.3.13+1.20.1
    Porting Lib Base: 2.3.13+1.20.1
    Porting Lib Brewing: 2.3.13+1.20.1
    Porting Lib Client Events: 2.3.13+1.20.1
    Porting Lib Common: 2.3.13+1.20.1
    Porting Lib Config: 2.3.13+1.20.1
    Porting Lib Core: 2.3.13+1.20.1
    Porting Lib Data: 2.3.13+1.20.1
    Porting Lib Entity: 2.3.13+1.20.1
    Porting Lib Extensions: 2.3.13+1.20.1
    Porting Lib Fluids: 2.3.13+1.20.1
    Porting Lib GameTest: 2.1.1090+1.20
    Porting Lib Gui Utils: 2.3.13+1.20.1
    Porting Lib Lazy Register: 2.3.13+1.20.1
    Porting Lib Mixin Extensions: 2.3.13+1.20.1
    Porting Lib Model Generators: 2.3.13+1.20.1
    Porting Lib Model Loader: 2.3.13+1.20.1
    Porting Lib Model Materials: 2.3.13+1.20.1
    Porting Lib Models: 2.3.13+1.20.1
    Porting Lib Networking: 2.3.13+1.20.1
    Porting Lib Obj Loader: 2.3.13+1.20.1
    Porting Lib Tags: 3.0
    Porting Lib Tool Actions: 2.3.13+1.20.1
    Porting Lib Transfer: 2.3.13+1.20.1
    Porting Lib Utility: 2.3.13+1.20.1
    Reach Entity Attributes: 2.4.0
    Registrate for Fabric: 1.3.79-MC1.20.1
Server Info
Create:
    Mod Version: 6.0.8.1+build.1744-mc1.20.1
    Fabric API Version: 0.92.7+1.20.1
    Ponder Version: 1.0.91
    Minecraft Version: 1.20.1

System Information:
    Operating System: Linux (amd64) version 6.18.15
    Java Version: 17.0.15, Microsoft
    JVM Flags: 2 total; -Xms512m -Xmx4096m
    Memory: 724533288 bytes (690 MiB) / 2044723200 bytes (1950 MiB) up to 4294967296 bytes (4096 MiB)
    Total Memory: 1326514096 bytes (1265 MiB) / 2044723200 bytes (1950 MiB)
    CPU: AMD Ryzen 5 PRO 4650U with Radeon Graphics @ -0.00 GHz; 6 cores / 12 threads on 1 socket(s)
    Graphics card #0: Renoir [Radeon Vega Series / Radeon Vega Mobile Series] (Advanced Micro Devices, Inc. [AMD/ATI] (0x1002)); 258.00 MB of VRAM

Other Mods:
    core: 3.6.6
    toml: 3.6.6
    jsr305: 3.0.2
    Dripstone Fluid Lib: 3.0.2
    Fabric API Base: 0.4.32+1802ada577
    Fabric API Lookup API (v1): 1.6.37+1802ada577
    Fabric Biome API (v1): 13.0.15+93aa238b77
    Fabric Block API (v1): 1.0.12+1802ada577
    Fabric BlockView API (v2): 1.0.3+924f046a77
    Fabric BlockRenderLayer Registration (v1): 1.1.42+1802ada577
    Fabric Client Tags: 1.1.3+1802ada577
    Fabric Command API (v1): 1.2.35+f71b366f77
    Fabric Command API (v2): 2.2.14+1802ada577
    Fabric Commands (v0): 0.2.52+df3654b377
    Fabric Containers (v0): 0.1.67+df3654b377
    Fabric Content Registries (v0): 4.0.13+1802ada577
    Fabric Convention Tags: 1.5.6+1802ada577
    Fabric Crash Report Info (v1): 0.2.20+1802ada577
    Fabric Data Attachment API (v1): 1.0.2+de0fd6d177
    Fabric Data Generation API (v1): 12.3.7+1802ada577
    Fabric Dimensions API (v1): 2.1.55+1802ada577
    Fabric Entity Events (v1): 1.6.1+1c78457f77
    Fabric Events Interaction (v0): 0.6.5+13a40c6677
    Fabric Events Lifecycle (v0): 0.2.64+df3654b377
    Fabric Game Rule API (v1): 1.0.41+1802ada577
    Fabric Item API (v1): 2.1.29+1802ada577
    Fabric Item Group API (v1): 4.0.14+1802ada577
    Fabric Key Binding API (v1): 1.0.38+1802ada577
    Fabric Key Bindings (v0): 0.2.36+df3654b377
    Fabric Lifecycle Events (v1): 2.2.23+1802ada577
    Fabric Loot API (v2): 1.2.3+1802ada577
    Fabric Loot Tables (v1): 1.1.47+9e7660c677
    Fabric Message API (v1): 5.1.10+1802ada577
    Fabric Mining Level API (v1): 2.1.52+1802ada577
    Fabric Model Loading API (v1): 1.0.4+1802ada577
    Fabric Models (v0): 0.4.3+9386d8a777
    Fabric Networking API (v1): 1.3.14+a158aa0477
    Fabric Networking (v0): 0.3.54+df3654b377
    Fabric Object Builder API (v1): 11.1.5+e35120df77
    Fabric Particles (v1): 1.1.3+1802ada577
    Fabric Recipe API (v1): 1.0.24+1802ada577
    Fabric Registry Sync (v0): 2.3.6+1802ada577
    Fabric Renderer API (v1): 3.2.2+1802ada577
    Fabric Renderer - Indigo: 1.5.3+85287f9f77
    Fabric Renderer Registries (v1): 3.2.47+df3654b377
    Fabric Rendering Data Attachment (v1): 0.3.39+92a0d36777
    Fabric Rendering Fluids (v1): 3.0.29+1802ada577
    Fabric Rendering (v0): 1.1.50+df3654b377
    Fabric Rendering (v1): 3.0.9+1802ada577
    Fabric Resource Conditions API (v1): 2.3.9+1802ada577
    Fabric Resource Loader (v0): 0.11.12+fb82e9d777
    Fabric Screen API (v1): 2.0.9+1802ada577
    Fabric Screen Handler API (v1): 1.3.33+1802ada577
    Fabric Sound API (v1): 1.0.14+1802ada577
    Fabric Transfer API (v1): 3.3.6+8dd72ea377
    Fabric Transitive Access Wideners (v1): 4.3.2+1802ada577
    Fabric Loader: 0.18.4
    Forge Config API Port: 8.0.0
    OpenJDK 64-Bit Server VM: 17
    javax.annotation-api: 1.3.2
    Milk Lib: 1.2.60
    MixinExtras: 0.5.0
    Porting Lib Accessors: 2.3.13+1.20.1
    Porting Lib Attributes: 2.3.13+1.20.1
    Porting Lib Base: 2.3.13+1.20.1
    Porting Lib Brewing: 2.3.13+1.20.1
    Porting Lib Client Events: 2.3.13+1.20.1
    Porting Lib Common: 2.3.13+1.20.1
    Porting Lib Config: 2.3.13+1.20.1
    Porting Lib Core: 2.3.13+1.20.1
    Porting Lib Data: 2.3.13+1.20.1
    Porting Lib Entity: 2.3.13+1.20.1
    Porting Lib Extensions: 2.3.13+1.20.1
    Porting Lib Fluids: 2.3.13+1.20.1
    Porting Lib GameTest: 2.1.1090+1.20
    Porting Lib Gui Utils: 2.3.13+1.20.1
    Porting Lib Lazy Register: 2.3.13+1.20.1
    Porting Lib Mixin Extensions: 2.3.13+1.20.1
    Porting Lib Model Generators: 2.3.13+1.20.1
    Porting Lib Model Loader: 2.3.13+1.20.1
    Porting Lib Model Materials: 2.3.13+1.20.1
    Porting Lib Models: 2.3.13+1.20.1
    Porting Lib Networking: 2.3.13+1.20.1
    Porting Lib Obj Loader: 2.3.13+1.20.1
    Porting Lib Tags: 3.0
    Porting Lib Tool Actions: 2.3.13+1.20.1
    Porting Lib Transfer: 2.3.13+1.20.1
    Porting Lib Utility: 2.3.13+1.20.1
    Reach Entity Attributes: 2.4.0
    Registrate for Fabric: 1.3.79-MC1.20.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions