Skip to content

Guard empty fluid extraction in ItemBloodContainer.consume to prevent broom tick crash#1188

Merged
rubensworks merged 1 commit intomaster-26from
copilot/fix-minecraft-crash
Apr 15, 2026
Merged

Guard empty fluid extraction in ItemBloodContainer.consume to prevent broom tick crash#1188
rubensworks merged 1 commit intomaster-26from
copilot/fix-minecraft-crash

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

A broom energy drain path can call ItemBloodContainer.consume when the fluid handler’s selected resource is empty. On NeoForge, extracting minecraft:empty throws IllegalArgumentException, causing an entity tick crash.

  • Root cause

    • consume(...) fetched fluidHandler.getResource(0) and always called extract(...), even when that resource was empty.
  • Change

    • Added an empty-resource guard before extraction in ItemBloodContainer.consume.
    • If the resource is empty, extraction is skipped (drained = 0) and existing fallback logic (drain from other containers / return drained stack) remains unchanged.
  • Behavioral impact

    • Prevents extract(minecraft:empty, ...) calls while preserving existing blood consumption semantics for valid fluid resources.
FluidResource resource = fluidHandler.getResource(0);
int drained = resource.isEmpty() ? 0 : fluidHandler.extract(resource, amount, tx);

@rubensworks rubensworks marked this pull request as ready for review April 15, 2026 15:30
@rubensworks rubensworks merged commit 8237aff into master-26 Apr 15, 2026
2 of 3 checks passed
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 24463199897

Coverage increased (+0.002%) to 36.703%

Details

  • Coverage increased (+0.002%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15638
Covered Lines: 6625
Line Coverage: 42.36%
Relevant Branches: 5434
Covered Branches: 1109
Branch Coverage: 20.41%
Branches in Coverage %: Yes
Coverage Strength: 2.03 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.

3 participants