Skip to content

Fix IllegalStateException when BiomeExtract contains a biome from a removed/updated mod#1179

Merged
rubensworks merged 3 commits intomaster-1.21-ltsfrom
copilot/fix-illegal-state-exception-biome
Apr 4, 2026
Merged

Fix IllegalStateException when BiomeExtract contains a biome from a removed/updated mod#1179
rubensworks merged 3 commits intomaster-1.21-ltsfrom
copilot/fix-illegal-state-exception-biome

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

When a biome mod is updated and removes a biome previously captured in a BiomeExtract item, deserializing that item crashes with IllegalStateException: Missing element ResourceKey[minecraft:worldgen/biome / ...]. This affects any item lookup (e.g., AE2 search) that triggers component deserialization.

Changes

  • DataComponentBiomeConfig.BiomeHolder.getBiome(): Replace getOrThrow with get().orElse(null) — returns null instead of throwing when the biome key is absent from the registry.

    // Before
    return getter.getOrThrow(ResourceKey.create(Registries.BIOME, id));
    
    // After
    return getter.get(ResourceKey.create(Registries.BIOME, id)).orElse(null);
  • ItemBiomeExtract.appendHoverText(): When the holder is present but the biome no longer exists, fall back to displaying the raw resource location (e.g. biomeswevegone:skyrise_vale) instead of showing nothing.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 4, 2026

Pull Request Test Coverage Report for Build 23979663165

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 19 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.009%) to 28.502%

Files with Coverage Reduction New Missed Lines %
org/cyclops/evilcraft/item/ItemBiomeExtract.java 19 0.0%
Totals Coverage Status
Change from base Build 23681841435: -0.009%
Covered Lines: 5018
Relevant Lines: 15069

💛 - Coveralls

… item

When a biome mod is updated and a previously-extracted biome (stored in
a BiomeExtract item) no longer exists, the game crashed with
IllegalStateException: Missing element ResourceKey[minecraft:worldgen/biome / ...].

The crash occurred in DataComponentBiomeConfig.BiomeHolder.getBiome()
which called getter.getOrThrow(), throwing when the biome key isn't
found in the registry.

Changes:
- DataComponentBiomeConfig.BiomeHolder.getBiome(): Changed from
  getOrThrow to get().orElse(null) to gracefully handle missing biomes
- ItemBiomeExtract.getDescriptionId(): Check holder directly instead of
  biome so items with removed biomes aren't shown as "empty"
- ItemBiomeExtract.isEmpty(): Check holder directly instead of biome
- ItemBiomeExtract.appendHoverText(): When biome is missing (removed
  mod), display the raw biome ID as fallback

Agent-Logs-Url: https://github.com/CyclopsMC/EvilCraft/sessions/2091da3d-064b-4c36-aa6f-8eb54afa71a9

Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix IllegalStateException for missing biome resource key Fix IllegalStateException when BiomeExtract contains a biome from a removed/updated mod Apr 4, 2026
Copilot AI requested a review from rubensworks April 4, 2026 05:09
}

public boolean isEmpty(ItemStack itemStack) {
return getBiome(itemStack) == null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this change is necessary. If not needed, please revert.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in 11279c3.

@Override
public String getDescriptionId(ItemStack itemStack) {
return super.getDescriptionId(itemStack) + (getBiome(itemStack) == null ? ".empty" : "");
return super.getDescriptionId(itemStack) + (itemStack.get(RegistryEntries.COMPONENT_BIOME) == null ? ".empty" : "");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this change is necessary. If not needed, please revert.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in 11279c3.

Copilot AI requested a review from rubensworks April 4, 2026 13:17
@rubensworks rubensworks marked this pull request as ready for review April 4, 2026 13:25
@rubensworks rubensworks merged commit 811b69a into master-1.21-lts Apr 4, 2026
3 checks passed
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.

WeatherContainer Item: IllegalStateException: Missing element ResourceKey[minecraft:worldgen/biome / biomeswevegone:skyrise_vale]

3 participants