Files
gradle
src
.gitignore
build.gradle
gradle.properties
gradlew
gradlew.bat
README.md
settings.gradle
Code
14 515
src/main/java/com/topper/autosprint/TopperAutoSprintClient.java
package com.topper.autosprint;
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.options.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import org.lwjgl.glfw.GLFW;
public class TopperAutoSprintClient implements ClientModInitializer {
private static boolean enabled = true;
private static KeyBinding toggleKeybind;
private static boolean wasPressed = false;
@Override
public void onInitializeClient() {
toggleKeybind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.topperautosprint.toggle",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_F6,
"category.topperautosprint"
));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (toggleKeybind.isPressed()) {
if (!wasPressed) {
wasPressed = true;
enabled = !enabled;
if (client.player != null) {
if (enabled) {
client.player.sendMessage(
new LiteralText("ToPeR SpRiNt MoD ACTIVE").formatted(Formatting.GREEN),
false
);
} else {
client.player.sendMessage(
new LiteralText("ToPeR SpRiNt MoD DEACTIVATED").formatted(Formatting.RED),
false
);
}
}
}
} else {
wasPressed = false;
}
});
}
public static boolean isEnabled() {
return enabled;
}
}