top.hendrixshen.magiclib.util.minecraft.render.RenderUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of magiclib-minecraft-api-1.19.3-fabric Show documentation
Show all versions of magiclib-minecraft-api-1.19.3-fabric Show documentation
Unleash magic into Minecraft, infuse souls, ascend to heaven!
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2023 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see .
*/
package top.hendrixshen.magiclib.util.minecraft.render;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_2561;
import net.minecraft.class_310;
import net.minecraft.class_327;
import net.minecraft.class_5481;
import top.hendrixshen.magiclib.api.compat.minecraft.client.gui.FontCompat;
/**
* Reference to TweakerMore
*/
@Environment(EnvType.CLIENT)
public class RenderUtil {
private static final class_327 TEXT_RENDERER = class_310.method_1551().field_1772;
public static final int TEXT_HEIGHT = RenderUtil.TEXT_RENDERER.field_2000;
public static final int TEXT_LINE_HEIGHT = RenderUtil.TEXT_HEIGHT + 1;
public static int getRenderWidth(String text) {
return RenderUtil.TEXT_RENDERER.method_1727(text);
}
public static int getRenderWidth(class_2561 text) {
FontCompat fontCompat = FontCompat.of(RenderUtil.TEXT_RENDERER);
return fontCompat.width(text);
}
//#if MC > 11502
public static int getRenderWidth(class_5481 text) {
return RenderUtil.TEXT_RENDERER.method_30880(text);
}
//#endif
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy