How to reproduce:
Type the following command in chat without executing it
/execute as @s run advancement grant @s only minecraft:adventure/adventuring_time
Press space to be prompted with suggestions for the specific advancement criterion to grant
Observe there are no suggestions provided and there is an error in the log
[Server thread/ERROR] (Minecraft) Failed to handle packet net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket@5e761b9f, suppressing error java.lang.IllegalArgumentException: No such argument 'advancement' exists on this command at com.mojang.brigadier.context.CommandContext.getArgument(CommandContext.java:102) at net.minecraft.commands.arguments.ResourceKeyArgument.getRegistryKey(ResourceKeyArgument.java:60) at net.minecraft.commands.arguments.ResourceKeyArgument.getAdvancement(ResourceKeyArgument.java:94) at net.minecraft.server.commands.AdvancementCommands.method_12991(AdvancementCommands.java:52) at com.mojang.brigadier.tree.ArgumentCommandNode.listSuggestions(ArgumentCommandNode.java:71) at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:541) at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:523) at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCustomCommandSuggestions(ServerGamePacketListenerImpl.java:568) at net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket.handle(ServerboundCommandSuggestionPacket.java:37) at net.minecraft.network.protocol.game.ServerboundCommandSuggestionPacket.handle(ServerboundCommandSuggestionPacket.java:9) at net.minecraft.network.protocol.PacketUtils.method_11072(PacketUtils.java:27) at net.minecraft.server.TickTask.run(TickTask.java:18) at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:164) at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:889) at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:180) at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:138) at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:871) at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:865) at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:147) at net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:829) at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:836) at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:719) at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:292) at java.base/java.lang.Thread.run(Thread.java:1583)
This also affects the attribute command:
/execute as @s run attribute @s minecraft:armor modifier remove
Code Analysis:
For the advancement criterion in net.minecraft.server.commands.AdvancementCommands
:
Commands.argument("criterion", StringArgumentType.greedyString())
.suggests((context, builder) -> SharedSuggestionProvider.suggest(
ResourceKeyArgument.getAdvancement(context, "advancement").value().criteria().keySet(), builder
))
The suggestion provider tries to get the "advancement"
argument from the context, however when CommandDispatcher.getCompletionSuggestions
is called it passes the CommandContext
built from ParseResults.getContext
which doesn't take into account the proper context chain depending on which node is providing suggestions but instead provides the root /execute
command CommandContext
.
A suggested solution would be to have CommandContextBuilder.findSuggestionContext
also return the relevant context builder for the suggestion as it already searches through all of it's children to find the correct CommandNode
. Then you could simply use this CommandContextBuilder
to construct the correct context for the suggestions.
See relevant pull request: https://github.com/Mojang/brigadier/pull/156
Comments 0
No comments.