use of net.minecraft.client.font.TextRenderer in project Moonfix by Kingdom-of-Moon.
the class CategoryEntry method render.
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
// render text
TextRenderer textRenderer = client.textRenderer;
int textWidth = client.textRenderer.getWidth(this.title);
float xPos = client.currentScreen.width / 2f - textWidth / 2f;
int yPos = y + entryHeight;
textRenderer.draw(matrices, this.title, xPos, (float) (yPos - 9 - 1), 0xFFFFFF);
}
use of net.minecraft.client.font.TextRenderer in project Moonfix by Kingdom-of-Moon.
the class EnumEntry method render.
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
// text
TextRenderer textRenderer = client.textRenderer;
int posY = y + entryHeight / 2;
textRenderer.draw(matrices, this.title, (float) x, (float) (posY - 9 / 2), 0xFFFFFF);
// reset button
this.reset.x = x + 260;
this.reset.y = y;
this.reset.active = !this.config.configValue.equals(this.config.defaultValue);
this.reset.render(matrices, mouseX, mouseY, tickDelta);
// toggle button
this.toggle.x = x + 175;
this.toggle.y = y;
this.toggle.setMessage(states.get((int) this.config.configValue % states.size()));
// if setting is changed
if ((int) this.config.configValue != this.initValue)
this.toggle.setMessage(new LiteralText("").styled(ConfigManager.ACCENT_COLOR).append(this.toggle.getMessage()));
this.toggle.render(matrices, mouseX, mouseY, tickDelta);
}
use of net.minecraft.client.font.TextRenderer in project RPG-Hud by KurodaAkira.
the class GuiSettingsMod method init.
@Override
public void init() {
TextRenderer fontRenderer = client.textRenderer;
if (this.subSetting.equals("")) {
GuiButtonTooltip guismallbutton = new GuiButtonTooltip(this.width / 2 - 155 + 0 % 2 * 160, this.height / 6 - 14 + 20 * (0 >> 1), "general", new TranslatableText("gui.rpg.general"), button -> {
GuiButtonTooltip b = (GuiButtonTooltip) button;
if (b.enumOptions != null)
client.setScreen(new GuiSettingsMod(instance, b.enumOptions, new TranslatableText("gui.settings.rpghud")));
}).setTooltip(I18n.translate("tooltip.general", new Object[0]));
this.addDrawableChild(guismallbutton);
int count = 1;
for (HudElementType type : HudElementType.values()) {
List<String> settings = this.settings.getSettingsOf(type);
if (!settings.isEmpty()) {
guismallbutton = new GuiButtonTooltip(this.width / 2 - 155 + count % 2 * 160, this.height / 6 - 14 + 20 * (count >> 1), type.name(), new TranslatableText(type.getDisplayName()), button -> {
GuiButtonTooltip b = (GuiButtonTooltip) button;
if (b.enumOptions != null) {
this.client.setScreen(new GuiSettingsMod(instance, b.enumOptions, new TranslatableText("gui.settings.rpghud")));
}
}).setTooltip(I18n.translate("tooltip.element", new Object[0]));
this.addDrawableChild(guismallbutton);
count++;
}
}
} else {
List<String> settingList = this.settings.getSettingsOf(this.subSetting);
for (int i = 0; i < settingList.size(); i++) {
if (this.settings.getSetting(settingList.get(i)) instanceof SettingPosition) {
String[] values = ((String) this.settings.getSetting(settingList.get(i)).getValue()).split("_");
List<TextFieldWidget> fields = new ArrayList<TextFieldWidget>();
GuiTextLabel settingLabel = new GuiTextLabel(this.width / 2 - 152 + i % 2 * 160, this.height / 6 - 8 + 20 * (i >> 1), this.settings.getButtonString(settingList.get(i)));
labelList.add(settingLabel);
TextFieldWidget xPos = new TextFieldWidgetMod(fontRenderer, ValueType.POSITION, this.width / 2 - 100 + i % 2 * 160, this.height / 6 - 12 + 20 * (i >> 1), 45, 15, new TranslatableText(values[0]));
xPos.setText(values[0]);
xPos.setMaxLength(6);
this.addDrawableChild(xPos);
fields.add(xPos);
TextFieldWidget yPos = new TextFieldWidgetMod(fontRenderer, ValueType.POSITION, this.width / 2 - 100 + i % 2 * 160 + 48, this.height / 6 - 12 + 20 * (i >> 1), 45, 15, new TranslatableText(values[1]));
yPos.setText(values[1]);
yPos.setMaxLength(6);
this.addDrawableChild(yPos);
fields.add(yPos);
textFields.put(settingList.get(i), fields);
} else if (this.settings.getSetting(settingList.get(i)) instanceof SettingDouble) {
List<TextFieldWidget> fields = new ArrayList<TextFieldWidget>();
GuiTextLabel scaleLabel = new GuiTextLabel(this.width / 2 - 151 + i % 2 * 160, this.height / 6 - 8 + 20 * (i >> 1), this.settings.getButtonString(settingList.get(i)));
TextFieldWidget scale = new TextFieldWidgetMod(fontRenderer, ValueType.DOUBLE, this.width / 2 - 100 + i % 2 * 160 + 3, this.height / 6 - 12 + 20 * (i >> 1), 90, 15, new TranslatableText(String.valueOf(this.settings.getDoubleValue(settingList.get(i)))));
scale.setText(String.valueOf(this.settings.getDoubleValue(settingList.get(i))));
labelList.add(scaleLabel);
this.addDrawableChild(scale);
fields.add(scale);
textFields.put(settingList.get(i), fields);
} else {
GuiButtonTooltip guismallbutton = new GuiButtonTooltip(this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 14 + 20 * (i >> 1), settingList.get(i), new TranslatableText(this.settings.getButtonString(settingList.get(i))), button -> {
GuiButtonTooltip b = (GuiButtonTooltip) button;
if (b.enumOptions != null) {
if (settings.getSetting(b.enumOptions) instanceof SettingColor) {
client.setScreen(new GuiSettingsModColor(instance, b.enumOptions, new TranslatableText("gui.settings.rpghud")));
} else {
settings.increment(b.enumOptions);
button.setMessage(new TranslatableText(settings.getButtonString(b.enumOptions)));
}
}
}).setTooltip(this.settings.getSetting(settingList.get(i)).getTooltip());
this.addDrawableChild(guismallbutton);
}
}
}
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 168, 200, 20, new TranslatableText("gui.done"), button -> {
Settings settings = ModRPGHud.instance.settings;
for (String settingID : textFields.keySet()) {
for (TextFieldWidget t : textFields.get(settingID)) {
if (t instanceof TextFieldWidgetMod) {
ValueType type = ((TextFieldWidgetMod) t).getValueType();
switch(type) {
case DOUBLE:
double value;
try {
value = Double.valueOf(textFields.get(settingID).get(0).getText());
this.settings.getSetting(settingID).setValue(value);
} catch (NumberFormatException e) {
}
break;
case POSITION:
this.settings.getSetting(settingID).setValue(textFields.get(settingID).get(0).getText() + "_" + textFields.get(settingID).get(1).getText());
break;
}
}
}
}
settings.saveSettings();
client.setScreen(parent);
}));
}
use of net.minecraft.client.font.TextRenderer in project KiwiClient by TangyKiwi.
the class InGameHudMixin method render.
@Inject(method = "render", at = @At(value = "TAIL"), cancellable = true)
private void render(CallbackInfo info) {
if (!MinecraftClient.getInstance().options.debugEnabled) {
MinecraftClient client = MinecraftClient.getInstance();
TextRenderer textRenderer = client.textRenderer;
TextureManager textureManager = client.getTextureManager();
MatrixStack matrixStack = new MatrixStack();
RenderSystem.setShaderTexture(0, KiwiClient.DUCK);
client.inGameHud.drawTexture(matrixStack, 0, 0, 0, 0, 130, 130);
}
DrawOverlayEvent event = new DrawOverlayEvent(new MatrixStack());
KiwiClient.eventBus.post(event);
if (event.isCancelled())
info.cancel();
}
use of net.minecraft.client.font.TextRenderer in project meteor-client by MeteorDevelopment.
the class ContainerButtonWidget method renderButton.
@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
MinecraftClient minecraftClient = MinecraftClient.getInstance();
TextRenderer textRenderer = minecraftClient.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);
}
Aggregations