Posted June 20, 20223 yr Hello I've almost finished my first mod, which is basically just a little add-on mod to Vanilla(e.g. A command where I type something into the chat with color codes and then the client sends it back to me as a formatted string, so I can see if there are issues before I use it for server stuff), but now when I went to try it out for the first time on a multiplayer server, I found that I can't use any of the commands I registered with the RegisterCommandsEvent that worked in singleplayer. Is there any way to register the commands on the client side so that they work for me in multiplayer? Edited June 20, 20223 yr by SPDE
June 20, 20223 yr do you have the permission to execute the command? Edited June 20, 20223 yr by Luis_ST
June 20, 20223 yr Author 5 minutes ago, Luis_ST said: do you have the permission to execute the command? It returns the default message "Unknown or incomplete command" and is also unable to auto-complete if that is what you mean.
June 20, 20223 yr Author 2 minutes ago, Luis_ST said: show your command class As I said, it works in singleplayer, it just doesn't work on multiplayer servers, but sure: One of the commands. package com.versemod.command.commands; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; import com.versemod.command.Command; import com.versemod.configs.GeneralConfig; import com.versemod.util.MessageBus; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; @Command.Declaration(name="Token Calculation",syntax = VerseModCommands.COMMAND_SYNTAX_PREFIX+" tc",description = "Calculates token value") public class TokenCalculationCommand extends Command { private static final GeneralConfig config = new GeneralConfig(); private static final TokenCalculationCommand tokenCommand = new TokenCalculationCommand(); /* * Used by VerseModCommands to register the TokenCalculation command. * */ protected static ArgumentBuilder<CommandSource,?> register() { VerseModCommands.addCommand(tokenCommand); return Commands.literal("tc").executes(cmd->VerseModCommands.throwSyntaxHelp(tokenCommand,"<amount>")) .then(Commands.argument("amount", IntegerArgumentType.integer(1)) .executes(command->calculateTokenValue(IntegerArgumentType.getInteger(command,"amount"))) ); } /* * Calculates the token amount value based on the GeneralConfig defined token value. * */ private static int calculateTokenValue(int amount){ int valuePerToken = config.getTokenValue(); MessageBus.sendPlayerMessage(MessageBus.DEFAULT_HIGHLIGHT_COLOR+""+amount +""+ MessageBus.DEFAULT_SUCCESS_COLOR+ " token(s) are worth "+MessageBus.DEFAULT_HIGHLIGHT_COLOR+"$" + valuePerToken * amount,true); return -1; } } Registration: /* * Registers all VerseMod commands. * */ @SubscribeEvent public void registerCommands(RegisterCommandsEvent event) { event.getDispatcher().register( LiteralArgumentBuilder.<CommandSource> literal(COMMAND_PREFIX).executes(cmd->HelpCommand.getHelp()) .then(HelpCommand.register()) .then(TokenCalculationCommand.register()) .then(TrackCommand.register()) .then(HologramCommand.register()) .then(FormattingCommand.register()) .then(WeeklyEventCommand.register()) .then(ItemBindCommand.register()) .then(PunishmentCommand.register()) .then(HostBroadcastCommand.register()) ); }
June 20, 20223 yr Based on the description of your error, I would assume that you are trying to load client only classes on the server to confirm my theory, please enable the mojang debug logging (-Dforge.logging.mojang.level=debug) and post full debug log here
June 20, 20223 yr Author 29 minutes ago, diesieben07 said: RegisterCommandsEvent is for server side commands. Support for client side commands was added in 1.18.2. You need to update. The server I'm playing on only runs on 1.16.5 because the modpack is limited to that version, is there nothing else that can be done? Edited June 20, 20223 yr by SPDE
June 20, 20223 yr Author 13 minutes ago, diesieben07 said: There are no client-only commands in 1.16.5, no. Well, that’s unfortunate. I have good relations to the management, what would the server need to do that the commands would work?
June 21, 20223 yr Author I could add the commands with ClientChatEvent, but is there any way to implement something like a custom autocomplete?
June 21, 20223 yr why did you not update to 1.18.2, there you have client-only commands with autocomplete and everything from the normal commands client side
June 21, 20223 yr Author 11 minutes ago, Luis_ST said: why did you not update to 1.18.2, there you have client-only commands with autocomplete and everything from the normal commands client side As I said, the server I'm playing on is running on 1.16.5 and can't be updated because the modpack is limited to that version and probably won't be updated for a few years.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.