Skip to content

Commit

Permalink
Added option to completely hide bones from showing. Added "bones bar"…
Browse files Browse the repository at this point in the history
… that displays an overlay of how many bones you have left.
  • Loading branch information
biscuut committed Jul 2, 2019
1 parent 9e7eefd commit 9ff3afa
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 86 deletions.
95 changes: 60 additions & 35 deletions src/main/java/codes/biscuit/skyblockaddons/gui/ButtonLocation.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package codes.biscuit.skyblockaddons.gui;

import codes.biscuit.skyblockaddons.SkyblockAddons;
import codes.biscuit.skyblockaddons.listeners.PlayerListener;
import codes.biscuit.skyblockaddons.utils.ConfigColor;
import codes.biscuit.skyblockaddons.utils.Feature;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
Expand All @@ -13,10 +15,12 @@
public class ButtonLocation extends GuiButton {

private SkyblockAddons main;
private Feature feature;

ButtonLocation(int buttonId, double x, double y, String buttonText, SkyblockAddons main, int width, int height) {
super(buttonId, (int)x, (int)y, buttonText);
ButtonLocation(int buttonId, SkyblockAddons main, int width, int height, Feature feature) {
super(buttonId, 0, 0, null);
this.main = main;
this.feature = feature;
this.width = width;
this.height = height;
}
Expand All @@ -25,43 +29,64 @@ public class ButtonLocation extends GuiButton {
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();
if (feature == Feature.MANA_BAR) {
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;
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);
}
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);
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();
GlStateManager.disableBlend();
} else {
xPosition = (int) (main.getConfigValues().getSkeletonBarX() * sr.getScaledWidth());
yPosition = (int) (main.getConfigValues().getSkeletonBarY() * 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);
int width = (int)(main.getConfigValues().getSkeletonBarX()*sr.getScaledWidth());
int height = (int)(main.getConfigValues().getSkeletonBarY()*sr.getScaledHeight());
for (int boneCounter = 0; boneCounter < 3; boneCounter++) {
mc.getRenderItem().renderItemIntoGUI(PlayerListener.BONE, width+(boneCounter*15)+2, height+2);
}
}
}
}

Feature getFeature() {
return feature;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
}
}
} else if (feature.getButtonType() == Feature.ButtonType.SOLID) {
if (feature == Feature.MANA_LOCATION) {
if (feature == Feature.EDIT_LOCATIONS) {
boxColor = ConfigColor.GREEN.getColor(boxAlpha * alphaMultiplier);
} else {
boxColor = ConfigColor.RED.getColor(boxAlpha * alphaMultiplier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@
public class LocationEditGui extends GuiScreen {

private SkyblockAddons main;
private boolean dragging = false;
private boolean draggingMana = false;
private boolean draggingSkeleton = 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));
buttonList.add(new ButtonLocation(0, main, boxWidth, boxHeight, Feature.MANA_BAR));
boxWidth = 50;
buttonList.add(new ButtonLocation(1, main, boxWidth, boxHeight, Feature.SKELETON_BAR));
boxWidth = 100;
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));
"Reset Locations", main, Feature.RESET_LOCATION, boxWidth, boxHeight));
}


Expand All @@ -46,28 +49,39 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
@Override
protected void actionPerformed(GuiButton abstractButton) {
if (abstractButton instanceof ButtonLocation) {
dragging = true;
ButtonLocation buttonLocation = (ButtonLocation)abstractButton;
if (buttonLocation.getFeature() == Feature.MANA_BAR) {
draggingMana = true;
} else {
draggingSkeleton = true;
}
} else {
ScaledResolution sr = new ScaledResolution(mc);
main.getConfigValues().setManaBarX(width/2-60, sr.getScaledWidth());
main.getConfigValues().setManaBarY(height/2-40, sr.getScaledWidth());
main.getConfigValues().setManaBarY(height/2-70, sr.getScaledHeight());
main.getConfigValues().setSkeletonBarX(width/2-25, sr.getScaledWidth());
main.getConfigValues().setSkeletonBarY(height/2-40, sr.getScaledHeight());
}
}

