mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
Fix 1.19.1 client command API bugs (#2425)
This commit is contained in:
parent
d4b7bd1caa
commit
0c17ea96b8
3 changed files with 11 additions and 2 deletions
fabric-command-api-v2/src/client/java/net/fabricmc/fabric
impl/command/client
mixin/command/client
|
@ -128,7 +128,7 @@ public final class ClientCommandInternals {
|
|||
return type == builtins.dispatcherUnknownCommand() || type == builtins.dispatcherParseException();
|
||||
}
|
||||
|
||||
// See CommandSuggestor.method_30505. That cannot be used directly as it returns an OrderedText instead of a Text.
|
||||
// See ChatInputSuggestor.formatException. That cannot be used directly as it returns an OrderedText instead of a Text.
|
||||
private static Text getErrorMessage(CommandSyntaxException e) {
|
||||
Text message = Texts.toText(e.getRawMessage());
|
||||
String context = e.getContext();
|
||||
|
|
|
@ -37,7 +37,8 @@ abstract class ClientCommandSourceMixin implements FabricClientCommandSource {
|
|||
|
||||
@Override
|
||||
public void sendFeedback(Text message) {
|
||||
this.client.getMessageHandler().onGameMessage(message, false);
|
||||
this.client.inGameHud.getChatHud().addMessage(message);
|
||||
this.client.getNarratorManager().narrate(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -28,6 +29,13 @@ import net.fabricmc.fabric.impl.command.client.ClientCommandInternals;
|
|||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
abstract class ClientPlayerEntityMixin {
|
||||
@Inject(method = "sendCommand(Ljava/lang/String;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private void onSendCommand(String command, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (ClientCommandInternals.executeCommand(command)) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "sendCommand(Ljava/lang/String;Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void onSendCommand(String command, Text preview, CallbackInfo info) {
|
||||
if (ClientCommandInternals.executeCommand(command)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue