Skip to content

Factory Gauge network could rarely produce 0 item reading #10486

@nbcss

Description

@nbcss

Description

Create's Factory Gauge could sometime read 0 item in stock despite there are items. It will only last up to 1 second, but could potentially cause over-request.

Replicate the issue (can stable reproduce, tested in 6.0.11)

  1. Put a barrel, attach a packager and a stock link (form a network)
  2. Place Nixie Tubes next to barrel for better reading
  3. Target a Display Link with the Nixie Tube, place the Display Link on ground, and put a 2t timer point to it for frequent update
  4. Place a factory gauge on ground, use plank as filter (could be any item), then link to display link.
  5. Place TWO stacks of planks into barrel, the NixieTube should correctly shows item count
  6. [Issue] take out FIRST stack of plank (left) in the barrel, the reading immediately becomes 0, then recover to 64 after a short delay.
Image Image

Game Log

NA

Debug Information

This bug already been investigated during my time of modding. Here is the root cause:
Create's InventorySummary class incorrectly use ItemStack's direct reference as key, instead of make a copy of the ItemStack (unless getCount() > STACK_SIZE). Check:
InventorySummary use as key without make copy: https://github.com/Creators-of-Create/Create/blob/03ce9a27a7d19211978cf2ca78114349a83f1870/src/main/java/com/simibubi/create/content/logistics/packager/InventorySummary.java#L98C44-L98C49
Packager directly feed ItemStack in container into InventorySummary: https://github.com/Creators-of-Create/Create/blob/03ce9a27a7d19211978cf2ca78114349a83f1870/src/main/java/com/simibubi/create/content/logistics/packager/PackagerBlockEntity.java#L223C4-L223C55

Combine the container loop in Packager and the InventorySummary's insert code, it put the FIRST ItemStack from container and use as reference key, and any same ItemStacks in following slots will just update the count number in the InventorySummary. Since it use directly ItemStack reference from the first slot, if item get take out from that slot, the count of that ItemStack becomes 0, and getItem() on that ItemStack will returns AIR. As the result, all reading of the item in InventorySummary becomes 0 since that item becomes AIR in summary and cannot keyed by correct item filter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugIssue where something isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions