32 lines
930 B
Java
32 lines
930 B
Java
package net.minecraft.client.gui.screens.inventory.tooltip;
|
|
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.gui.Font;
|
|
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
|
|
import net.minecraft.util.FormattedCharSequence;
|
|
import org.joml.Matrix4f;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class ClientTextTooltip implements ClientTooltipComponent {
|
|
private final FormattedCharSequence text;
|
|
|
|
public ClientTextTooltip(FormattedCharSequence text) {
|
|
this.text = text;
|
|
}
|
|
|
|
@Override
|
|
public int getWidth(Font font) {
|
|
return font.width(this.text);
|
|
}
|
|
|
|
@Override
|
|
public int getHeight(Font font) {
|
|
return 10;
|
|
}
|
|
|
|
@Override
|
|
public void renderText(Font font, int mouseX, int mouseY, Matrix4f matrix, BufferSource bufferSource) {
|
|
font.drawInBatch(this.text, (float)mouseX, (float)mouseY, -1, true, matrix, bufferSource, Font.DisplayMode.NORMAL, 0, 15728880);
|
|
}
|
|
}
|