mojira.dev
MC-170128

Cannot build an EntityType without a datafixer due to an IllegalArgumentException

The bug

This bug report is based off of Minecraft 1.15.2 Pre-release 2 with Yarn names and decompiled with FernFlower.

EntityType$Builder#build(String id) tries to get a datafixer for the entity before creating the type, and continue even if it is unable to get the fixer.
The vanilla code looks like this:

public EntityType<T> build(String id) {
    if (this.saveable) {
        try {
            Schemas.getFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getGameVersion().getWorldVersion())).getChoiceType(TypeReferences.ENTITY_TREE, id);
        } catch (IllegalStateException var3) {
            if (SharedConstants.isDevelopment) {
                throw var3;
            }

            EntityType.LOGGER.warn("No data fixer registered for entity {}", id);
        }
    }

    return new EntityType(this.factory, this.category, this.saveable, this.summonable, this.fireImmune, this.spawnableFarFromPlayer, this.size);
}

Vanilla catches an IllegalStateException, but the actual exception that is thrown by Schema#getChoiceType is IllegalArgumentException. This means that if an EntityType is built for an entity that doesn't have a type, the game will fail hard and crash.

Recommended change:

...
} catch (IllegalArgumentException var3) {
...

Comments 0

No comments.

Glitch

slicedlime

Plausible

Normal

Crash

1.15.1, 1.15.2 Pre-release 2

20w06a

Retrieved