Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should be valid for NEK integration.
- Loading branch information
1 parent
28a4dfe
commit 8a0092e
Showing
6 changed files
with
720 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package modwarriors.notenoughkeys.api; | ||
|
||
import cpw.mods.fml.common.Loader; | ||
import cpw.mods.fml.relauncher.Side; | ||
import cpw.mods.fml.relauncher.SideOnly; | ||
|
||
/** | ||
* Center of the API. Main api methods can be found in this class. | ||
* | ||
* @author TheTemportalist | ||
*/ | ||
@SideOnly(Side.CLIENT) | ||
public class Api { | ||
|
||
/** | ||
* Checks if NotEnoughKeys is loaded in the current environment | ||
* | ||
* @return 'true' if loaded | ||
*/ | ||
public static boolean isLoaded() { | ||
return Loader.isModLoaded("notenoughkeys"); | ||
} | ||
|
||
/** | ||
* Registers a mod's keys with NEK | ||
* | ||
* @param modname The NAME of the mod registering the key | ||
* @param keyDecriptions A String[] (Array[String]) of the key descriptions. i.e. new String[]{"key.hotbar1"} | ||
*/ | ||
public static void registerMod(String modname, String[] keyDecriptions) { | ||
try { | ||
Class.forName("modwarriors.notenoughkeys.keys.KeyBindTracker").getMethod( | ||
"registerMod", String.class, String[].class | ||
).invoke(null, modname, keyDecriptions); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
src/api/java/modwarriors/notenoughkeys/api/KeyBindingPressedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package modwarriors.notenoughkeys.api; | ||
|
||
import cpw.mods.fml.common.eventhandler.Cancelable; | ||
import cpw.mods.fml.common.eventhandler.Event; | ||
import cpw.mods.fml.relauncher.Side; | ||
import cpw.mods.fml.relauncher.SideOnly; | ||
import net.minecraft.client.settings.KeyBinding; | ||
|
||
/** | ||
* Called when a keybinding is triggered with the passed with valid modifiers | ||
* | ||
* @author TheTemportalist | ||
*/ | ||
@SideOnly(Side.CLIENT) | ||
@Cancelable | ||
public class KeyBindingPressedEvent extends Event { | ||
|
||
/** | ||
* The KeyBinding being triggered | ||
*/ | ||
public KeyBinding keyBinding = null; | ||
/** | ||
* Tells whether a modifier was required AND was down when triggered | ||
*/ | ||
public boolean shiftRequired = false, ctrlRequired = false, altRequired = false; | ||
|
||
/** | ||
* Called with the passed keyBinding and modifiers. | ||
* Subscribe to this event so activate a keybinding when triggered. | ||
* | ||
* @param keyBinding The KeyBinding being triggered. Stores the key's description and keycode | ||
* @param modifiers The modifiers (SHIFT, CTRL, ALT) that determine when a compatible key is pressed | ||
*/ | ||
public KeyBindingPressedEvent(KeyBinding keyBinding, boolean[] modifiers) { | ||
super(); | ||
this.keyBinding = keyBinding; | ||
this.shiftRequired = modifiers[0]; | ||
this.ctrlRequired = modifiers[1]; | ||
this.altRequired = modifiers[2]; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
@API(owner = "Not Enough Keys", provides = "API_NEK", | ||
apiVersion = "1.0.0") package modwarriors.notenoughkeys.api; | ||
|
||
import cpw.mods.fml.common.API; |
Oops, something went wrong.