Skip to content

Fix crash when empty blood fluid container ticks in inventory#1167

Draft
Copilot wants to merge 2 commits intomaster-1.21from
copilot/fix-automatic-blood-filler-crash
Draft

Fix crash when empty blood fluid container ticks in inventory#1167
Copilot wants to merge 2 commits intomaster-1.21from
copilot/fix-automatic-blood-filler-crash

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

NeoForge 21.11.38-beta+ made ResourceHandler.extract() strict about non-empty resources. DamageIndicatedItemFluidContainer.canDrain (cyclopscore) calls extract(getResource(0), ...) — when the item is empty, getResource(0) returns FluidResource.EMPTY (minecraft:empty), which now throws IllegalArgumentException instead of silently returning 0.

This surfaced as a server crash whenever an empty ItemInvigoratingPendant (or any ItemBloodContainer) was in a player's inventory and its inventoryTick fired:

IllegalArgumentException: Expected resource to be non-empty: minecraft:empty [0]
  at ResourceHandler.extract
  at DamageIndicatedItemFluidContainer.canDrain
  at ItemBloodContainer.canConsume
  at ItemInvigoratingPendant.clearBadEffects
  at ItemInvigoratingPendant.inventoryTick

Changes

  • ItemBloodContainer.canDrain (override): Short-circuits with false when the item has no fluid via FluidUtil.getFirstStackContained, avoiding the parent's extract call on an empty resource.

  • ItemBloodContainer.consume: Guards the fluidHandler.extract(resource, ...) call with resource.isEmpty() to handle the case where the item is empty but other inventory containers can supply the blood.

  • GameTestsPendant: Two regression game tests — one directly calling clearBadEffects on an empty ItemInvigoratingPendant, one asserting canConsume returns false on an empty ItemPrimedPendant.

  • RegistryEntries: Added ITEM_INVIGORATING_PENDANT and ITEM_PRIMED_PENDANT typed holders needed by the new tests.

Original prompt

This section details on the original issue you should resolve

<issue_title>Automatic blood filler crash</issue_title>
<issue_description>

Issue type:

  • 🐛 Bug

Short description:

something stupid happens with fluid detections in pendants, etc.

Steps to reproduce the problem:

craft empty pendant, shift click red stick to auto refill items.

Expected behaviour:

red stick fills empty items too.


Versions:

  • This mod: latest from modrinth
  • Minecraft: 1.21.11
  • Mod loader version: neoforge

Log file:

crash-2026-03-06_16.05.23-server.txt</issue_description>

<agent_instructions>Please debug and fix. And if relevant, add a game test corresponding to this case.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@rubensworks

Thanks for reporting!


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…nd fix consume to handle empty fluid resource

Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix automatic blood filler crash with fluid detections Fix crash when empty blood fluid container ticks in inventory Mar 6, 2026
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Pull Request Test Coverage Report for Build 22777099647

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 12 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 34.845%

Files with Coverage Reduction New Missed Lines %
org/cyclops/evilcraft/core/item/ItemBloodContainer.java 12 17.16%
Totals Coverage Status
Change from base Build 22095261687: 0.2%
Covered Lines: 6186
Relevant Lines: 15307

💛 - 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