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.