@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);
ScaledResolution sr = new ScaledResolution(mc);
if (draggingMana) {
main.getConfigValues().setManaBarX(mouseX-60, sr.getScaledWidth());
main.getConfigValues().setManaBarY(mouseY-10, sr.getScaledHeight());
} else if (draggingSkeleton) {
main.getConfigValues().setSkeletonBarX(mouseX-25, sr.getScaledWidth());
main.getConfigValues().setSkeletonBarY(mouseY-10, sr.getScaledHeight());
}
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ public SkyblockAddonsGui(SkyblockAddons main) {
@Override
public void initGui() {
int halfWidth = width/2;
int boxWidth = 120;
int boxWidth = 130;
int boxHeight = 20;
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-30, height*0.25, "Magma Boss Warning", main, Feature.MAGMA_WARNING, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+30, height*0.25, "Item Drop Confirmation", main, Feature.DROP_CONFIRMATION, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-30, height*0.35, null, main, Feature.MANA_BAR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-30, height*0.33, null, main, Feature.MANA_BAR, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth+30, height*0.33, "Hide Skeleton Hat Bones", main, Feature.BONES, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-boxWidth-30, height*0.41, "Skeleton Hat Bones Bar", main, Feature.SKELETON_BAR, boxWidth, boxHeight));
boxWidth = 200;
buttonList.add(new ButtonRegular(0, halfWidth-100, height*0.45, "Disable Ember Rod Ability on Island", main, Feature.DISABLE_EMBER_ROD, boxWidth, boxHeight));
buttonList.add(new ButtonRegular(0, halfWidth-100, height*0.49, "Disable Ember Rod Ability on Island", main, Feature.DISABLE_EMBER_ROD, boxWidth, boxHeight));
boxWidth = 100;
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));
buttonList.add(new ButtonRegular(0, halfWidth+20, height*0.73, "Edit Locations", main, Feature.EDIT_LOCATIONS, 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 @@ -106,7 +108,7 @@ protected void actionPerformed(GuiButton abstractButton) {
main.getConfigValues().setWarningSeconds(main.getConfigValues().getWarningSeconds() - 1);
}
}
} else if (feature == Feature.MANA_LOCATION) {
} else if (feature == Feature.EDIT_LOCATIONS) {
Minecraft.getMinecraft().displayGuiScreen(null);
Minecraft.getMinecraft().displayGuiScreen(new LocationEditGui(main));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityMagmaCube;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
Expand All @@ -29,6 +33,8 @@

public class PlayerListener {

public final static ItemStack BONE = new ItemStack(Item.getItemById(352));

private boolean predictMana = false;
private int mana = 0;
private int maxMana = 100;
Expand Down Expand Up @@ -107,40 +113,58 @@ public void onChatReceive(ClientChatReceivedEvent e) {
@SubscribeEvent()
public void onRenderManaBar(RenderGameOverlayEvent.Post e) {
Minecraft mc = Minecraft.getMinecraft();
if (e.type == RenderGameOverlayEvent.ElementType.EXPERIENCE && Utils.isOnSkyblock() && main.getConfigValues().getManaBarType() != Feature.ManaBarType.OFF
&& !(mc.currentScreen instanceof LocationEditGui)) {
mc.getTextureManager().bindTexture(icons);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableBlend();

short barWidth = 92;
ScaledResolution sr = new ScaledResolution(mc);
int left = (int)(main.getConfigValues().getManaBarX()*sr.getScaledWidth())+14;

if (main.getConfigValues().getManaBarType() == Feature.ManaBarType.BAR
|| main.getConfigValues().getManaBarType() == Feature.ManaBarType.BAR_TEXT) {
float manaFill = (float) mana / maxMana;
if (manaFill > 1) manaFill = 1;
int filled = (int) (manaFill * barWidth);
int top = (int)(main.getConfigValues().getManaBarY()*sr.getScaledHeight())+10;
mc.ingameGUI.drawTexturedModalRect(left, top, 10, 84, barWidth, 5);
if (filled > 0) {
mc.ingameGUI.drawTexturedModalRect(left, top, 10, 89, filled, 5);
if (e.type == RenderGameOverlayEvent.ElementType.EXPERIENCE && Utils.isOnSkyblock()) {
if (main.getConfigValues().getManaBarType() != Feature.ManaBarType.OFF && !(mc.currentScreen instanceof LocationEditGui)) {
mc.getTextureManager().bindTexture(icons);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableBlend();

short barWidth = 92;
ScaledResolution sr = new ScaledResolution(mc);
int left = (int) (main.getConfigValues().getManaBarX() * sr.getScaledWidth()) + 14;

if (main.getConfigValues().getManaBarType() == Feature.ManaBarType.BAR
|| main.getConfigValues().getManaBarType() == Feature.ManaBarType.BAR_TEXT) {
float manaFill = (float) mana / maxMana;
if (manaFill > 1) manaFill = 1;
int filled = (int) (manaFill * barWidth);
int top = (int) (main.getConfigValues().getManaBarY() * sr.getScaledHeight()) + 10;
mc.ingameGUI.drawTexturedModalRect(left, top, 10, 84, barWidth, 5);
if (filled > 0) {
mc.ingameGUI.drawTexturedModalRect(left, top, 10, 89, filled, 5);
}
}
if (main.getConfigValues().getManaBarType() == Feature.ManaBarType.TEXT
|| main.getConfigValues().getManaBarType() == Feature.ManaBarType.BAR_TEXT) {
int color = new Color(47, 71, 249).getRGB();
String text = mana + "/" + maxMana;
int x = (int) (main.getConfigValues().getManaBarX() * sr.getScaledWidth()) + 60 - mc.ingameGUI.getFontRenderer().getStringWidth(text) / 2;
int y = (int) (main.getConfigValues().getManaBarY() * sr.getScaledHeight()) + 4;
mc.ingameGUI.getFontRenderer().drawString(text, x + 1, y, 0);
mc.ingameGUI.getFontRenderer().drawString(text, x - 1, y, 0);
mc.ingameGUI.getFontRenderer().drawString(text, x, y + 1, 0);
mc.ingameGUI.getFontRenderer().drawString(text, x, y - 1, 0);
mc.ingameGUI.getFontRenderer().drawString(text, x, y, color);
GlStateManager.enableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
}
}
if (main.getConfigValues().getManaBarType() == Feature.ManaBarType.TEXT
|| main.getConfigValues().getManaBarType() == Feature.ManaBarType.BAR_TEXT) {
int color = new Color(47, 71, 249).getRGB();
String text = mana + "/" + maxMana;
int x = (int)(main.getConfigValues().getManaBarX()*sr.getScaledWidth())+ 60-mc.ingameGUI.getFontRenderer().getStringWidth(text)/2;
int y = (int)(main.getConfigValues().getManaBarY()*sr.getScaledHeight()) + 4;
mc.ingameGUI.getFontRenderer().drawString(text, x + 1, y, 0);
mc.ingameGUI.getFontRenderer().drawString(text, x - 1, y, 0);
mc.ingameGUI.getFontRenderer().drawString(text, x, y + 1, 0);
mc.ingameGUI.getFontRenderer().drawString(text, x, y - 1, 0);
mc.ingameGUI.getFontRenderer().drawString(text, x, y, color);
GlStateManager.enableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if ((!main.getConfigValues().getDisabledFeatures().contains(Feature.SKELETON_BAR))
&& !(mc.currentScreen instanceof LocationEditGui)) {
ScaledResolution sr = new ScaledResolution(mc);
int width = (int)(main.getConfigValues().getSkeletonBarX()*sr.getScaledWidth());
int height = (int)(main.getConfigValues().getSkeletonBarY()*sr.getScaledHeight());
int bones = 0;
for (Entity listEntity : mc.theWorld.loadedEntityList) {
if (listEntity instanceof EntityItem &&
listEntity.ridingEntity instanceof EntityZombie && listEntity.ridingEntity.isInvisible()) {
bones++;
}
}
if (bones > 3) bones = 3;
for (int boneCounter = 0; boneCounter < bones; boneCounter++) {
mc.getRenderItem().renderItemIntoGUI(BONE, width+(boneCounter*15), height);
}
}
}
}
Expand Down
Loading

0 comments on commit 9ff3afa

Please sign in to comment.