Skip to content

Commit

Permalink
fix: no suggestions in client command
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Apr 15, 2023
1 parent 15c6393 commit c5096ab
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import net.minecraft.commands.CommandRuntimeException;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.synchronization.SuggestionProviders;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentUtils;
Expand Down Expand Up @@ -144,18 +143,15 @@ public static CommandDispatcher<SharedSuggestionProvider> getRoot(@NotNull Playe

@SuppressWarnings({ "unchecked", "rawtypes" })
private static void fillUsableCommands(@NotNull CommandNode<CommandSourceStack> commandNode, @NotNull CommandNode<SharedSuggestionProvider> commandNode2, CommandSourceStack commandSourceStack, @NotNull Map<CommandNode<CommandSourceStack>, @NotNull CommandNode<SharedSuggestionProvider>> map) {
for(CommandNode<CommandSourceStack> commandNode3 : commandNode.getChildren()) {
for (CommandNode<CommandSourceStack> commandNode3 : commandNode.getChildren()) {
if (commandNode3.canUse(commandSourceStack)) {
ArgumentBuilder<SharedSuggestionProvider, ?> argumentBuilder = (ArgumentBuilder) commandNode3.createBuilder();
argumentBuilder.requires((sharedSuggestionProvider) -> true); // Client commands are always available
if (argumentBuilder.getCommand() != null) {
argumentBuilder.executes((commandContext) -> 0);
}
if (argumentBuilder instanceof RequiredArgumentBuilder) {
RequiredArgumentBuilder<SharedSuggestionProvider, ?> requiredArgumentBuilder = (RequiredArgumentBuilder<SharedSuggestionProvider, ?>) argumentBuilder;
if (requiredArgumentBuilder.getSuggestionsProvider() != null) {
requiredArgumentBuilder.suggests(SuggestionProviders.safelySwap(requiredArgumentBuilder.getSuggestionsProvider()));
}
if (argumentBuilder instanceof RequiredArgumentBuilder requiredArgumentBuilder) {
requiredArgumentBuilder.suggests(requiredArgumentBuilder.getSuggestionsProvider());
}
if (argumentBuilder.getRedirect() != null) {
argumentBuilder.redirect(map.get(argumentBuilder.getRedirect()));
Expand Down

0 comments on commit c5096ab

Please sign in to comment.