Open rikka0w0 opened 1 month ago
As the title suggests. It is inconvenient when handling a large set of similar options and requires a lot of duplication and hard coding.
I found a solution. In DefaultGuiProviders.java:
private static List<AbstractConfigListEntry> getChildren(String i18n, Class<?> fieldType, Object iConfig, Object iDefaults, GuiRegistryAccess guiProvider) { - return Arrays.stream(fieldType.getDeclaredFields()) + return traverseFields(fieldType, true).stream()
where traverseFields is a new helper function:
traverseFields
private static List<Field> traverseFields(Class<?> fieldType, boolean includeSuper) { List<Field> result = new LinkedList<>(); Class<?> cls = fieldType; while (cls != null && !cls.equals(Object.class)) { result.addAll(Arrays.asList(cls.getDeclaredFields())); if (!includeSuper) { break; } cls = cls.getSuperclass(); } return result; }
We could introduce another option in the CollapsibleObject annotation to specify whether we include the fields in its super class or not.
As the title suggests. It is inconvenient when handling a large set of similar options and requires a lot of duplication and hard coding.
I found a solution. In DefaultGuiProviders.java:
where
traverseFields
is a new helper function:We could introduce another option in the CollapsibleObject annotation to specify whether we include the fields in its super class or not.