Skip to content

Commit

Permalink
Origins: Fix #408.
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed Mar 11, 2024
1 parent afdfc32 commit 0da1af0
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ public static ResourceKey<Origin> getOrigin(CommandContext<CommandSourceStack> c
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {

List<ResourceLocation> availableOrigins = new ArrayList<>();
availableOrigins.add(OriginsBuiltinRegistries.ORIGINS.get().getKey(Origin.EMPTY));

ResourceLocation originLayerId = context.getArgument("layer", ResourceLocation.class);
OriginLayer originLayer = OriginsAPI.getLayersRegistry().get(originLayerId);
try {
ResourceLocation originLayerId = context.getArgument("layer", ResourceLocation.class);
OriginLayer originLayer = OriginsAPI.getLayersRegistry().get(originLayerId);

availableOrigins.addAll(originLayer.origins().stream().map(Holder::unwrapKey).flatMap(Optional::stream).map(ResourceKey::location).collect(Collectors.toCollection(LinkedList::new)));
availableOrigins.add(OriginsBuiltinRegistries.ORIGINS.get().getKey(Origin.EMPTY));
if (originLayer != null) availableOrigins.addAll(originLayer.origins().stream().map(Holder::unwrapKey).flatMap(Optional::stream).map(ResourceKey::location).collect(Collectors.toCollection(LinkedList::new)));
} catch (IllegalArgumentException ignored) {}

return SharedSuggestionProvider.suggestResource(availableOrigins.stream(), builder);
}
Expand Down

0 comments on commit 0da1af0

Please sign in to comment.