Skip to content

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;
        }
    }
}

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.

1 participant