use of net.minecraft.client.font.TextRenderer in project jGui by ReplayMod.
the class MinecraftGuiRenderer method drawCenteredString.
@Override
public int drawCenteredString(int x, int y, int color, String text, boolean shadow) {
TextRenderer fontRenderer = MCVer.getFontRenderer();
x -= fontRenderer.getWidth(text) / 2;
return drawString(x, y, color, text, shadow);
}
use of net.minecraft.client.font.TextRenderer in project Client by MatHax.
the class PlayerListHudMixin method onRenderLatencyIcon.
@Inject(method = "renderLatencyIcon", at = @At("HEAD"), cancellable = true)
private void onRenderLatencyIcon(MatrixStack matrices, int width, int x, int y, PlayerListEntry entry, CallbackInfo info) {
BetterTab betterTab = Modules.get().get(BetterTab.class);
if (betterTab.isActive() && betterTab.accurateLatency.get()) {
TextRenderer textRenderer = client.textRenderer;
int latency = Utils.clamp(entry.getLatency(), 0, 9999);
int color = latency < 150 ? 0x00E970 : latency < 300 ? 0xE7D020 : 0xD74238;
String text = latency + "ms";
textRenderer.drawWithShadow(matrices, text, (float) x + width - textRenderer.getWidth(text), (float) y, color);
info.cancel();
}
}
use of net.minecraft.client.font.TextRenderer in project Client by MatHax.
the class ContainerButtonWidget method renderButton.
@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
TextRenderer textRenderer = mc.textRenderer;
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.enableDepthTest();
int halfWidth = width / 2;
int halfHeight = height / 2;
int texY = getYImage(isHovered()) * 20;
drawTexture(matrices, x, y, 0, 46 + texY, halfWidth, halfHeight);
drawTexture(matrices, x, y + halfHeight, 0, 46 + texY + 14, halfWidth, halfHeight);
drawTexture(matrices, x + halfWidth, y, 200 - halfWidth, 46 + texY, halfWidth, halfHeight);
drawTexture(matrices, x + halfWidth, y + halfHeight, 200 - halfWidth, 46 + texY + 14, halfWidth, halfHeight);
drawCenteredText(matrices, textRenderer, getMessage(), x + width / 2, (y + height / 2) - 4, active ? 16777215 : 10526880 | MathHelper.ceil(alpha * 255.0F) << 24);
}
use of net.minecraft.client.font.TextRenderer in project BleachHack by BleachDrinker420.
the class ModuleWindow method render.
public void render(MatrixStack matrices, int mouseX, int mouseY) {
tooltip = null;
int x = x1 + 1;
int y = y1 + 13;
x2 = x + len + 1;
y2 = hiding ? y1 + 13 : y1 + 13 + getHeight();
super.render(matrices, mouseX, mouseY);
if (hiding)
return;
TextRenderer textRend = mc.textRenderer;
int curY = 0;
for (Entry<Module, Boolean> m : mods.entrySet()) {
if (mouseOver(x, y + curY, x + len, y + 12 + curY)) {
DrawableHelper.fill(matrices, x, y + curY, x + len, y + 12 + curY, 0x70303070);
}
// If they match: Module gets marked red
if (searchedModules != null && searchedModules.contains(m.getKey()) && ModuleManager.getModule(ClickGui.class).getSetting(1).asToggle().getState()) {
DrawableHelper.fill(matrices, x, y + curY, x + len, y + 12 + curY, 0x50ff0000);
}
textRend.drawWithShadow(matrices, textRend.trimToWidth(m.getKey().getName(), len), x + 2, y + 2 + curY, m.getKey().isEnabled() ? 0x70efe0 : 0xc0c0c0);
// Set which module settings show on
if (mouseOver(x, y + curY, x + len, y + 12 + curY)) {
tooltip = new Tooltip(x + len + 2, y + curY, m.getKey().getDesc());
if (lmDown)
m.getKey().toggle();
if (rmDown)
mods.replace(m.getKey(), !m.getValue());
if (lmDown || rmDown)
mc.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
curY += 12;
// draw settings
if (m.getValue()) {
for (ModuleSetting<?> s : m.getKey().getSettings()) {
s.render(this, matrices, x + 1, y + curY, len - 1);
if (!s.getTooltip().isEmpty() && mouseOver(x + 2, y + curY, x + len, y + s.getHeight(len) + curY)) {
tooltip = s.getTooltip(this, x + 1, y + curY, len - 1);
}
DrawableHelper.fill(matrices, x + 1, y + curY, x + 2, y + curY + s.getHeight(len), 0xff8070b0);
curY += s.getHeight(len);
}
}
}
}
use of net.minecraft.client.font.TextRenderer in project BleachHack by BleachDrinker420.
the class Window method render.
public void render(MatrixStack matrices, int mouseX, int mouseY) {
TextRenderer textRend = MinecraftClient.getInstance().textRenderer;
if (dragging) {
x2 = (x2 - x1) + mouseX - dragOffX - Math.min(0, mouseX - dragOffX);
y2 = (y2 - y1) + mouseY - dragOffY - Math.min(0, mouseY - dragOffY);
x1 = Math.max(0, mouseX - dragOffX);
y1 = Math.max(0, mouseY - dragOffY);
}
drawBackground(matrices, mouseX, mouseY, textRend);
for (WindowWidget w : widgets) {
if (w.shouldRender(x1, y1, x2, y2)) {
w.render(matrices, x1, y1, mouseX, mouseY);
}
}
boolean blockItem = icon != null && icon.getItem() instanceof BlockItem;
/* window icon */
if (icon != null) {
RenderSystem.getModelViewStack().push();
RenderSystem.getModelViewStack().translate(x1 + (blockItem ? 3 : 2), y1 + 2, 0);
RenderSystem.getModelViewStack().scale(0.6f, 0.6f, 1f);
DiffuseLighting.enableGuiDepthLighting();
MinecraftClient.getInstance().getItemRenderer().renderInGui(icon, 0, 0);
DiffuseLighting.disableGuiDepthLighting();
RenderSystem.getModelViewStack().pop();
RenderSystem.applyModelViewMatrix();
}
/* window title */
textRend.drawWithShadow(matrices, title, x1 + (icon == null || icon.getItem() == Items.AIR ? 4 : (blockItem ? 15 : 14)), y1 + 3, -1);
}
Aggregations