added CatFormat

This commit is contained in:
cattyn
2025-07-14 17:12:07 +03:00
parent 93d35969e9
commit d9efde3d2c
5 changed files with 41 additions and 1 deletions
+4
View File
@@ -13,6 +13,7 @@ repositories {
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
mavenCentral()
maven { url "https://jitpack.io" }
}
loom {
@@ -27,6 +28,9 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
include implementation("com.github.cattyngmd.catformat:catformat-core:${project.catformat_version}")
include modImplementation("com.github.cattyngmd.catformat:catformat-fabric:${project.catformat_version}")
}
processResources {
+1
View File
@@ -15,3 +15,4 @@ loader_version=0.16.14
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.121.0+1.21.5
catformat_version=2.0.3
@@ -1,6 +1,7 @@
package me.alpha432.oyvey;
import me.alpha432.oyvey.manager.*;
import me.alpha432.oyvey.util.TextUtil;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.minecraft.SharedConstants;
@@ -37,6 +38,8 @@ public class OyVey implements ModInitializer, ClientModInitializer {
moduleManager = new ModuleManager();
speedManager = new SpeedManager();
holeManager = new HoleManager();
TextUtil.init();
}
@Override public void onInitializeClient() {
@@ -3,6 +3,7 @@ package me.alpha432.oyvey.features.modules.client;
import me.alpha432.oyvey.OyVey;
import me.alpha432.oyvey.event.impl.Render2DEvent;
import me.alpha432.oyvey.features.modules.Module;
import me.alpha432.oyvey.util.TextUtil;
public class HudModule extends Module {
public HudModule() {
@@ -12,7 +13,7 @@ public class HudModule extends Module {
@Override public void onRender2D(Render2DEvent event) {
event.getContext().drawTextWithShadow(
mc.textRenderer,
OyVey.NAME + " " + OyVey.VERSION,
TextUtil.text("{global} %s {} %s", OyVey.NAME, OyVey.VERSION),
2, 2,
-1
);
@@ -0,0 +1,31 @@
package me.alpha432.oyvey.util;
import dev.cattyn.catformat.CatFormat;
import dev.cattyn.catformat.fabric.FabricCatFormat;
import me.alpha432.oyvey.OyVey;
import net.minecraft.text.MutableText;
public final class TextUtil {
private static CatFormat<MutableText> formatter;
private TextUtil() {
throw new AssertionError("Can't create an instance of utility class");
}
public static void init() {
if (formatter != null) throw new IllegalStateException("Formatter is already initialized");
formatter = new FabricCatFormat(true);
initColors();
}
public static MutableText text(String content, Object... obj) {
if (obj == null || obj.length == 0) {
return formatter.format(content);
}
return formatter.format(content, obj);
}
private static void initColors() {
formatter.add("global", () -> OyVey.colorManager.getColorAsInt());
}
}