Jump to content

[1.12.2] Commands appear not to register, not recognized in game


RedstoneMaster256

Recommended Posts

I am not sure why, but my commands in the mod I am writing seem to not be registering properly. I have tried all sorts of things, including looking at prior functioning code and tutorials, but none of it is working.

When I do /help, it is not listed there, nor is it listed when I press / then tab.

 

Here is one of the commands, which generates and builds a maze by id.

package dcn.mazegen.commands;

import java.util.ArrayList;
import java.util.List;

import dcn.mazegen.Maze;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;

public class CmdBuild extends CommandBase{

	@Override
	public String getName() {
		return "buildmaze";
	}

	@Override
	public String getUsage(ICommandSender sender) {
		return "buildmaze <id>";
	}

	@Override
	public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
		if(args.length == 0) {
			sender.sendMessage(new TextComponentString("Too few args"));
			return;
		}
		boolean found = false;
		for(Maze m : Maze.mazeList) {
			if(m.id.equals(args[0])) {
				found = true;
				sender.sendMessage(new TextComponentString("Generating maze...."));
				m.generate();
				sender.sendMessage(new TextComponentString("Generated, building maze...."));
				m.build();
				sender.sendMessage(new TextComponentString("Maze built."));
				break;
			}
		}
		if(!found)
			sender.sendMessage(new TextComponentString("Could not find maze with id \"" + args[0] + "\"."));
	}
}

 

Here is the main class, with the @Mod annotation.

package dcn.mazegen;

import dcn.mazegen.commands.CmdBuild;
import dcn.mazegen.commands.CmdMaze;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;

@Mod(modid = MazeGenerator.MODID, name = MazeGenerator.NAME, version = MazeGenerator.VERSION)
public class MazeGenerator {
	public static final String MODID = "MazeGenerator";
	public static final String NAME = "Maze Generator";
	public static final String VERSION = "0.0";

	@Instance
	public static MazeGenerator instance;
	
	@EventHandler
	public void onServerLoad(FMLServerStartingEvent e) {
		e.registerServerCommand(new CmdMaze());
		e.registerServerCommand(new CmdBuild());
	}
}

 

I am using Forge version 1.12.2 - 14.23.4.2705 and Java version 1.8.0_171.

Edited by RedstoneMaster256
Adding code change
Link to comment
Share on other sites

Actually, in testing, it still isn't working. I changed the event handler to not be static.

 

Edit: Figured it out

I read through the logs and saw this line

java.lang.IllegalArgumentException: The modId MazeGenerator must be all lowercase.

 

Now I feel even dumber :(

Edited by RedstoneMaster256
Solved it
Link to comment
Share on other sites

2 hours ago, RedstoneMaster256 said:

Actually, in testing, it still isn't working. I changed the event handler to not be static.

 

Edit: Figured it out

I read through the logs and saw this line


java.lang.IllegalArgumentException: The modId MazeGenerator must be all lowercase.

 

Now I feel even dumber :(

Do you need help with that error, or not?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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