Skip to content

Commit

Permalink
Merge pull request #1 from user32dll/feature/add-keybind-to-toggle-mod
Browse files Browse the repository at this point in the history
Add keybind
  • Loading branch information
ellienonekomimi authored Oct 2, 2023
2 parents 9fad502 + fcded0f commit 4f27869
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {

apply plugin: 'foxloader.dev'

version '0.1.0'
version '0.2.0'

foxloader {
// forceReload = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

0 comments on commit 4f27869

Please sign in to comment.