diff --git a/build.gradle b/build.gradle index f7d9b12aec..4ae6610675 100644 --- a/build.gradle +++ b/build.gradle @@ -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" diff --git a/src/main/java/codes/biscuit/skyblockaddons/gui/ButtonLocation.java b/src/main/java/codes/biscuit/skyblockaddons/gui/ButtonLocation.java new file mode 100644 index 0000000000..60538eb66b --- /dev/null +++ b/src/main/java/codes/biscuit/skyblockaddons/gui/ButtonLocation.java @@ -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(); + } + } +} diff --git a/src/main/java/codes/biscuit/skyblockaddons/gui/ButtonRegular.java b/src/main/java/codes/biscuit/skyblockaddons/gui/ButtonRegular.java index b4d0071905..41c815a952 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/gui/ButtonRegular.java +++ b/src/main/java/codes/biscuit/skyblockaddons/gui/ButtonRegular.java @@ -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); } diff --git a/src/main/java/codes/biscuit/skyblockaddons/gui/LocationEditGui.java b/src/main/java/codes/biscuit/skyblockaddons/gui/LocationEditGui.java new file mode 100644 index 0000000000..f162dbdddd --- /dev/null +++ b/src/main/java/codes/biscuit/skyblockaddons/gui/LocationEditGui.java @@ -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(); + } +} diff --git a/src/main/java/codes/biscuit/skyblockaddons/gui/SkyblockAddonsGui.java b/src/main/java/codes/biscuit/skyblockaddons/gui/SkyblockAddonsGui.java index 7f3f6ebce2..60fbc086e0 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/gui/SkyblockAddonsGui.java +++ b/src/main/java/codes/biscuit/skyblockaddons/gui/SkyblockAddonsGui.java @@ -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; @@ -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)); @@ -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)); } } diff --git a/src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java b/src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java index f6ebd36dd5..e74714bb23 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java +++ b/src/main/java/codes/biscuit/skyblockaddons/listeners/PlayerListener.java @@ -1,20 +1,16 @@ package codes.biscuit.skyblockaddons.listeners; import codes.biscuit.skyblockaddons.SkyblockAddons; +import codes.biscuit.skyblockaddons.gui.LocationEditGui; import codes.biscuit.skyblockaddons.gui.SkyblockAddonsGui; import codes.biscuit.skyblockaddons.utils.Feature; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; +import codes.biscuit.skyblockaddons.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityMagmaCube; import net.minecraft.entity.monster.EntitySlime; -import net.minecraft.scoreboard.Score; -import net.minecraft.scoreboard.ScoreObjective; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; @@ -25,12 +21,9 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import java.awt.*; -import java.util.Collection; -import java.util.List; import java.util.Timer; import java.util.TimerTask; import java.util.regex.Pattern; -import java.util.stream.Collectors; import static net.minecraft.client.gui.Gui.icons; @@ -84,113 +77,81 @@ public void onRenderBossWarning(RenderGameOverlayEvent.Post e) { @SubscribeEvent() public void onChatReceive(ClientChatReceivedEvent e) { - if (e.type == 2 && main.getConfigValues().getManaBarType() != Feature.ManaBarType.OFF) { // Render a title-like warning. + if (main.getConfigValues().getManaBarType() != Feature.ManaBarType.OFF) { String message = e.message.getUnformattedText(); - if (message.contains("\u270E Mana")) { - String[] manaSplit = message.split(Pattern.quote("\u270E Mana")); - if (manaSplit.length > 1) { - if (manaSplit[0].contains(EnumChatFormatting.AQUA.toString())) { - message = manaSplit[0].split(Pattern.quote(EnumChatFormatting.AQUA.toString()))[1]; - manaSplit = message.split(Pattern.quote("/")); - mana = Integer.parseInt(manaSplit[0]); - maxMana = Integer.parseInt(manaSplit[1]); - e.message = new ChatComponentText(e.message.getUnformattedText().split(EnumChatFormatting.AQUA.toString())[0].trim()); - predictMana = false; - return; + if (e.type == 2) { + if (message.contains("\u270E Mana")) { + String[] manaSplit = message.split(Pattern.quote("\u270E Mana")); + if (manaSplit.length > 1) { + if (manaSplit[0].contains(EnumChatFormatting.AQUA.toString())) { + message = manaSplit[0].split(Pattern.quote(EnumChatFormatting.AQUA.toString()))[1]; + manaSplit = message.split(Pattern.quote("/")); + mana = Integer.parseInt(manaSplit[0]); + maxMana = Integer.parseInt(manaSplit[1]); + e.message = new ChatComponentText(e.message.getUnformattedText().split(EnumChatFormatting.AQUA.toString())[0].trim()); + predictMana = false; + return; + } } } + predictMana = true; + } else { + if (predictMana && message.startsWith("Used ") && message.endsWith("Mana)")) { + int mana = Integer.parseInt(message.split(Pattern.quote("! ("))[1].split(Pattern.quote(" Mana)"))[0]); + this.mana -= mana; + } } - predictMana = true; } } @SubscribeEvent() public void onRenderManaBar(RenderGameOverlayEvent.Post e) { - if (e.type == RenderGameOverlayEvent.ElementType.EXPERIENCE && main.getConfigValues().getManaBarType() != Feature.ManaBarType.OFF) { - Minecraft mc = Minecraft.getMinecraft(); - ScaledResolution res = new ScaledResolution(mc); - int width = res.getScaledWidth(); - int height = res.getScaledHeight(); + 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; - int left = width / 2 - 91 + barWidth; + 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 = height - 59; + 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 = ((width - mc.ingameGUI.getFontRenderer().getStringWidth(text)) / 2) + (barWidth / 2); - int y = height - 65; - 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); } } } -// Minecraft mc = Minecraft.getMinecraft(); -// ScaledResolution p_175176_1_ = new ScaledResolution(mc); -// int p_175176_2_ = p_175176_1_.getScaledWidth() / 2 - 91; -// mc.getTextureManager().bindTexture(icons); -// int i = mc.thePlayer.xpBarCap(); -// -// if (i > 0) -// { -// int j = 182; //182 -// int k = (int)(mc.thePlayer.experience * (float)(j + 1)); -// int l = p_175176_1_.getScaledHeight() - 20 + 3; // p_175176_1_.getScaledHeight() - 32 + 3 -// mc.ingameGUI.drawTexturedModalRect(p_175176_2_, l, 0, 64, j, 5); -// -// if (k > 0) -// { -// mc.ingameGUI.drawTexturedModalRect(p_175176_2_, l, 0, 69, k, 5); -// } -// } -// -// mc.mcProfiler.endSection(); -// -// if (mc.thePlayer.experienceLevel > 0) -// { -// mc.mcProfiler.startSection("expLevel"); -// int k1 = 8453920; -// String s = "" + mc.thePlayer.experienceLevel; -// int l1 = (p_175176_1_.getScaledWidth() - mc.ingameGUI.getFontRenderer().getStringWidth(s)) / 2; -// int i1 = p_175176_1_.getScaledHeight() - 31 - 4; -// int j1 = 0; -// mc.ingameGUI.getFontRenderer().drawString(s, l1 + 1, i1, 0); -// mc.ingameGUI.getFontRenderer().drawString(s, l1 - 1, i1, 0); -// mc.ingameGUI.getFontRenderer().drawString(s, l1, i1 + 1, 0); -// mc.ingameGUI.getFontRenderer().drawString(s, l1, i1 - 1, 0); -// mc.ingameGUI.getFontRenderer().drawString(s, l1, i1, k1); -// mc.mcProfiler.endSection(); -// } - @SubscribeEvent() public void onInteract(PlayerInteractEvent e) { if (!main.getConfigValues().getDisabledFeatures().contains(Feature.DISABLE_EMBER_ROD)) { Minecraft mc = Minecraft.getMinecraft(); if (e.entityPlayer == mc.thePlayer && e.entityPlayer.getHeldItem() != null) { if (mc.thePlayer.getHeldItem().getItem().getRegistryName().equals("minecraft:blaze_rod") && mc.thePlayer.getHeldItem().isItemEnchanted()) { - if (isOnIsland()) { + if (Utils.isOnIsland()) { e.setCanceled(true); } } @@ -208,12 +169,12 @@ public void onTickMana(TickEvent.ClientTickEvent e) { if (mana>maxMana) mana = maxMana; } } else if (manaTick > 20) { + Utils.checkIfOnSkyblockAndIsland(); manaTick = 1; } } } - @SubscribeEvent() public void onTickSound(TickEvent.ClientTickEvent e) { if (e.phase == TickEvent.Phase.START && !main.getConfigValues().getDisabledFeatures().contains(Feature.MAGMA_WARNING)) { @@ -245,7 +206,6 @@ public void run() { } soundTick++; if (soundTick > 20) { - isOnIsland(); soundTick = 1; } } @@ -259,44 +219,11 @@ public void onRender(TickEvent.RenderTickEvent e) { } } - private boolean isOnIsland() { // Most of this is replicated from the scoreboard rendering code so not many comments here xD - Minecraft mc = Minecraft.getMinecraft(); - if (mc != null && mc.theWorld != null) { - Scoreboard scoreboard = mc.theWorld.getScoreboard(); - ScoreObjective scoreobjective = null; - ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(mc.thePlayer.getName()); - if (scoreplayerteam != null) { - int randomNumber = scoreplayerteam.getChatFormat().getColorIndex(); - if (randomNumber >= 0) { - scoreobjective = scoreboard.getObjectiveInDisplaySlot(3 + randomNumber); - } - } - ScoreObjective scoreobjective1 = scoreobjective != null ? scoreobjective : scoreboard.getObjectiveInDisplaySlot(1); - if (scoreobjective1 != null) { - Collection collection = scoreboard.getSortedScores(scoreobjective1); - List list = Lists.newArrayList(collection.stream().filter(score -> score.getPlayerName() != null && !score.getPlayerName().startsWith("#")).collect(Collectors.toList())); - if (list.size() > 15) { - collection = Lists.newArrayList(Iterables.skip(list, collection.size() - 15)); - } else { - collection = list; - } - for (Score score1 : collection) { - ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score1.getPlayerName()); - String s1 = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score1.getPlayerName()); - if (s1.equals(" \u00A77\u23E3 \u00A7aYour Isla\uD83C\uDFC0\u00A7and")) { - return true; - } - } - } - } - return false; - } - public boolean isBossWarning() { return bossWarning; } - // private void logServer(Minecraft mc) { + // private void logServer(Minecraft mc) { // for magma boss logs // if (mc.ingameGUI.getTabList().header != null) { // List siblings = mc.ingameGUI.getTabList().header.getSiblings(); // Bring back AT if doing this // if (siblings.size() > 2) { diff --git a/src/main/java/codes/biscuit/skyblockaddons/mixins/MixinEntityRenderer.java b/src/main/java/codes/biscuit/skyblockaddons/mixins/MixinEntityRenderer.java new file mode 100644 index 0000000000..afd982f9d1 --- /dev/null +++ b/src/main/java/codes/biscuit/skyblockaddons/mixins/MixinEntityRenderer.java @@ -0,0 +1,26 @@ +package codes.biscuit.skyblockaddons.mixins; + +import codes.biscuit.skyblockaddons.utils.Utils; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.util.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.List; + +@Mixin(EntityRenderer.class) +public class MixinEntityRenderer { + + @Inject(method = "getMouseOver", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", ordinal = 0), locals = LocalCapture.CAPTURE_FAILSOFT) + private void intersectsWith(float partialTicks, CallbackInfo ci, Entity entity, double d0, double d1, Vec3 vec3, boolean flag, boolean b, Vec3 vec31, Vec3 vec32, Vec3 vec33, float f, List list, double d2, int i) { + if (Utils.isOnSkyblock()) { + list.removeIf(listEntity -> listEntity instanceof EntityZombie && listEntity.isInvisible() && listEntity.riddenByEntity instanceof EntityItem); + } + } +} diff --git a/src/main/java/codes/biscuit/skyblockaddons/utils/ConfigValues.java b/src/main/java/codes/biscuit/skyblockaddons/utils/ConfigValues.java index 52cbeff589..ae41df18b0 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/utils/ConfigValues.java +++ b/src/main/java/codes/biscuit/skyblockaddons/utils/ConfigValues.java @@ -16,6 +16,8 @@ public class ConfigValues { private ConfigColor confirmationColor = ConfigColor.GRAY; private Feature.ManaBarType manaBarType = Feature.ManaBarType.BAR_TEXT; private int warningSeconds = 4; + private float manaBarX; + private float manaBarY; public ConfigValues(File configFile) { this.configFile = configFile; @@ -43,6 +45,12 @@ public void loadConfig() { if (loadedConfig.has("manaBarType")) { manaBarType = Feature.ManaBarType.values()[loadedConfig.get("manaBarType").getAsInt()]; } + if (loadedConfig.has("manaBarX")) { + manaBarX = loadedConfig.get("manaBarX").getAsFloat(); + } + if (loadedConfig.has("manaBarY")) { + manaBarY = loadedConfig.get("manaBarY").getAsFloat(); + } } catch (IOException e) { e.printStackTrace(); } @@ -68,6 +76,8 @@ public void saveConfig() { loadedConfig.addProperty("confirmationColor", confirmationColor.ordinal()); loadedConfig.addProperty("manaBarType", manaBarType.ordinal()); loadedConfig.addProperty("warningSeconds", warningSeconds); + loadedConfig.addProperty("manaBarX", manaBarX); + loadedConfig.addProperty("manaBarY", manaBarY); bufferedWriter.write(loadedConfig.toString()); bufferedWriter.close(); @@ -113,4 +123,20 @@ public int getWarningSeconds() { public void setWarningSeconds(int warningSeconds) { this.warningSeconds = warningSeconds; } + + public float getManaBarX() { + return manaBarX; + } + + public void setManaBarX(int x, int maxX) { + this.manaBarX = (float)x/maxX; + } + + public float getManaBarY() { + return manaBarY; + } + + public void setManaBarY(int y, int maxY) { + this.manaBarY = (float)y/maxY; + } } diff --git a/src/main/java/codes/biscuit/skyblockaddons/utils/Feature.java b/src/main/java/codes/biscuit/skyblockaddons/utils/Feature.java index 76f9d3a936..9125807083 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/utils/Feature.java +++ b/src/main/java/codes/biscuit/skyblockaddons/utils/Feature.java @@ -13,7 +13,10 @@ public enum Feature { WARNING_TIME(-1, ButtonType.NEUTRAL), ADD(-1, ButtonType.MODIFY), - SUBTRACT(-1, ButtonType.MODIFY); + SUBTRACT(-1, ButtonType.MODIFY), + + MANA_LOCATION(-1, ButtonType.SOLID), + RESET_LOCATION(-1, ButtonType.SOLID); private int id; private ButtonType buttonType; @@ -40,7 +43,8 @@ public enum ButtonType { REGULAR, COLOR, NEUTRAL, - MODIFY + MODIFY, + SOLID } public enum ManaBarType { diff --git a/src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java b/src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java index 397fb7225c..acab9daa04 100644 --- a/src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java +++ b/src/main/java/codes/biscuit/skyblockaddons/utils/Utils.java @@ -1,12 +1,26 @@ package codes.biscuit.skyblockaddons.utils; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import net.minecraft.client.Minecraft; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.ChatComponentText; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.common.MinecraftForge; +import java.util.Collection; +import java.util.List; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + public class Utils { + private static boolean onIsland = false; + private static boolean onSkyblock = false; + // Static cause I can't be bothered to pass the instance ok stop bullying me public static void sendMessage(String text) { ClientChatReceivedEvent event = new ClientChatReceivedEvent((byte)1, new ChatComponentText(text)); @@ -15,4 +29,54 @@ public static void sendMessage(String text) { Minecraft.getMinecraft().thePlayer.addChatMessage(event.message); // Just for logs } } + + public static void checkIfOnSkyblockAndIsland() { // Most of this is replicated from the scoreboard rendering code so not many comments here xD + Minecraft mc = Minecraft.getMinecraft(); + if (mc != null && mc.theWorld != null) { + Scoreboard scoreboard = mc.theWorld.getScoreboard(); + ScoreObjective scoreobjective = null; + ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(mc.thePlayer.getName()); + if (scoreplayerteam != null) { + int randomNumber = scoreplayerteam.getChatFormat().getColorIndex(); + if (randomNumber >= 0) { + scoreobjective = scoreboard.getObjectiveInDisplaySlot(3 + randomNumber); + } + } + ScoreObjective scoreobjective1 = scoreobjective != null ? scoreobjective : scoreboard.getObjectiveInDisplaySlot(1); + if (scoreobjective1 != null) { + String scoreboardTitle = scoreobjective1.getDisplayName(); + onSkyblock = stripColor(scoreboardTitle).startsWith("SKYBLOCK"); + Collection collection = scoreboard.getSortedScores(scoreobjective1); + List list = Lists.newArrayList(collection.stream().filter(score -> score.getPlayerName() != null && !score.getPlayerName().startsWith("#")).collect(Collectors.toList())); + if (list.size() > 15) { + collection = Lists.newArrayList(Iterables.skip(list, collection.size() - 15)); + } else { + collection = list; + } + for (Score score1 : collection) { + ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score1.getPlayerName()); + String s1 = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score1.getPlayerName()); + if (s1.equals(" \u00A77\u23E3 \u00A7aYour Isla\uD83C\uDFC0\u00A7and")) { + onIsland = true; + return; + } + } + } + } + onIsland = false; + } + + private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile( "(?i)" + '\u00A7' + "[0-9A-FK-OR]" ); + private static String stripColor(final String input) { + if (input == null) return null; + return STRIP_COLOR_PATTERN.matcher(input).replaceAll(""); + } + + public static boolean isOnIsland() { + return onIsland; + } + + public static boolean isOnSkyblock() { + return onSkyblock; + } } diff --git a/src/main/resources/mixins.skyblockaddons.json b/src/main/resources/mixins.skyblockaddons.json index 2fb8161df7..827f7c8740 100644 --- a/src/main/resources/mixins.skyblockaddons.json +++ b/src/main/resources/mixins.skyblockaddons.json @@ -5,6 +5,7 @@ "verbose": true, "mixins": [ "MixinEntityPlayerSP", - "MixinSoundManager" + "MixinSoundManager", + "MixinEntityRenderer" ] } \ No newline at end of file