diff --git a/build.gradle b/build.gradle index 59bfcbd..c46f7c5 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { apply plugin: 'foxloader.dev' -version '0.1.0' +version '0.2.0' foxloader { // forceReload = true diff --git a/src/client/java/com/jellied/lightlevelindicator/LightLevelIndicatorModClient.java b/src/client/java/com/jellied/lightlevelindicator/LightLevelIndicatorModClient.java index e039ef1..3a0c30a 100644 --- a/src/client/java/com/jellied/lightlevelindicator/LightLevelIndicatorModClient.java +++ b/src/client/java/com/jellied/lightlevelindicator/LightLevelIndicatorModClient.java @@ -2,13 +2,32 @@ import com.fox2code.foxloader.loader.ClientMod; import com.fox2code.foxloader.registry.CommandCompat; +import net.minecraft.src.client.KeyBinding; +import com.fox2code.foxloader.client.KeyBindingAPI; +import net.minecraft.client.Minecraft; +import org.lwjgl.input.Keyboard; public class LightLevelIndicatorModClient extends LightLevelIndicatorMod implements ClientMod { + private static final KeyBinding toggleLightLevelIndicatorKeyBinding = new KeyBinding("Toggle Light Indicators", Keyboard.KEY_L); + private static boolean firstPress = true; + public void onTick() { + handleKeybind(); LightLevelIndicatorHandler.update(); } public void onInit() { + KeyBindingAPI.registerKeyBinding(toggleLightLevelIndicatorKeyBinding); CommandCompat.registerClientCommand(new ToggleCommand("toggleLightIndicators")); } + + private void handleKeybind() { + if (Keyboard.isKeyDown(toggleLightLevelIndicatorKeyBinding.keyCode) && firstPress) { + LightLevelIndicatorHandler.toggleIsEnabled(); + Minecraft.getInstance().thePlayer.displayChatMessage("Light Level Indicators: " + (LightLevelIndicatorHandler.getIsEnabled() ? "Enabled" : "Disabled")); + firstPress = false; + } else if (!Keyboard.isKeyDown(toggleLightLevelIndicatorKeyBinding.keyCode)) { + firstPress = true; + } + } }