mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 00:07:45 +00:00
Fix client commands not working when using clickable commands.
This commit is contained in:
1 parent
9e55363e2c
commit
ddb1e52e99
5 files changed
+73
No files matched your search
@@ -71,3 +71,11 @@
|
||||
SignableCommand<ClientSuggestionProvider> signablecommand = SignableCommand.of(this.commands.parse(p_250092_, this.suggestionsProvider));
|
||||
if (signablecommand.arguments().isEmpty()) {
|
||||
this.send(new ServerboundChatCommandPacket(p_250092_));
|
||||
@@ -2641,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void sendUnattendedCommand(String p_407213_, @Nullable Screen p_406262_) {
|
||||
+ if (net.minecraftforge.client.ClientCommandHandler.runCommand(p_407213_)) return;
|
||||
switch (this.verifyCommand(p_407213_)) {
|
||||
case NO_ISSUES:
|
||||
this.send(new ServerboundChatCommandPacket(p_407213_));
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "minecraft:function",
|
||||
"environment": "minecraft:default",
|
||||
"function": "forge:client_command/test_command",
|
||||
"max_ticks": 100,
|
||||
"structure": "forge:empty3x3x3"
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "minecraft:function",
|
||||
"environment": "minecraft:default",
|
||||
"function": "forge:client_command_test/client_command_test",
|
||||
"max_ticks": 100,
|
||||
"structure": "forge:empty3x3x3"
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraftforge.client.event.RegisterClientCommandsEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.gametest.GameTest;
|
||||
import net.minecraftforge.gametest.GameTestNamespace;
|
||||
import net.minecraftforge.test.BaseTestMod;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
|
||||
@GameTestNamespace("forge")
|
||||
@Mod(ClientCommandTest.MODID)
|
||||
public class ClientCommandTest extends BaseTestMod {
|
||||
public static final String MODID = "client_command";
|
||||
private static final String COMMAND = "testClientCommand";
|
||||
private static int LAST_COMMAND = -1;
|
||||
|
||||
public ClientCommandTest(FMLJavaModLoadingContext context) {
|
||||
super(context, false, false);
|
||||
RegisterClientCommandsEvent.BUS.addListener(this::addCommand);
|
||||
}
|
||||
|
||||
private void addCommand(RegisterClientCommandsEvent event) {
|
||||
event.getDispatcher()
|
||||
.register(Commands.literal(COMMAND)
|
||||
.then(Commands.argument("id", IntegerArgumentType.integer())
|
||||
.executes(ctx -> LAST_COMMAND = IntegerArgumentType.getInteger(ctx, "id"))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@GameTest
|
||||
public static void testCommand(GameTestHelper helper) throws IllegalAccessException {
|
||||
int random = new Random().nextInt();
|
||||
Minecraft.getInstance().getConnection().sendUnattendedCommand(COMMAND + ' ' + random, null);
|
||||
helper.assertTrue(LAST_COMMAND == random, "Client command did not execute");
|
||||
helper.succeed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
clientSideOnly=true
|
||||
Reference in new issue
Block a user