Skip to content

Commit

Permalink
Finished mana bar for the most part, added feature to avoid skeleton …
Browse files Browse the repository at this point in the history
…hat bones from blocking your hits.
  • Loading branch information
biscuut committed Jul 1, 2019
1 parent abd62f9 commit 9e7eefd
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 122 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "1.0"
version = "1.0-b1"
group= "codes.biscuit.skyblockaddons" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "SkyblockAddons"

Expand Down
67 changes: 67 additions & 0 deletions src/main/java/codes/biscuit/skyblockaddons/gui/ButtonLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package codes.biscuit.skyblockaddons.gui;

import codes.biscuit.skyblockaddons.SkyblockAddons;
import codes.biscuit.skyblockaddons.utils.ConfigColor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;

import java.awt.*;

public class ButtonLocation extends GuiButton {

private SkyblockAddons main;

ButtonLocation(int buttonId, double x, double y, String buttonText, SkyblockAddons main, int width, int height) {
super(buttonId, (int)x, (int)y, buttonText);
this.main = main;
this.width = width;
this.height = height;
}

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (visible) {
ScaledResolution sr = new ScaledResolution(mc);
xPosition = (int)(main.getConfigValues().getManaBarX()*sr.getScaledWidth());
yPosition = (int)(main.getConfigValues().getManaBarY()*sr.getScaledHeight());
hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
int boxAlpha = 100;
if (hovered) {
boxAlpha = 170;
}
int boxColor = ConfigColor.GRAY.getColor(boxAlpha);
drawRect(xPosition, yPosition, xPosition+this.width, yPosition+this.height, boxColor);
GlStateManager.enableBlend();
mc.getTextureManager().bindTexture(icons);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableBlend();

short barWidth = 92;

float manaFill = (float) 99 / 123;
int filled = (int) (manaFill * barWidth);
drawTexturedModalRect(xPosition+14, yPosition+10, 10, 84, barWidth, 5);
if (filled > 0) {
drawTexturedModalRect(xPosition+14, yPosition+10, 10, 89, filled, 5);
}

int color = new Color(47, 71, 249).getRGB();
String text = 99 + "/" + 123;
int x = xPosition+60 - mc.ingameGUI.getFontRenderer().getStringWidth(text)/2;
int y = yPosition+4;
FontRenderer fontRenderer = mc.ingameGUI.getFontRenderer();
fontRenderer.drawString(text, x + 1, y, 0);
fontRenderer.drawString(text, x - 1, y, 0);
fontRenderer.drawString(text, x, y + 1, 0);
fontRenderer.drawString(text, x, y - 1, 0);
fontRenderer.drawString(text, x, y, color);
GlStateManager.enableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

GlStateManager.disableBlend();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
boxColor = ConfigColor.RED.getColor(boxAlpha * alphaMultiplier);
}
}
} else if (feature.getButtonType() == Feature.ButtonType.SOLID) {
if (feature == Feature.MANA_LOCATION) {
boxColor = ConfigColor.GREEN.getColor(boxAlpha * alphaMultiplier);
} else {
boxColor = ConfigColor.RED.getColor(boxAlpha * alphaMultiplier);
}
} else {
boxColor = ConfigColor.GRAY.getColor(boxAlpha * alphaMultiplier);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package codes.biscuit.skyblockaddons.gui;

import codes.biscuit.skyblockaddons.SkyblockAddons;
import codes.biscuit.skyblockaddons.utils.Feature;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;

import java.awt.*;

public class LocationEditGui extends GuiScreen {

private SkyblockAddons main;
private boolean dragging = false;

LocationEditGui(SkyblockAddons main) {
this.main = main;
}

@Override
public void initGui() {
int halfWidth = width/2;
int boxWidth = 120;
int boxHeight = 20;
buttonList.add(new ButtonLocation(0, halfWidth-boxWidth-30, height*0.25, "Move This", main, boxWidth, boxHeight));
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
buttonList.add(new ButtonRegular(0, scaledResolution.getScaledWidth()/2-boxWidth/2, scaledResolution.getScaledHeight()/2-boxHeight/2,
"Reset Location", main, Feature.RESET_LOCATION, boxWidth, boxHeight));
}


@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
float alphaMultiplier = 0.5F;
int alpha = (int)(255*alphaMultiplier); // Alpha of the text will increase from 0 to 127 over 500ms.

int startColor = new Color(0,0, 0, alpha).getRGB();
int endColor = new Color(0,0, 0, (int)(alpha*1.5)).getRGB();
drawGradientRect(0, 0, width, height, startColor, endColor);

super.drawScreen(mouseX, mouseY, partialTicks); // Draw buttons.
}


@Override
protected void actionPerformed(GuiButton abstractButton) {
if (abstractButton instanceof ButtonLocation) {
dragging = true;
} else {
ScaledResolution sr = new ScaledResolution(mc);
main.getConfigValues().setManaBarX(width/2-60, sr.getScaledWidth());
main.getConfigValues().setManaBarY(height/2-40, sr.getScaledWidth());
}
}

@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
if (dragging) {
ScaledResolution sr = new ScaledResolution(mc);
main.getConfigValues().setManaBarX(mouseX-60, sr.getScaledWidth());
main.getConfigValues().setManaBarY(mouseY-10, sr.getScaledHeight());
}
}

@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
super.mouseReleased(mouseX, mouseY, state);
dragging = false;
}

@Override
public void onGuiClosed() {
main.getConfigValues().saveConfig();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import codes.biscuit.skyblockaddons.SkyblockAddons;
import codes.biscuit.skyblockaddons.utils.Feature;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
Expand Down Expand Up @@ -33,6 +34,7 @@ public void initGui() {
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-20, height*0.65, "Warning Color", main, Feature.WARNING_COLOR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+20, height*0.65, "Confirmation Color", main, Feature.CONFIRMATION_COLOR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-20, height*0.73, null, main, Feature.WARNING_TIME, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+20, height*0.73, "Edit Mana Location", main, Feature.MANA_LOCATION, boxWidth, boxHeight));
boxWidth = 20;
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-125, height*0.73, "+", main, Feature.ADD, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth+5, height*0.73, "-", main, Feature.SUBTRACT, boxWidth, boxHeight));
Expand Down Expand Up @@ -104,6 +106,9 @@ protected void actionPerformed(GuiButton abstractButton) {
main.getConfigValues().setWarningSeconds(main.getConfigValues().getWarningSeconds() - 1);
}
}
} else if (feature == Feature.MANA_LOCATION) {
Minecraft.getMinecraft().displayGuiScreen(null);
Minecraft.getMinecraft().displayGuiScreen(new LocationEditGui(main));
}
}

Expand Down
Loading

0 comments on commit 9e7eefd

Please sign in to comment.