Начинающий
- Статус
- Оффлайн
- Регистрация
- 26 Фев 2024
- Сообщения
- 454
- Реакции
- 1
увидел что многие ставят либо хуйню которую спастили, либо хуйню которую сделали, по этому вот вам нормальные кейстрокесы, писал 15 минут
сс
когда не нажаты клавиши
когда нажаты все кроме спайса
KeyStrokesRenderer:
package ru.ancientmc.ui.display.impl;
import com.mojang.blaze3d.matrix.MatrixStack;
import ru.ancientmc.events.EventDisplay;
import ru.ancientmc.functions.impl.render.HUD;
import ru.ancientmc.ui.display.ElementRenderer;
import ru.ancientmc.utils.drag.Dragging;
import ru.ancientmc.utils.math.StopWatch;
import ru.ancientmc.utils.math.Vector4i;
import ru.ancientmc.utils.render.ColorUtils;
import ru.ancientmc.utils.render.DisplayUtils;
import ru.ancientmc.utils.render.Scissor;
import ru.ancientmc.utils.render.font.Fonts;
import ru.ancientmc.utils.text.GradientUtil;
import net.minecraft.util.math.vector.Vector4f;
import net.minecraft.util.text.ITextComponent;
public class KeyStrokesRenderer implements ElementRenderer {
private StopWatch time = new StopWatch();
private final Dragging dragging;
private float width;
private float height;
public void render(EventDisplay eventDisplay) {
MatrixStack ms = eventDisplay.getMatrixStack();
float posX = this.dragging.getX();
float posY = this.dragging.getY();
float padding = 3.0F;
float font_size = 8.0F;
float textPadding = 23.0F;
String w = "W";
String a = "A";
String s = "S";
String d = "D";
String space = "SPACE";
this.drawRect(posX, posY, this.width - 2.0F, this.height);
Fonts.sfbold.drawCenteredText(ms, w, posX + 43, posY + padding - 25, ColorUtils.rgb(0,0,0), font_size);
Fonts.sfbold.drawCenteredText(ms, a, posX - textPadding + 35, posY + padding + 6, ColorUtils.rgb(0,0,0), font_size );
Fonts.sfbold.drawCenteredText(ms, space, posX + 42, posY + 38.5F, ColorUtils.rgb(0,0,0), font_size );
Fonts.sfbold.drawCenteredText(ms, s, posX + 43, posY + padding + 6, ColorUtils.rgb(0,0,0), font_size );
Fonts.sfbold.drawCenteredText(ms, d, posX + textPadding + 50, posY + padding + 6, ColorUtils.rgb(0,0,0), font_size );
this.onClick(eventDisplay);
float maxWidth = Fonts.sfMedium.getWidth(w, font_size) + padding * 2.0F;
float localHeight = font_size + padding * 2.0F;
Scissor.push();
Scissor.setFromComponentCoordinates((double)posX, (double)posY, (double)(this.width - 2.0F), (double)this.height);
Scissor.unset();
Scissor.pop();
this.width = Math.max(maxWidth, 80.0F);
this.height = localHeight + 2.5F;
this.dragging.setWidth(this.width);
this.dragging.setHeight(this.height);
}
public void drawRect(float x, float y, float width, float height) {
final Vector4i vector4i = new Vector4i(HUD.getColor(0, 1), HUD.getColor(0, 1), HUD.getColor(90, 1), HUD.getColor(90, 1));
width = 28.0F;
DisplayUtils.drawShadow(x + 30, y, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//S
DisplayUtils.drawShadow(x + 30, y, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//S
DisplayUtils.drawShadow(x + 30, y, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//S
DisplayUtils.drawRoundedRect(x + 30, y, width, height + 10,4, ColorUtils.rgba(255, 255, 255, 255));//S
DisplayUtils.drawShadow(x + 30, y - 30, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//W
DisplayUtils.drawShadow(x + 30, y - 30, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//W
DisplayUtils.drawShadow(x + 30, y - 30, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//W
DisplayUtils.drawRoundedRect(x + 30, y - 30, width, height + 10,4, ColorUtils.rgba(255, 255, 255, 255));//W
DisplayUtils.drawShadow(x, y + 30, width + 60, height + 7,4, ColorUtils.rgba(0, 0, 0, 255));//space
DisplayUtils.drawShadow(x, y + 30, width + 60, height + 7,4, ColorUtils.rgba(0, 0, 0, 255));//space
DisplayUtils.drawShadow(x, y + 30, width + 60, height + 7,4, ColorUtils.rgba(0, 0, 0, 255));//space
DisplayUtils.drawRoundedRect(x, y + 30, width + 60, height + 7,4, ColorUtils.rgba(255, 255, 255, 255));//space
DisplayUtils.drawShadow(x, y, width, height + 10, 4, ColorUtils.rgba(0, 0, 0, 255));//A
DisplayUtils.drawShadow(x, y, width, height + 10, 4, ColorUtils.rgba(0, 0, 0, 255));//A
DisplayUtils.drawShadow(x, y, width, height + 10, 4, ColorUtils.rgba(0, 0, 0, 255));//A
DisplayUtils.drawRoundedRect(x, y, width, height + 10, 4, ColorUtils.rgba(255, 255, 255, 255));//A
DisplayUtils.drawShadow(x + 60, y, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//D
DisplayUtils.drawShadow(x + 60, y, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//D
DisplayUtils.drawShadow(x + 60, y, width, height + 10,4, ColorUtils.rgba(0, 0, 0, 255));//D
DisplayUtils.drawRoundedRect(x + 60, y, width, height + 10,4, ColorUtils.rgba(255, 255, 255, 255));//D
}
public void onClick(EventDisplay eventDisplay) {
width = 28.0F;
MatrixStack ms = eventDisplay.getMatrixStack();
float posX = this.dragging.getX();
float posY = this.dragging.getY();
float x = this.dragging.getX();
float y = this.dragging .getY();
float font_size = 8.0F;
if (mc.gameSettings.keyBindBack.pressed) {
DisplayUtils.drawRoundedRect(x + 30,y,width,height + 10,4,ColorUtils.getColor(0));
String s = "S";
Fonts.sfbold.drawCenteredText(ms, s, posX + 43, posY + 9, ColorUtils.rgb(0,0,0), font_size ); //s
}
if (mc.gameSettings.keyBindJump.pressed) {
DisplayUtils.drawRoundedRect(x,y + 30,width + 60,height + 7,4,ColorUtils.getColor(0));
String space = "SPACE";
Fonts.sfbold.drawCenteredText(ms, space, posX + 42, posY + 38.5F, ColorUtils.rgb(0,0,0), font_size );//space
}
if (mc.gameSettings.keyBindForward.pressed) {
DisplayUtils.drawRoundedRect(x + 30,y - 30,width,height + 10,4,ColorUtils.getColor(0));
String w = "W";
Fonts.sfbold.drawCenteredText(ms, w, posX + 43, posY - 22 , ColorUtils.rgb(0,0,0), font_size);//w
}
if (mc.gameSettings.keyBindLeft.pressed) {
DisplayUtils.drawRoundedRect(x,y,width,height + 10,4,ColorUtils.getColor(0));
String a = "A";
Fonts.sfbold.drawCenteredText(ms, a, posX + 12, posY + 9, ColorUtils.rgb(0,0,0), font_size );//a
}
if (mc.gameSettings.keyBindRight.pressed) {
DisplayUtils.drawRoundedRect(x + 60,y,width,height + 10,4,ColorUtils.getColor(0));
String d = "D";
Fonts.sfbold.drawCenteredText(ms, d, posX + 73, posY + 9, ColorUtils.rgb(0,0,0), font_size );//d
}
}
public KeyStrokesRenderer(Dragging dragging) {
this.dragging = dragging;
}
}
сс
когда не нажаты клавиши
когда нажаты все кроме спайса