-
-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished mana bar for the most part, added feature to avoid skeleton …
…hat bones from blocking your hits.
- Loading branch information
Showing
11 changed files
with
325 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/codes/biscuit/skyblockaddons/gui/ButtonLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/codes/biscuit/skyblockaddons/gui/LocationEditGui.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.