Skip to content

Commit 00482ef

Browse files
committed
Handle case where IndexedEnum has default value of 0
1 parent 5b252c8 commit 00482ef

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

enumextensions/src/main/java/net/neoforged/jst/enumextensions/EnumExtensionVisitor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ private void inject(PsiClass psiClass, Collection<ExtensionPrototype> targets) {
134134
final int indexedEnumIndexIdx;
135135
if (indexedEnumAnnotation != null && psiClass.hasAnnotation(indexedEnumAnnotation)) {
136136
var annotation = psiClass.getAnnotation(indexedEnumAnnotation);
137-
indexedEnumIndexIdx = (int) ((JvmAnnotationConstantValue) annotation.getAttributes().getFirst().getAttributeValue()).getConstantValue();
137+
var attributes = annotation.getAttributes();
138+
if (attributes.isEmpty()) {
139+
indexedEnumIndexIdx = 0;
140+
} else {
141+
indexedEnumIndexIdx = (int) ((JvmAnnotationConstantValue) attributes.getFirst().getAttributeValue()).getConstantValue();
142+
}
138143
} else {
139144
indexedEnumIndexIdx = -1;
140145
}

0 commit comments

Comments
 (0)