Posted February 25, 201510 yr Hi everyone. I am new to Minecraft Forge. I am used to java and know how to create programs. But I struggle with one little thing: I want to create a mod running on the server only. It is very basic: whenever someone uses a /-command, a random quote is printed to the chat (to all players). Unfortunately I do not know how to disable the check, if the mod is installed on the client side. Any help is appreciated. My mod looks like this: My Controll class: package my.commandcontroll; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLServerStartingEvent; @Mod(modid="CommandControll", name="My Command Controll", version="0.1") public class CommandControll{ @Instance(value="CommandControll") public static CommandControllinstance; @EventHandler public void serverLoad(FMLServerStartingEvent event) { event.registerServerCommand(new MyCommand()); } } My Command class: package my.commandcontroll; import java.util.ArrayList; import java.util.List; import java.util.Random; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; public class MyCommand implements ICommand { private List aliases; private List<String> quotes; private Random random; public MyCommand() { this.aliases = new ArrayList(); this.aliases.add("mycommandtext"); random = new Random(); quotes= new ArrayList<String>(); quotes.add("some text"); quotes.add("some other text"); } @Override public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { int i = random.nextInt(strafen.size()); EntityPlayer player = (EntityPlayer) p_71515_1_; MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentText(player.getDisplayName() + " -> " + qoutes.get(i))); } @Override public int compareTo(Object o) { return 0; } @Override public String getCommandName() { return "mycommandtext"; } @Override public String getCommandUsage(ICommandSender p_71518_1_) { return "mycommandtext"; } @Override public List getCommandAliases() { return this.aliases; } @Override public boolean canCommandSenderUseCommand(ICommandSender p_71519_1_) { return true; } @Override public List addTabCompletionOptions(ICommandSender p_71516_1_, String[] p_71516_2_) { return null; } @Override public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { return false; } }
February 25, 201510 yr @Mod(stuff, acceptableRemoteVersions = "*") 1.7.10 is no longer supported by forge, you are on your own.
February 25, 201510 yr Author Thank you so much! I kind of did know, there will be a very simple solution - I just did not know where to search for it
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.