Posted April 6, 201312 yr comment_37745 I am trying to register my own commands. I've searched and found a couple threads, pointing to ModLoader.addCommand(new MyCommand()). However, I get this error: cpw.mods.fml.common.FMLModContainer cannot be cast to cpw.mods.fml.common.modloader.ModLoaderModContainer at cpw.mods.fml.common.modloader.ModLoaderHelper.addCommand(ModLoaderHelper.java:213) I am on forge 1.5.1. I'm sure the dependencies are being downloaded properly (I've seen them being downloaded and I haven't done anything complicated and other stuff works). Is there a new way to do this? I know I could do checks every time in the Forge CommandEvent, but that seems kludgy... surely, there must be a way to directly register commands?
April 6, 201312 yr Author comment_37748 Wow as always, after spending tons of time (anywhere from 30 minutes to days) trying to solve a problem, I find the solution immediately after asking in the forum. Well at least this can help future users. The solution is to add a @ServerStarting method in your main mod file: @ServerStarting public void serverStarting(FMLServerStartingEvent event) { // Commands event.registerServerCommand(new MyCommand()); // Commands extend CommandBase }
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.