Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package th.pack.mods;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.Gui;
- import net.minecraft.client.settings.KeyBinding;
- import org.lwjgl.input.Keyboard;
- import org.lwjgl.opengl.GL11;
- public class SpaceButton
- {
- private final Minecraft mc;
- private final KeyBinding key;
- private final int xOffset;
- private final int yOffset;
- private boolean wasPressed;
- private long lastPress;
- private int color;
- private double textBrightness;
- public SpaceButton(KeyBinding key, int xOffset, int yOffset) {
- this.mc = Minecraft.getMinecraft();
- this.wasPressed = true;
- this.lastPress = 0L;
- this.color = 255;
- this.textBrightness = 1.0d;
- this.key = key;
- this.xOffset = xOffset;
- this.yOffset = yOffset;
- }
- public void renderSpaceKey(int x, int y, int textColor) {
- final boolean pressed = this.key.isKeyDown();
- final String name = Keyboard.getKeyName(this.key.getKeyCode());
- final String SZMUL = "§l§m--------";
- if (pressed != this.wasPressed) {
- this.wasPressed = pressed;
- this.lastPress = System.currentTimeMillis();
- }
- if (pressed) {
- this.color = Math.min(255, (int)(2L * (System.currentTimeMillis() - this.lastPress)));
- this.textBrightness = Math.max(0.0, 1.0 - (System.currentTimeMillis() - this.lastPress) / 20.0);
- } else {
- this.color = Math.max(0, 255 - (int)(2L * (System.currentTimeMillis() - this.lastPress)));
- this.textBrightness = Math.min(1.0, (System.currentTimeMillis() - this.lastPress) / 20.0);
- }
- Gui.drawRect(x + this.xOffset, y + this.yOffset, x + this.xOffset + 70, y + this.yOffset + 16, 2013265920 + (this.color << 16) + (this.color << 8) + this.color);
- final int red = textColor >> 16 & 0xFF;
- final int green = textColor >> 8 & 0xFF;
- final int blue = textColor & 0xFF;
- mc.fontRendererObj.drawString(SZMUL, x + this.xOffset + 8, y + this.yOffset + 4, -16777216 + ((int)(red * this.textBrightness) << 16) + ((int)(green * this.textBrightness) << 8) + (int)(blue * this.textBrightness));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement