use of net.minecraft.client.render.GameRenderer in project Hypnotic-Client by Hypnotic-Development.
the class ColorBox method render.
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, int offset) {
colorSet.displayName = colorSet.name;
sx = parent.getX() + 5;
sy = parent.getY() + 4 + offset + parent.getHeight() + 12;
ex = parent.getX() + parent.getWidth() - 17;
ey = parent.getY() + 4 + offset + parent.getHeight() + getHeight(parent.getWidth()) + 8;
RenderUtils.fill(matrices, parent.getX() + 1, parent.getY() + offset + parent.getHeight(), parent.getX() + parent.getWidth() - 1, parent.getY() + offset + parent.getHeight() * (open ? 8.5 : 2), new Color(40, 40, 40, 255).getRGB());
HypnoticScreen.fontSmall.drawWithShadow(matrices, colorSet.name, (int) sx, (int) sy - 12, -1);
HypnoticScreen.fontSmall.drawWithShadow(matrices, "#" + colorSet.getHex().toUpperCase(), (int) sx + HypnoticScreen.fontSmall.getStringWidth(colorSet.name) + (open ? 12 : 2), (int) sy - 12, colorSet.getRGB());
if (hovered((int) mouseX, (int) mouseY, sx + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + "#" + colorSet.getHex().toUpperCase()) + 4, sy - 12, (int) (sx + HypnoticScreen.fontSmall.getStringWidth(colorSet.name + "#" + colorSet.getHex().toUpperCase()) + 30), sy - 4) && !open) {
RenderUtils.setup2DRender(true);
RenderUtils.fill(matrices, mouseX, mouseY, mouseX + HypnoticScreen.fontSmall.getStringWidth("Right click me!") + 6, mouseY - 12, new Color(0, 0, 0, 200).getRGB());
HypnoticScreen.fontSmall.drawWithShadow(matrices, "Right click me!", mouseX + 2, mouseY - 10, -1);
RenderUtils.end2DRender();
if (rmDown)
open = true;
}
if (!open) {
RenderUtils.fill(matrices, sx + HypnoticScreen.fontSmall.getStringWidth(colorSet.name + "#" + colorSet.getHex().toUpperCase()) + 4, sy - 12, sx + HypnoticScreen.fontSmall.getStringWidth(colorSet.name + "#" + colorSet.getHex().toUpperCase()) + 30, sy - 4, colorSet.getColor().getRGB());
return;
}
RenderUtils.fill(matrices, sx + 3 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 4, sx + 27 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()), sy - 12, new Color(0, 0, 0, 200).getRGB());
RenderUtils.fill(matrices, sx, sy, ex, ey, -1);
int satColor = MathHelper.hsvToRgb(colorSet.hue, 1f, 1f);
int red = satColor >> 16 & 255;
int green = satColor >> 8 & 255;
int blue = satColor & 255;
RenderSystem.disableBlend();
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
// Draw the color
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(ex, sy, 0).color(red, green, blue, 255).next();
bufferBuilder.vertex(sx, sy, 0).color(red, green, blue, 0).next();
bufferBuilder.vertex(sx, ey, 0).color(red, green, blue, 0).next();
bufferBuilder.vertex(ex, ey, 0).color(red, green, blue, 255).next();
tessellator.draw();
// Draw the black stuff
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(ex, sy, 0).color(0, 0, 0, 0).next();
bufferBuilder.vertex(sx, sy, 0).color(0, 0, 0, 0).next();
bufferBuilder.vertex(sx, ey, 0).color(0, 0, 0, 255).next();
bufferBuilder.vertex(ex, ey, 0).color(0, 0, 0, 255).next();
tessellator.draw();
RenderSystem.disableBlend();
RenderSystem.enableTexture();
// Set the color
if (hovered(mouseX, mouseY, sx, sy, ex, ey) && lmDown) {
colorSet.bri = 1f - 1f / ((float) (ey - sy) / (mouseY - sy));
colorSet.sat = 1f / ((float) (ex - sx) / (mouseX - sx));
}
int briY = (int) (ey - (ey - sy) * colorSet.bri);
int satX = (int) (sx + (ex - sx) * colorSet.sat);
RenderUtils.fill(matrices, satX - 2, briY - 2, satX + 2, briY + 2, Color.GRAY.brighter().getRGB(), Color.WHITE.darker().getRGB(), Color.WHITE.getRGB());
RenderUtils.fill(matrices, sx + 3 + HypnoticScreen.fontSmall.getStringWidth(colorSet.name), sy - 4, sx + 10 + HypnoticScreen.fontSmall.getStringWidth(colorSet.name), sy - 12, colorSet.getColor().getRGB());
if (hovered((int) mouseX, (int) mouseY, sx + 3 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name), sy - 12, sx + 10 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name), sy - 4) && open) {
RenderUtils.setup2DRender(true);
RenderUtils.fill(matrices, mouseX, mouseY, mouseX + HypnoticScreen.fontSmall.getStringWidth("Right click me!") + 6, mouseY - 12, new Color(0, 0, 0, 200).getRGB());
HypnoticScreen.fontSmall.drawWithShadow(matrices, "Right click me!", mouseX + 2, mouseY - 10, -1);
RenderUtils.end2DRender();
if (rmDown)
open = false;
}
// Set hex codes
if (hovered(mouseX, mouseY, sx + 3 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()) + 17, sy - 12, sx + 27 + (int) HypnoticScreen.fontSmall.getStringWidth(colorSet.name + colorSet.getHex().toUpperCase()), sy - 4)) {
RenderSystem.disableDepthTest();
RenderSystem.depthFunc(GL11.GL_ALWAYS);
RenderUtils.fill(matrices, mouseX, mouseY, mouseX + HypnoticScreen.fontSmall.getStringWidth("Sets the hex color to your current clipboard") + 6, mouseY - 12, new Color(0, 0, 0, 200).getRGB());
HypnoticScreen.fontSmall.drawWithShadow(matrices, "Sets the hex color to your current clipboard", mouseX + 2, mouseY - 10, -1);
RenderSystem.depthFunc(GL11.GL_LEQUAL);
RenderSystem.enableDepthTest();
if (lmDown && colorSet.getColor() != colorSet.hexToRgb(mc.keyboard.getClipboard())) {
Color hexColor = colorSet.hexToRgb(mc.keyboard.getClipboard());
float[] vals = colorSet.rgbToHsv(hexColor.getRed(), hexColor.getGreen(), hexColor.getBlue(), hexColor.getAlpha());
colorSet.setHSV(vals[0], vals[1], vals[2]);
h = vals[0];
s = vals[1];
v = vals[2];
}
}
sx = ex + 5;
ex = ex + 12;
for (int i = sy; i < ey; i++) {
float curHue = 1f / ((float) (ey - sy) / (i - sy));
DrawableHelper.fill(matrices, sx, i, ex, i + 1, 0xff000000 | MathHelper.hsvToRgb(curHue, 1f, 1f));
}
if (hovered(mouseX, mouseY, sx, sy, ex, ey) && lmDown) {
colorSet.hue = 1f / ((float) (ey - sy) / (mouseY - sy));
}
int hueY = (int) (sy + (ey - sy) * colorSet.hue);
RenderUtils.fill(matrices, sx, hueY - 2, ex, hueY + 2, Color.GRAY.brighter().getRGB(), Color.WHITE.darker().getRGB(), Color.WHITE.getRGB());
super.render(matrices, mouseX, mouseY, offset);
}
use of net.minecraft.client.render.GameRenderer in project Hypnotic-Client by Hypnotic-Development.
the class NahrFont method drawer.
private final void drawer(MatrixStack matrixStack, String text, float x, float y, int color) {
x *= 2.0F;
y *= 2.0F;
RenderUtils.setup2DRender(false);
RenderUtils.bindTexture(this.resourceLocation);
if ((color & -67108864) == 0) {
color |= -16777216;
}
int newColor = color;
float startX = x;
boolean scramble = false;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
for (int i = 0; i < text.length(); i++) if ((text.charAt(i) == '\247') && (i + 1 < text.length())) {
char oneMore = Character.toLowerCase(text.charAt(i + 1));
if (oneMore == 'n') {
y += this.theMetrics.getAscent() + 2;
x = startX;
} else if (oneMore == 'k') {
scramble = true;
} else if (oneMore == 'r')
newColor = color;
else {
newColor = getColorFromCode(oneMore);
}
i++;
} else {
try {
String obfText = "\\:><&%$@!/?";
char c = scramble ? obfText.charAt((int) (new Random().nextFloat() * (obfText.length() - 1))) : text.charAt(i);
drawChar(matrixStack, c, x, y, newColor);
x += getStringWidth(Character.toString(c)) * 2.0F;
} catch (ArrayIndexOutOfBoundsException indexException) {
char c = text.charAt(i);
System.err.println("Can't draw character: " + c + " (" + Character.getNumericValue(c) + ")");
}
}
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderUtils.shaderColor(0xffffffff);
}
use of net.minecraft.client.render.GameRenderer in project HWG by cybercat-mods.
the class GunTableScreen method render.
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
List<GunTableRecipe> tradeOfferList = this.handler.getRecipes();
if (!tradeOfferList.isEmpty()) {
int i = (this.width - this.backgroundWidth) / 2;
int j = (this.height - this.backgroundHeight) / 2;
int yPos = j + 17;
int xPos = i + 3;
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, TEXTURE);
this.renderScrollbar(matrices, i, j, tradeOfferList);
int m = 0;
while (true) {
for (GunTableRecipe gunTableRecipe : tradeOfferList) if (this.canScroll(tradeOfferList.size()) && (m < this.indexStartOffset || m >= 7 + this.indexStartOffset)) {
++m;
} else {
ItemStack output = gunTableRecipe.getOutput();
this.itemRenderer.zOffset = 100.0F;
int n = yPos + 2;
this.renderIngredients(matrices, gunTableRecipe, xPos, n);
this.renderArrow(matrices, gunTableRecipe, i + 22, n);
this.itemRenderer.renderInGui(output, i + 24 + 68, n);
this.itemRenderer.renderGuiItemOverlay(this.textRenderer, output, i + 24 + 68, n);
this.itemRenderer.zOffset = 0.0F;
yPos += 20;
++m;
}
for (WidgetButtonPage widgetButtonPage : this.offers) {
if (widgetButtonPage.isHovered()) {
widgetButtonPage.renderToolTip(matrices, mouseX, mouseY);
}
widgetButtonPage.visible = widgetButtonPage.index < this.handler.getRecipes().size();
}
RenderSystem.enableDepthTest();
break;
}
}
this.drawMouseoverTooltip(matrices, mouseX, mouseY);
}
use of net.minecraft.client.render.GameRenderer in project custom-stars by b3spectacled.
the class MixinWorldRenderer method reloadStars.
@Inject(method = "renderSky(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Matrix4f;FLnet/minecraft/client/render/Camera;ZLjava/lang/Runnable;)V", at = @At("HEAD"))
private void reloadStars(CallbackInfo info) {
if (CustomStars.STARS_RERENDER_OBSERVER.update()) {
CustomStars.log(Level.INFO, "Star settings modified, reloading buffer...");
Tessellator tess = Tessellator.getInstance();
BufferBuilder builder = tess.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionShader);
this.starsBuffer = new VertexBuffer();
((MixinWorldRendererInvoker) this).rerenderStars(builder);
builder.end();
this.starsBuffer.upload(builder);
}
}
use of net.minecraft.client.render.GameRenderer in project WildfireFemaleGenderMod by WildfireRomeo.
the class WildfireCharacterSettingsScreen method render.
@Override
public void render(MatrixStack m, int f1, int f2, float f3) {
super.renderBackground(m);
PlayerEntity plrEntity = MinecraftClient.getInstance().world.getPlayerByUuid(this.playerUUID);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
if (this.BACKGROUND != null) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, this.BACKGROUND);
}
int i = (this.width - 172) / 2;
int j = (this.height - 124) / 2;
drawTexture(m, i, j, 0, 0, 172, 144);
int x = this.width / 2;
int y = this.height / 2;
this.textRenderer.draw(m, getTitle(), x - 79, yPos - 10, 4473924);
super.render(m, f1, f2, f3);
if (plrEntity != null) {
Screen.drawCenteredText(m, this.textRenderer, plrEntity.getDisplayName(), x, yPos - 30, 0xFFFFFF);
}
if (bounceWarning) {
Screen.drawCenteredText(m, this.textRenderer, new TranslatableText("wildfire_gender.tooltip.bounce_warning").formatted(Formatting.ITALIC), x, y + 90, 0xFF6666);
}
}
Aggregations