Files
src
build.gradle
gradle.properties
LICENSE
README.md
settings.gradle
Code
11 436
src/main/java/com/kodari/tripleboost/TripleBoostClient.java
package com.kodari.tripleboost;
import com.mojang.blaze3d.platform.InputUtil;
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.option.KeyBinding;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
public final class TripleBoostClient implements ClientModInitializer {
public static final String MOD_ID = "tripleboost";
private static KeyBinding fullbrightKey;
private static KeyBinding outlineKey;
private static KeyBinding performanceKey;
private static boolean fullbrightEnabled;
private static boolean redOutlineEnabled;
private static boolean performanceEnabled = true;
private static boolean performanceInitialized;
private static double originalGamma;
private static boolean gammaCaptured;
@Override
public void onInitializeClient() {
fullbrightKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.tripleboost.fullbright",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_G,
"category.tripleboost"
));
outlineKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.tripleboost.outline",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_O,
"category.tripleboost"
));
performanceKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.tripleboost.performance",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_P,
"category.tripleboost"
));
RedOutlineRenderer.register();
ClientTickEvents.END_CLIENT_TICK.register(TripleBoostClient::onClientTick);
}
private static void onClientTick(MinecraftClient client) {
if (!performanceInitialized) {
PerformanceProfile.enable(client.options);
performanceInitialized = true;
}
while (fullbrightKey.wasPressed()) {
fullbrightEnabled = !fullbrightEnabled;
updateFullbright(client);
notifyPlayer(client, "Fullbright", fullbrightEnabled);
}
while (outlineKey.wasPressed()) {
redOutlineEnabled = !redOutlineEnabled;
notifyPlayer(client, "Contorno rojo", redOutlineEnabled);
}
while (performanceKey.wasPressed()) {
performanceEnabled = !performanceEnabled;
if (performanceEnabled) {
PerformanceProfile.enable(client.options);
} else {
PerformanceProfile.disable(client.options);
}
notifyPlayer(client, "Perfil de rendimiento", performanceEnabled);
}
}
private static void updateFullbright(MinecraftClient client) {
if (fullbrightEnabled) {
if (!gammaCaptured) {
originalGamma = client.options.getGamma().getValue();
gammaCaptured = true;
}
client.options.getGamma().setValue(16.0);
return;
}
if (gammaCaptured) {
client.options.getGamma().setValue(originalGamma);
}
}
private static void notifyPlayer(MinecraftClient client, String feature, boolean enabled) {
if (client.player != null) {
client.player.sendMessage(
Text.literal(feature + (enabled ? ": activado" : ": desactivado")),
true
);
}
}
public static boolean isRedOutlineEnabled() {
return redOutlineEnabled;
}
}