SPDE Posted June 20, 2022 Posted June 20, 2022 (edited) 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, 2022 by SPDE Quote
Luis_ST Posted June 20, 2022 Posted June 20, 2022 (edited) do you have the permission to execute the command? Edited June 20, 2022 by Luis_ST Quote
SPDE Posted June 20, 2022 Author Posted June 20, 2022 On 6/20/2022 at 3:20 PM, Luis_ST said: do you have the permission to execute the command? Expand It returns the default message "Unknown or incomplete command" and is also unable to auto-complete if that is what you mean. Quote
SPDE Posted June 20, 2022 Author Posted June 20, 2022 On 6/20/2022 at 3:30 PM, Luis_ST said: show your command class Expand 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()) ); } Quote
Luis_ST Posted June 20, 2022 Posted June 20, 2022 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 Quote
SPDE Posted June 20, 2022 Author Posted June 20, 2022 (edited) On 6/20/2022 at 4:09 PM, diesieben07 said: RegisterCommandsEvent is for server side commands. Support for client side commands was added in 1.18.2. You need to update. Expand 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, 2022 by SPDE Quote
SPDE Posted June 20, 2022 Author Posted June 20, 2022 On 6/20/2022 at 4:42 PM, diesieben07 said: There are no client-only commands in 1.16.5, no. Expand Well, that鈥檚 unfortunate. I have good relations to the management, what would the server need to do that the commands would work? Quote
SPDE Posted June 21, 2022 Author Posted June 21, 2022 I could add the commands with ClientChatEvent, but is there any way to implement something like a custom autocomplete? Quote
Luis_ST Posted June 21, 2022 Posted June 21, 2022 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 Quote
SPDE Posted June 21, 2022 Author Posted June 21, 2022 On 6/21/2022 at 9:49 AM, 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 Expand 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. Quote
Recommended Posts
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.