Skip to content

Fix "Unregistered holder" exception when applying an ArchetypeVolume to a world#4237

Merged
Yeregorix merged 1 commit intoSpongePowered:api-12from
AlexandreArcil:wrong-biome-holder
Oct 20, 2025
Merged

Fix "Unregistered holder" exception when applying an ArchetypeVolume to a world#4237
Yeregorix merged 1 commit intoSpongePowered:api-12from
AlexandreArcil:wrong-biome-holder

Conversation

@AlexandreArcil
Copy link
Contributor

Related to #4222

Bug

When a biome is applied through ArchetypeVolume, the exception "Unregistered holder in ResourceKey[minecraft:root / minecraft:worldgen/biome]: Direct{net.minecraft.world.level.biome.Biome@XXXXXXX};" is thrown when the chunk is saved.

Cause

The root error is the function Registry#safeCastToReference which check that the Holder is a Reference, which is not the case after an ArchetypeVolume is applied to a world as it sets biomes with a Holder.Direct.

Fix

Change the Holder.Direct to a Holder.Reference when a biome is set to a LevelChunkSection.

Reproduction

I used this code to create and apply an ArchetypeVolume:

private ArchetypeVolume volume;

@Listener
public void rightClick(InteractBlockEvent.Secondary event) {
    if(event.context().get(EventContextKeys.USED_HAND).orElse(HandTypes.OFF_HAND.get()).equals(HandTypes.MAIN_HAND.get())) {
        Vector3i pos = event.interactionPoint().toInt();
        ServerWorld serverWorld = Sponge.server().worldManager().world(event.block().world()).get();
        if (volume == null) {
            volume = serverWorld.createArchetypeVolume(pos, pos.add(0, 1, 0), pos);
            logger.info("volume created");
        } else {
            volume.applyToWorld(serverWorld, pos, SpawnTypes.PLUGIN);
            logger.info("volume applied");
            volume = null;
        }
    }
}

@Yeregorix Yeregorix merged commit bc5fb49 into SpongePowered:api-12 Oct 20, 2025
5 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.

2 participants