Skip to content

NullPointerException when draw an invalid patternΒ #1005

@zhichaoxi2006

Description

@zhichaoxi2006

@Override
protected double getCostModifier(PatternShapeMatch match) {
ResourceLocation loc = actionKey(match);
if (isOfTag(IXplatAbstractions.INSTANCE.getActionRegistry(), loc, HexTags.Actions.CANNOT_MODIFY_COST)) {
return 1.0;
} else {
return this.caster.getAttributeValue(HexAttributes.MEDIA_CONSUMPTION_MODIFIER);
}
}

@Nullable
protected ResourceLocation actionKey(PatternShapeMatch match) {
ResourceLocation key;
if (match instanceof PatternShapeMatch.Normal normal) {
key = normal.key.location();
} else if (match instanceof PatternShapeMatch.PerWorld perWorld) {
key = perWorld.key.location();
} else if (match instanceof PatternShapeMatch.Special special) {
key = special.key.location();
} else {
key = null;
}
return key;
}

loc may null but there not check loc is null, result in throw a NullPointerException when draw an invaild pattern.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    πŸ“‹ Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions