diff --git a/build.gradle b/build.gradle index f33d1eb..d2fdff9 100644 --- a/build.gradle +++ b/build.gradle @@ -13,9 +13,9 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.0' +version = '1.1' group = 'com.xkball.key_command' // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = 'modid' +archivesBaseName = 'KeyCommand' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. diff --git a/src/main/java/com/xkball/key_command/KeyCommand.java b/src/main/java/com/xkball/key_command/KeyCommand.java index 7f898a2..72affa9 100644 --- a/src/main/java/com/xkball/key_command/KeyCommand.java +++ b/src/main/java/com/xkball/key_command/KeyCommand.java @@ -19,7 +19,7 @@ @Mod(modid = KeyCommand.MODID, name = KeyCommand.NAME, version = KeyCommand.VERSION) public class KeyCommand { - public static final String MODID = "assets/key_command"; + public static final String MODID = "key_command"; public static final String NAME = "Key Command"; public static final String VERSION = "1.0"; diff --git a/src/main/java/com/xkball/key_command/client/KeyBind.java b/src/main/java/com/xkball/key_command/client/KeyBind.java index c0c381c..751edda 100644 --- a/src/main/java/com/xkball/key_command/client/KeyBind.java +++ b/src/main/java/com/xkball/key_command/client/KeyBind.java @@ -1,12 +1,15 @@ package com.xkball.key_command.client; import net.minecraft.client.settings.KeyBinding; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class KeyBind { final String command; final int keyDefault; + @SideOnly(Side.CLIENT) KeyBinding real_key; public KeyBind(String command, int keyDefault) { @@ -14,10 +17,12 @@ public KeyBind(String command, int keyDefault) { this.keyDefault = keyDefault; } + @SideOnly(Side.CLIENT) public KeyBinding getReal_key() { return real_key; } + @SideOnly(Side.CLIENT) public void setReal_key(KeyBinding real_key) { this.real_key = real_key; } diff --git a/src/main/java/com/xkball/key_command/client/KeyManager.java b/src/main/java/com/xkball/key_command/client/KeyManager.java index 6c8ed93..fdbf9b8 100644 --- a/src/main/java/com/xkball/key_command/client/KeyManager.java +++ b/src/main/java/com/xkball/key_command/client/KeyManager.java @@ -6,9 +6,12 @@ import net.minecraftforge.client.settings.KeyConflictContext; import net.minecraftforge.client.settings.KeyModifier; import net.minecraftforge.fml.client.registry.ClientRegistry; +import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.List; @@ -18,20 +21,24 @@ public class KeyManager { public static List keys = new ArrayList<>(); public static void init(){ - for(KeyBind key : keys){ - if(key.keyDefault != 0){ - KeyBinding real_key = new KeyBinding("key.command."+key.command, - KeyConflictContext.IN_GAME, - KeyModifier.NONE, - key.keyDefault, - "key.category.key_command"); - key.setReal_key(real_key); - ClientRegistry.registerKeyBinding(real_key); + if(FMLCommonHandler.instance().getSide() == Side.CLIENT){ + for(KeyBind key : keys){ + if(key.keyDefault != 0){ + KeyBinding real_key = new KeyBinding("key.command."+key.command, + KeyConflictContext.IN_GAME, + KeyModifier.NONE, + key.keyDefault, + "key.category.key_command"); + key.setReal_key(real_key); + ClientRegistry.registerKeyBinding(real_key); + + } } - } + } + @SideOnly(Side.CLIENT) @SubscribeEvent public static void onKeyPressed(InputEvent.KeyInputEvent event) { for(KeyBind key : keys){ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index f480667..9f65814 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,14 +1,14 @@ [ { - "modid": "examplemod", - "name": "Example Mod", - "description": "Example placeholder mod.", + "modid": "key_command", + "name": "Key Command", + "description": "bind key with command.", "version": "${version}", "mcversion": "${mcversion}", - "url": "", + "url": "https://github.com/xkball/key_command", "updateUrl": "", - "authorList": ["ExampleDude"], - "credits": "The Forge and FML guys, for making this example", + "authorList": ["xkball"], + "credits": "xkball", "logoFile": "", "screenshots": [], "dependencies": []