Carbon Config

Carbon Config

5M Downloads

[1.7.10] Registry suggestion crash

JackOfNoneTrades opened this issue ยท 0 comments

commented

At this line, there is a FMLControlledNamespacedRegistry to Collection cast which fails.
The following in a mixin @Overwrite fixes the issue:

public void provideSuggestions(Consumer<ISuggestionProvider.Suggestion> output, Predicate<ISuggestionProvider.Suggestion> filter) {
        for(Object entry : ((RegistryValueAccessor)value).getRegistry().typeSafeIterable()) {
            String key = ((RegistryValueAccessor)value).getRegistry().getNameForObject(entry).toString();
            ISuggestionProvider.Suggestion suggestion = ISuggestionProvider.Suggestion.namedTypeValue(key, key, ((RegistryValueAccessor) value).getClz());
            if(filter.test(suggestion)) output.accept(suggestion);
        }
    }

This happens when I add an item config entry and when I try to add a second item to the array, from the GUI.

RegistryValue<Item> itemCE = RegistryValue
            .builder("testItem", Item.class)
            .addDefault(Items.apple)
            .withFilter(x -> true)
            .withComment("custom item")
            .build(GameData.getItemRegistry());
        generalSection.add(itemCE);

Is there any way to add a RegistryValue that is not an array? For when I want to add a single item.