39 lines
1.4 KiB
Java
39 lines
1.4 KiB
Java
package wtf.hak.survivalfabric;
|
|
|
|
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.client.util.InputUtil;
|
|
import net.minecraft.text.Text;
|
|
import org.lwjgl.glfw.GLFW;
|
|
|
|
import java.awt.*;
|
|
|
|
public class SurvivalFabricClient implements ClientModInitializer {
|
|
|
|
public static boolean SHOULD_SHOW_FPS = false;
|
|
|
|
KeyBinding keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
|
"key.survivalfabric.fps", // The translation key of the keybinding's name
|
|
InputUtil.Type.KEYSYM, // The type of the keybinding, KEYSYM for keyboard, MOUSE for mouse.
|
|
GLFW.GLFW_KEY_PERIOD, // The keycode of the key
|
|
"category.survivalfabric.utils" // The translation key of the keybinding's category.
|
|
));
|
|
|
|
@Override
|
|
public void onInitializeClient() {
|
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
|
while (keyBinding.wasPressed()) {
|
|
MinecraftClient mc = MinecraftClient.getInstance();
|
|
SHOULD_SHOW_FPS = !SHOULD_SHOW_FPS;
|
|
if(SHOULD_SHOW_FPS) {
|
|
mc.player.sendMessage(Text.literal("FPS Counter is now on").withColor(Color.GREEN.getRGB()), true);
|
|
} else
|
|
mc.player.sendMessage(Text.literal("FPS Counter is now off").withColor(Color.RED.getRGB()), true);
|
|
|
|
}
|
|
});
|
|
}
|
|
} |