Jump to content

Recommended Posts

Posted (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 by SPDE
Posted
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.

Posted
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())
        );
    }

 

Posted

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

Posted (edited)
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 by SPDE
Posted
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?

Posted

I could add the commands with ClientChatEvent, but is there any way to implement something like a custom autocomplete?

Posted
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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I’m working on a Manta Ray entity in MCreator using GeckoLib animations, and my goal is to have a looping (flip) animation that ends at −360°, then transitions seamlessly into a swim animation starting at 0°. However, every method I’ve tried—like quickly interpolating the angle, inserting a brief keyframe at 0°, or using a micro “bridge” animation—still causes a visible “flash” https://imgur.com/a/5ucjUb9 or "jump" when the rotation resets. I want a perfectly smooth motion from the flip’s final rotation to the swim’s initial rotation. If anyone has solved this in MCreator/GeckoLib, or found a better trick for handling the −360° →0° gap without a snap, I’d appreciate some advice ! P.S.- I cannot set swim to start at -360 because I would have the same issue but in reverse. Here's the custom LoopingAnimationGoal :   class LoopingAnimationGoal extends Goal { private final MantaRayEntity entity; private final int cooldownTime; private int animationTimer; private int cooldownTimer; // New boolean to prevent double calls private boolean isLoopingActive = false; public LoopingAnimationGoal(MantaRayEntity entity, int cooldownTime) { this.entity = entity; this.cooldownTime = cooldownTime; this.animationTimer = 0; this.cooldownTimer = 0; this.setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK)); } @Override public boolean canUse() { System.out.println("[DEBUG] LoopingGoal canUse => cooldownTimer=" + cooldownTimer); if (cooldownTimer > 0) { cooldownTimer--; return false; } BlockPos entityPos = entity.blockPosition(); boolean canUse = entity.isWaterAbove(entityPos, 4); System.out.println("[DEBUG] LoopingGoal canUse => WATER " + (canUse ? "DETECTED" : "NOT DETECTED") + " at " + entityPos + ", returning " + canUse); return canUse; } @Override public void start() { entity.setAnimation("looping"); animationTimer = 63; isLoopingActive = true; System.out.println("[DEBUG] Looping animation STARTED. Timer=" + animationTimer + ", gameTime=" + entity.level().getGameTime()); } @Override public boolean canContinueToUse() { System.out.println("[DEBUG] LoopingGoal canContinueToUse => animationTimer=" + animationTimer); return animationTimer > 0; } @Override public void tick() { animationTimer--; System.out.println("[DEBUG] LoopingGoal TICK => animationTimer=" + animationTimer); // We stop ONLY if we are still looping if (animationTimer <= 0 && isLoopingActive) { System.out.println("[DEBUG] condition => animationTimer <= 0 && isLoopingActive"); stop(); } } @Override public void stop() { // Check if already stopped if (!isLoopingActive) { System.out.println("[DEBUG] stop() called again, but isLoopingActive = false. Doing nothing."); return; } System.out.println("[DEBUG] Looping STOP at tick=" + entity.level().getGameTime() + ", last known rotation=" + entity.getXRot() + "/" + entity.getYRot() + ", animationTimer=" + animationTimer); // Immediately switch to "swim" entity.setAnimation("swim"); // Reset cooldown cooldownTimer = cooldownTime; // Disable looping to prevent a second stop isLoopingActive = false; System.out.println("[DEBUG] Looping STOP => setAnimation('swim'), cooldownTimer=" + cooldownTimer); } }  
    • So is the intention of the crusher for ores meant to be used with a silk touch pickaxe or something? Cause that seems like too much effort just to profit off of the machine, when everything drops as raw materials now. Am I just missing something? 
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.