Skip to content

Fix crash when shift-clicking crafting output with empty result slot#199

Merged
rubensworks merged 1 commit intomaster-26from
copilot/fix-empty-resource-error
Apr 12, 2026
Merged

Fix crash when shift-clicking crafting output with empty result slot#199
rubensworks merged 1 commit intomaster-26from
copilot/fix-empty-resource-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

PlayerInventoryWrapper.insert() throws IllegalArgumentException when passed an empty ItemResource (air). This was triggered during shift-click crafting output when the result slot was empty, since no guard existed before calling insert.

Change

Added an isEmpty() check on the crafting result ItemStack before constructing ItemResource and calling PlayerInventoryWrapper.insert() — breaking the loop early if the slot is empty:

ItemStack insertItem = slotCrafting.getItem();
if (insertItem.isEmpty()) {
    break;
}
try (var tx = Transaction.openRoot()) {
    if (PlayerInventoryWrapper.of(player).insert(ItemResource.of(insertItem), insertItem.getCount(), tx) != insertItem.getCount()) {
        break;
    }
}

@rubensworks rubensworks marked this pull request as ready for review April 12, 2026 15:25
@rubensworks rubensworks merged commit 8d4e61b into master-26 Apr 12, 2026
3 checks passed
@github-actions
Copy link
Copy Markdown

Coverage Report for CI Build 24309972298

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage decreased (-0.005%) to 8.634%

Details

  • Coverage decreased (-0.005%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 8 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

8 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
org/cyclops/integratedterminals/network/packet/TerminalStorageIngredientItemStackCraftingGridShiftClickOutput.java 8 3.57%

Coverage Stats

Coverage Status
Relevant Lines: 5528
Covered Lines: 591
Line Coverage: 10.69%
Relevant Branches: 1734
Covered Branches: 36
Branch Coverage: 2.08%
Branches in Coverage %: Yes
Coverage Strength: 0.48 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants