Files
src
build.gradle
gradle.properties
lunge
manifest.kod
settings.gradle
Code
14 401
src/client/java/dev/lowfire/client/LowFireClient.java
package dev.lowfire.client;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.input.KeyInput;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;
public final class LowFireClient implements ClientModInitializer {
public static LowFireConfig config;
public static LungeModule module;
private static KeyBinding toggle;
private static KeyBinding gui;
private static KeyBinding lunge;
@Override
public void onInitializeClient() {
config = LowFireConfig.load();
module = new LungeModule(config);
KeyBinding.Category category = KeyBinding.Category.create(Identifier.of("low_fire", "controls"));
toggle = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.low_fire.toggle", GLFW.GLFW_KEY_RIGHT_SHIFT, category));
gui = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.low_fire.gui", GLFW.GLFW_KEY_F7, category));
lunge = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.low_fire.lunge", GLFW.GLFW_KEY_Q, category));
ClientTickEvents.END_CLIENT_TICK.register(module::tick);
}
public static boolean onKey(MinecraftClient client, int action, KeyInput input) {
if (config == null || toggle == null) return false;
if (gui.matchesKey(input) && (client.currentScreen == null || client.currentScreen instanceof LowFireScreen)) {
if (action == GLFW.GLFW_PRESS) {
if (client.currentScreen == null) client.setScreen(new LowFireScreen());
else client.setScreen(null);
}
return true;
}
if (client.currentScreen != null) return false;
if (toggle.matchesKey(input)) {
if (action == GLFW.GLFW_PRESS) {
config.enabled = !config.enabled;
config.save();
}
return true;
}
if (config.enabled && lunge.matchesKey(input)) {
if (action == GLFW.GLFW_PRESS) module.activate(client);
return true;
}
return false;
}
}