It's a long road, to 1.19

This commit is contained in:
2022-06-10 19:48:56 +02:00
parent 94e13cc65d
commit 7dc6bedf0f
12 changed files with 34 additions and 62 deletions

View File

@@ -2,25 +2,23 @@ package me.hypherionmc.craterlib.util;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
public class LangUtils {
public static Component getTooltipTitle(String key) {
return new TextComponent(ChatFormatting.YELLOW + new TranslatableComponent(key).getString());
return Component.literal(ChatFormatting.YELLOW + Component.translatable(key).getString());
}
public static String resolveTranslation(String key) {
return new TranslatableComponent(key).getString();
return Component.translatable(key).getString();
}
public static Component getTranslation(String key) {
return new TranslatableComponent(key);
return Component.translatable(key);
}
public static Component makeComponent(String text) {
return new TranslatableComponent(text);
return Component.translatable(text);
}
}

View File

@@ -3,7 +3,6 @@ package me.hypherionmc.craterlib.util;
import com.mojang.math.Vector4f;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
public class RenderUtils {
@@ -20,7 +19,7 @@ public class RenderUtils {
amount = amount / 81;
capacity = capacity / 81;
String text = "" + (int) (((float) amount / capacity) * 100);
return amount > 0 ? new TextComponent(ChatFormatting.AQUA + text + "%") : new TextComponent(text + "%");
return amount > 0 ? Component.literal(ChatFormatting.AQUA + text + "%") : Component.literal(text + "%");
}
public static Component getTimeDisplayString(double value) {
@@ -29,9 +28,9 @@ public class RenderUtils {
if (seconds >= 60) {
String appendString = (minutes == 1) ? "Minute" : "Minutes";
String doSeconds = ((seconds - (minutes * 60)) > 0) ? ", " + (seconds - (minutes * 60)) + " Seconds" : "";
return new TextComponent(minutes + " " + appendString + doSeconds);
return Component.literal(minutes + " " + appendString + doSeconds);
} else {
return new TextComponent(seconds + " Seconds");
return Component.literal(seconds + " Seconds");
}
}