diff options
Diffstat (limited to 'src')
27 files changed, 737 insertions, 253 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 9d619c78..8a6f77ea 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -1,8 +1,10 @@ package io.github.moulberry.notenoughupdates; +import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.core.config.Position; @@ -12,11 +14,8 @@ import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.*; -import io.github.moulberry.notenoughupdates.overlays.CommissionOverlay; -import io.github.moulberry.notenoughupdates.overlays.FarmingOverlay; +import io.github.moulberry.notenoughupdates.overlays.*; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; -import io.github.moulberry.notenoughupdates.overlays.TextOverlay; -import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle; import io.github.moulberry.notenoughupdates.util.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -49,6 +48,7 @@ import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -140,19 +140,6 @@ public class NEUEventListener { private static final Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$"); - public static Class<? extends TextOverlay> dontRenderOverlay = null; - private final List<TextOverlay> textOverlays = new ArrayList<>(); - { - textOverlays.add(new CommissionOverlay(NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, () -> { - int style = NotEnoughUpdates.INSTANCE.config.mining.overlayStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { - return TextOverlayStyle.values()[style]; - } - return TextOverlayStyle.BACKGROUND; - })); - textOverlays.add(new FarmingOverlay(new Position(20, 300), () -> TextOverlayStyle.BACKGROUND)); - } - /** * 1)Will send the cached message from #sendChatMessage when at least 200ms has passed since the last message. * This is used in order to prevent the mod spamming messages. @@ -198,6 +185,12 @@ public class NEUEventListener { DungeonBlocks.tick(); } DungeonWin.tick(); + FlyFix.tick(); + + for(TextOverlay overlay : OverlayManager.textOverlays) { + overlay.shouldUpdateFrequent = true; + } + if(longUpdate) { /*for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { if(entity instanceof EntityArmorStand) { @@ -211,10 +204,11 @@ public class NEUEventListener { DwarvenMinesTextures.tick(); FairySouls.tick(); MiningStuff.tick(); + XPInformation.getInstance().tick(); ProfileApiSyncer.getInstance().tick(); DamageCommas.tick(); BackgroundBlur.tick(); - for(TextOverlay overlay : textOverlays) { + for(TextOverlay overlay : OverlayManager.textOverlays) { overlay.tick(); } if(TradeWindow.hypixelTradeWindowActive()) { @@ -425,13 +419,13 @@ public class NEUEventListener { long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis); if(event.type == RenderGameOverlayEvent.ElementType.ALL) { DungeonWin.render(event.partialTicks); - for(TextOverlay overlay : textOverlays) { - if(dontRenderOverlay != null && dontRenderOverlay.isAssignableFrom(overlay.getClass())) { + for(TextOverlay overlay : OverlayManager.textOverlays) { + if(OverlayManager.dontRenderOverlay != null && OverlayManager.dontRenderOverlay.isAssignableFrom(overlay.getClass())) { continue; } overlay.render(); } - dontRenderOverlay = null; + OverlayManager.dontRenderOverlay = null; } if(event.type == RenderGameOverlayEvent.ElementType.ALL && timeRemaining > 0 && notificationLines != null && notificationLines.size() > 0) { @@ -1259,6 +1253,30 @@ public class NEUEventListener { EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"VERY SPECIAL", EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD.toString()+"SUPREME", }; + private static final HashMap<String, String> rarityArrMap = new HashMap<>(); + static { + rarityArrMap.put("COMMON", rarityArrC[0]); + rarityArrMap.put("UNCOMMON", rarityArrC[1]); + rarityArrMap.put("RARE", rarityArrC[2]); + rarityArrMap.put("EPIC", rarityArrC[3]); + rarityArrMap.put("LEGENDARY", rarityArrC[4]); + rarityArrMap.put("MYTHIC", rarityArrC[5]); + } + + private HashSet<String> percentStats = new HashSet<>(); + { + percentStats.add("bonus_attack_speed"); + percentStats.add("crit_damage"); + percentStats.add("crit_chance"); + percentStats.add("sea_creature_chance"); + percentStats.add("ability_damage"); + } + + private String currentRarity = "COMMON"; + private boolean showReforgeStoneStats = true; + private boolean pressedArrowLast = false; + private boolean pressedShiftLast = false; + @SubscribeEvent(priority = EventPriority.LOW) public void onItemTooltipLow(ItemTooltipEvent event) { if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return; @@ -1323,7 +1341,145 @@ public class NEUEventListener { int index = 0; List<String> newTooltip = new ArrayList<>(); for(String line : event.toolTip) { - if(line.contains("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune")) { + if(line.endsWith(EnumChatFormatting.DARK_GRAY+"Reforge Stone")) { + JsonObject reforgeStones = Constants.REFORGESTONES; + + if(reforgeStones != null && reforgeStones.has(internalname)) { + boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + if(!pressedShiftLast && shift) { + showReforgeStoneStats = !showReforgeStoneStats; + } + pressedShiftLast = shift; + + newTooltip.add(line); + newTooltip.add(""); + if(!showReforgeStoneStats) { + newTooltip.add(EnumChatFormatting.DARK_GRAY+"[Press SHIFT to show extra info]"); + } else { + newTooltip.add(EnumChatFormatting.DARK_GRAY+"[Press SHIFT to hide extra info]"); + } + + JsonObject reforgeInfo = reforgeStones.get(internalname).getAsJsonObject(); + JsonArray requiredRaritiesArray = reforgeInfo.get("requiredRarities").getAsJsonArray(); + + if(showReforgeStoneStats && requiredRaritiesArray.size() > 0) { + String reforgeName = Utils.getElementAsString(reforgeInfo.get("reforgeName"), ""); + + String[] requiredRarities = new String[requiredRaritiesArray.size()]; + for(int i=0; i<requiredRaritiesArray.size(); i++) { + requiredRarities[i] = requiredRaritiesArray.get(i).getAsString(); + } + + int rarityIndex = requiredRarities.length-1; + String rarity = requiredRarities[rarityIndex]; + for(int i=0; i<requiredRarities.length; i++) { + String rar = requiredRarities[i]; + if(rar.equalsIgnoreCase(currentRarity)) { + rarity = rar; + rarityIndex = i; + break; + } + } + + boolean left = Keyboard.isKeyDown(Keyboard.KEY_LEFT); + boolean right = Keyboard.isKeyDown(Keyboard.KEY_RIGHT); + if(!pressedArrowLast && (left || right)) { + if(left) { + rarityIndex--; + } else if(right) { + rarityIndex++; + } + if(rarityIndex < 0) rarityIndex = 0; + if(rarityIndex >= requiredRarities.length) rarityIndex = requiredRarities.length-1; + currentRarity = requiredRarities[rarityIndex]; + rarity = currentRarity; + } + pressedArrowLast = left || right; + + JsonElement statsE = reforgeInfo.get("reforgeStats"); + if(statsE != null && statsE.isJsonObject()) { + JsonObject stats = statsE.getAsJsonObject(); + + String rarityFormatted = rarityArrMap.getOrDefault(rarity, rarity); + + JsonElement reforgeAbilityE = reforgeInfo.get("reforgeAbility"); + String reforgeAbility = null; + if(reforgeAbilityE != null) { + if(reforgeAbilityE.isJsonPrimitive() && reforgeAbilityE.getAsJsonPrimitive().isString()) { + reforgeAbility = Utils.getElementAsString(reforgeInfo.get("reforgeAbility"), ""); + + } else if(reforgeAbilityE.isJsonObject()) { + if(reforgeAbilityE.getAsJsonObject().has(rarity)) { + reforgeAbility = reforgeAbilityE.getAsJsonObject().get(rarity).getAsString(); + } + } + } + + if(reforgeAbility != null && !reforgeAbility.isEmpty()) { + String text = EnumChatFormatting.BLUE + (reforgeName.isEmpty() ? "Bonus: " : reforgeName + " Bonus: ") + + EnumChatFormatting.GRAY+reforgeAbility; + boolean first = true; + for(String s : Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(text, 150)) { + newTooltip.add((first ? "" : " ") + s); + first = false; + } + newTooltip.add(""); + } + + newTooltip.add(EnumChatFormatting.BLUE+"Stats for "+rarityFormatted+"\u00a79: [\u00a7l\u00a7m< \u00a79Switch\u00a7l\u27a1\u00a79]"); + + JsonElement statsRarE = stats.get(rarity); + if(statsRarE != null && statsRarE.isJsonObject()) { + JsonObject statsRar = statsRarE.getAsJsonObject(); + + TreeSet<Map.Entry<String, JsonElement>> sorted = new TreeSet<>(Map.Entry.comparingByKey()); + sorted.addAll(statsRar.entrySet()); + + for(Map.Entry<String, JsonElement> entry : sorted) { + if(entry.getValue().isJsonPrimitive() && ((JsonPrimitive)entry.getValue()).isNumber()) { + float statNumF = entry.getValue().getAsFloat(); + String statNumS; + if(statNumF % 1 == 0) { + statNumS = String.valueOf(Math.round(statNumF)); + } else { + statNumS = Utils.floatToString(statNumF, 1); + } + String reforgeNamePretty = WordUtils.capitalizeFully(entry.getKey().replace("_", " ")); + String text = EnumChatFormatting.GRAY + reforgeNamePretty + ": " + EnumChatFormatting.GREEN+"+"+statNumS; + if(percentStats.contains(entry.getKey())) { + text += "%"; + } + newTooltip.add(" "+text); + } + } + } + + JsonElement reforgeCostsE = reforgeInfo.get("reforgeCosts"); + int reforgeCost = -1; + if(reforgeCostsE != null) { + if(reforgeCostsE.isJsonPrimitive() && reforgeCostsE.getAsJsonPrimitive().isNumber()) { + reforgeCost = (int)Utils.getElementAsFloat(reforgeInfo.get("reforgeAbility"), -1); + + } else if(reforgeCostsE.isJsonObject()) { + if(reforgeCostsE.getAsJsonObject().has(rarity)) { + reforgeCost = (int)Utils.getElementAsFloat(reforgeCostsE.getAsJsonObject().get(rarity), -1); + } + } + } + + if(reforgeCost >= 0) { + String text = EnumChatFormatting.BLUE + "Apply Cost: " + EnumChatFormatting.GOLD+NumberFormat.getNumberInstance().format(reforgeCost) +" coins"; + newTooltip.add(""); + newTooltip.add(text); + } + + } + } + + continue; + } + + } else if(line.contains("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune")) { line = line.replace("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune", Utils.chromaString("Rainbow Rune", index, false)+EnumChatFormatting.BLUE); } else if(hasEnchantments) { @@ -1652,6 +1808,9 @@ public class NEUEventListener { index++; } + pressedShiftLast = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + pressedArrowLast = Keyboard.isKeyDown(Keyboard.KEY_LEFT) || Keyboard.isKeyDown(Keyboard.KEY_RIGHT); + event.toolTip.clear(); event.toolTip.addAll(newTooltip); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index adfe13d5..f77279b0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -45,6 +45,7 @@ import net.minecraft.event.ClickEvent; import net.minecraft.event.HoverEvent; import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C13PacketPlayerAbilities; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.*; @@ -663,7 +664,9 @@ public class NotEnoughUpdates { SimpleCommand dhCommand = new SimpleCommand("dh", new SimpleCommand.ProcessCommandRunnable() { @Override public void processCommand(ICommandSender sender, String[] args) { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp dungeon_hub"); + //Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp dungeon_hub"); + Minecraft.getMinecraft().thePlayer.capabilities.isFlying = !Minecraft.getMinecraft().thePlayer.capabilities.isFlying; + Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C13PacketPlayerAbilities(Minecraft.getMinecraft().thePlayer.capabilities)); } }); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java index 3bd4e9d2..ef27a51d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java @@ -14,6 +14,8 @@ public class Position { @Expose private boolean centerY; + private static final int EDGE_OFFSET = 0; + public Position(int x, int y) { this(x, y, false, false); } @@ -45,7 +47,7 @@ public class Position { return y; } - public int getAbsX(ScaledResolution scaledResolution) { + public int getAbsX(ScaledResolution scaledResolution, int objWidth) { int width = scaledResolution.getScaledWidth(); if(centerX) { @@ -58,12 +60,12 @@ public class Position { } if(ret < 0) ret = 0; - if(ret > width) ret = width; + if(ret > width) ret = width - objWidth; return ret; } - public int getAbsY(ScaledResolution scaledResolution) { + public int getAbsY(ScaledResolution scaledResolution, int objHeight) { int height = scaledResolution.getScaledHeight(); if(centerY) { @@ -76,7 +78,7 @@ public class Position { } if(ret < 0) ret = 0; - if(ret > height) ret = height; + if(ret > height) ret = height - objHeight; return ret; } @@ -102,22 +104,22 @@ public class Position { } if(wasPositiveX) { - if(this.x < 2) { - deltaX += 2-this.x; - this.x = 2; + if(this.x < EDGE_OFFSET) { + deltaX += EDGE_OFFSET-this.x; + this.x = EDGE_OFFSET; } - if(this.x > screenWidth-2) { - deltaX += screenWidth-2-this.x; - this.x = screenWidth-2; + if(this.x > screenWidth-EDGE_OFFSET) { + deltaX += screenWidth-EDGE_OFFSET-this.x; + this.x = screenWidth-EDGE_OFFSET; } } else { - if(this.x+objWidth > -2) { - deltaX += -2-objWidth-this.x; - this.x = -2-objWidth; + if(this.x+objWidth > -EDGE_OFFSET) { + deltaX += -EDGE_OFFSET-objWidth-this.x; + this.x = -EDGE_OFFSET-objWidth; } - if(this.x+screenWidth < 2) { - deltaX += 2-screenWidth-this.x; - this.x = 2-screenWidth; + if(this.x+screenWidth < EDGE_OFFSET) { + deltaX += EDGE_OFFSET-screenWidth-this.x; + this.x = EDGE_OFFSET-screenWidth; } } @@ -151,22 +153,22 @@ public class Position { } if(wasPositiveY) { - if(this.y < 2) { - deltaY += 2-this.y; - this.y = 2; + if(this.y < EDGE_OFFSET) { + deltaY += EDGE_OFFSET-this.y; + this.y = EDGE_OFFSET; } - if(this.y > screenHeight-2) { - deltaY += screenHeight-2-this.y; - this.y = screenHeight-2; + if(this.y > screenHeight-EDGE_OFFSET) { + deltaY += screenHeight-EDGE_OFFSET-this.y; + this.y = screenHeight-EDGE_OFFSET; } } else { - if(this.y+objHeight > -2) { - deltaY += -2-objHeight-this.y; - this.y = -2-objHeight; + if(this.y+objHeight > -EDGE_OFFSET) { + deltaY += -EDGE_OFFSET-objHeight-this.y; + this.y = -EDGE_OFFSET-objHeight; } - if(this.y+screenHeight < 2) { - deltaY += 2-screenHeight-this.y; - this.y = 2-screenHeight; + if(this.y+screenHeight < EDGE_OFFSET) { + deltaY += EDGE_OFFSET-screenHeight-this.y; + this.y = EDGE_OFFSET-screenHeight; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java index f10b63f1..e28c5a32 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java @@ -32,7 +32,7 @@ public abstract class GuiOptionEditor { float paraHeight = 9 * lineCount - 1; - while(paraHeight >= height-10) { + while(paraHeight >= HEIGHT-10) { scale -= 1/8f; lineCount = fr.listFormattedStringToWidth(option.desc, (int)(width*2/3/scale-10)).size(); paraHeight = (int)(9*scale * lineCount - 1*scale); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java index cd26b03d..103a8c92 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java @@ -49,7 +49,8 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { int height = super.getHeight() + 13; for(int strIndex : activeText) { - height += 10; + String str = exampleText[strIndex]; + height += 10 * str.split("\n").length; } return height; @@ -88,12 +89,20 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { for(int strIndex : activeText) { String str = exampleText[strIndex]; + String[] multilines = str.split("\n"); + + int ySize = multilines.length * 10; + if(i++ != dragStartIndex) { - Utils.drawStringScaledMaxWidth("\u2261 "+str+EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, - x+10, y+50+yOff, true, width-20, 0xffffffff); + for(int multilineIndex=0; multilineIndex<multilines.length; multilineIndex++) { + String line = multilines[multilineIndex]; + Utils.drawStringScaledMaxWidth(line+EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, + x+20, y+50+yOff+multilineIndex*10, true, width-20, 0xffffffff); + } + Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", x+10, y+50+yOff + ySize/2 - 4, 0xffffff, true); } - yOff += 10; + yOff += ySize; } } @@ -129,7 +138,8 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { if(str.isEmpty()) { str = "<NONE>"; } - TextRenderUtils.drawStringScaledMaxWidth(str, fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0); + TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."), + fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0); dropdownY += 12; } } else if(currentDragging >= 0) { @@ -151,9 +161,20 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { String str = exampleText[currentDragging]; + String[] multilines = str.split("\n"); + GlStateManager.enableBlend(); - Utils.drawStringScaledMaxWidth("\u2261 "+str+EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, - dragOffsetX + mouseX, dragOffsetY + mouseY, true, width-20, 0xffffff | (opacity << 24)); + for(int multilineIndex=0; multilineIndex<multilines.length; multilineIndex++) { + String line = multilines[multilineIndex]; + Utils.drawStringScaledMaxWidth(line+EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, + dragOffsetX + mouseX + 10, dragOffsetY + mouseY + multilineIndex*10, true, width-20, 0xffffff | (opacity << 24)); + } + + int ySize = multilines.length * 10; + + Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", + dragOffsetX + mouseX, + dragOffsetY + mouseY + ySize/2 - 4, 0xffffff, true); } } @@ -230,7 +251,8 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { int yOff=0; int i = 0; for(int strIndex : activeText) { - if(mouseY < y+50+yOff+10) { + int ySize = 10 * exampleText[strIndex].split("\n").length; + if(mouseY < y+50+yOff+ySize) { dragOffsetX = x+10 - mouseX; dragOffsetY = y+50+yOff - mouseY; @@ -238,7 +260,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { dragStartIndex = i; break; } - yOff += 10; + yOff += ySize; i++; } } @@ -253,7 +275,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { dragStartIndex = i; break; } - yOff += 10; + yOff += 10 * exampleText[strIndex].split("\n").length; i++; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java index c5b6b3d8..d7d84d28 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java @@ -78,8 +78,8 @@ public class GuiPositionEditor extends GuiScreen { renderCallback.run(); - int x = position.getAbsX(scaledResolution); - int y = position.getAbsY(scaledResolution); + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); if(position.isCenterX()) x -= elementWidth/2; if(position.isCenterY()) y -= elementHeight/2; @@ -104,8 +104,8 @@ public class GuiPositionEditor extends GuiScreen { mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - int x = position.getAbsX(scaledResolution); - int y = position.getAbsY(scaledResolution); + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); if(position.isCenterX()) x -= elementWidth/2; if(position.isCenterY()) y -= elementHeight/2; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index da93b059..c0f48b87 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -43,6 +43,8 @@ public class CapeManager { private boolean allAvailable = false; private HashSet<String> availableCapes = new HashSet<>(); + private JsonObject lastJsonSync = null; + private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty", "furf" }; public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, false, true, true, true, false, false, true, false, true }; @@ -62,6 +64,8 @@ public class CapeManager { private void updateCapes() { NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("activecapes.json", (jsonObject) -> { if(jsonObject.get("success").getAsBoolean()) { + lastJsonSync = jsonObject; + lastCapeSynced = System.currentTimeMillis(); capeMap.clear(); for(JsonElement active : jsonObject.get("active").getAsJsonArray()) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java index 47d3a461..ea561e30 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -654,7 +654,8 @@ public class DungeonMap { pixelWidth = pixelHeight = 12; } GlStateManager.color(1, 1, 1, 1); - if((playerMarkerMapPositions.size() <= 1 || minU != 1/4f) && + if((!NotEnoughUpdates.INSTANCE.config.dungeonMapOpen.showOwnHeadAsMarker || + playerMarkerMapPositions.size() <= 1 || minU != 1/4f) && NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 1 && playerSkinMap.containsKey(entry.getKey())) { Minecraft.getMinecraft().getTextureManager().bindTexture(playerSkinMap.get(entry.getKey())); @@ -1033,7 +1034,7 @@ public class DungeonMap { Score score = scores.get(i); ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName()); String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName()); - line = Utils.cleanDuplicateColourCodes(line); + line = Utils.cleanColour(line); if(line.contains("(F1)")) { isFloorOne = true; @@ -1496,7 +1497,7 @@ public class DungeonMap { int size = 80 + Math.round(40*NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); ScaledResolution scaledResolution = Utils.pushGuiScale(2); - renderMap(pos.getAbsX(scaledResolution)+size/2, pos.getAbsY(scaledResolution)+size/2, + renderMap(pos.getAbsX(scaledResolution, size/2)+size/2, pos.getAbsY(scaledResolution, size/2)+size/2, colourMap, decorations, roomSizeBlocks, actualPlayers, true, event.partialTicks); Utils.pushGuiScale(-1); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java index 041cd842..c6ae6e4d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -478,8 +478,8 @@ public class GuiDungeonMapEditor extends GuiScreen { NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition, size, size, () -> { ScaledResolution scaledResolution = Utils.pushGuiScale(2); - demoMap.renderMap(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsX(scaledResolution)+size/2, - NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsY(scaledResolution)+size/2, + demoMap.renderMap(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsX(scaledResolution, size/2)+size/2, + NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsY(scaledResolution, size/2)+size/2, NotEnoughUpdates.INSTANCE.colourMap, decorations, 0, players, false, 0); Utils.pushGuiScale(-1); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java index 2b682e4f..b2ab13e6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java @@ -102,6 +102,7 @@ public class BetterContainers { return; } } + GlStateManager.enableBlend(); textureManager.bindTexture(location); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java index e206fdcc..96efe962 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java @@ -1,7 +1,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.overlays.CommissionOverlay; +import io.github.moulberry.notenoughupdates.overlays.MiningOverlay; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -29,6 +29,8 @@ import org.lwjgl.util.vector.Vector3f; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class DwarvenMinesWaypoints { @@ -88,16 +90,23 @@ public class DwarvenMinesWaypoints { } } - private long powderGhastMillis = 0; - private String powderGhastLocation = null; - private final String ghastString = "\u00A7r\u00A7eFind the \u00A7r\u00A76Powder Ghast\u00A7r\u00A7e near the \u00A7r\u00A7b"; + private long dynamicMillis = 0; + private String dynamicLocation = null; + private final Pattern ghastRegex = Pattern.compile("\u00A7r\u00A7eFind the \u00A7r\u00A76Powder Ghast\u00A7r\u00A7e near the \u00A7r\u00A7b(.+)!"); + private final Pattern fallenStarRegex = Pattern.compile("\u00A7r\u00A75Fallen Star \u00A7r\u00A7ehas crashed at \u00A7r\u00A7b(.+)\u00A7r\u00A7e!"); @SubscribeEvent public void onChat(ClientChatReceivedEvent event) { - if(event.message.getFormattedText().startsWith(ghastString)) { - String sub = event.message.getFormattedText().substring(ghastString.length()); - powderGhastLocation = Utils.cleanColour(sub).replace("!", "").trim(); - powderGhastMillis = System.currentTimeMillis(); + Matcher matcherGhast = ghastRegex.matcher(event.message.getFormattedText()); + if(matcherGhast.find()) { + dynamicLocation = Utils.cleanColour(matcherGhast.group(1).trim()); + dynamicMillis = System.currentTimeMillis(); + } else { + Matcher matcherStar = fallenStarRegex.matcher(event.message.getFormattedText()); + if(matcherStar.find()) { + dynamicLocation = Utils.cleanColour(matcherStar.group(1).trim()); + dynamicMillis = System.currentTimeMillis(); + } } } @@ -176,10 +185,10 @@ public class DwarvenMinesWaypoints { int locWaypoint = NotEnoughUpdates.INSTANCE.config.mining.locWaypoints; - if(powderGhastLocation != null && - System.currentTimeMillis() - powderGhastMillis < 30*1000) { + if(dynamicLocation != null && + System.currentTimeMillis() - dynamicMillis < 30*1000) { for(Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) { - if(entry.getKey().equals(powderGhastLocation)) { + if(entry.getKey().equals(dynamicLocation)) { renderWayPoint(EnumChatFormatting.GOLD+"Powder Ghast", new Vector3f(entry.getValue()).translate(0, 15, 0), event.partialTicks); break; @@ -192,7 +201,7 @@ public class DwarvenMinesWaypoints { if(locWaypoint >= 2) { renderWayPoint(EnumChatFormatting.AQUA+entry.getKey(), entry.getValue(), event.partialTicks); } else { - for(String commissionName : CommissionOverlay.commissionProgress.keySet()) { + for(String commissionName : MiningOverlay.commissionProgress.keySet()) { if(commissionName.toLowerCase().contains(entry.getKey().toLowerCase())) { if(commissionName.contains("Titanium")) { renderWayPoint(EnumChatFormatting.WHITE+entry.getKey(), entry.getValue(), event.partialTicks); @@ -210,7 +219,7 @@ public class DwarvenMinesWaypoints { if(NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0) return; if(!commissionFinished) { - for(float f : CommissionOverlay.commissionProgress.values()) { + for(float f : MiningOverlay.commissionProgress.values()) { if (f >= 1) { commissionFinished = true; break; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FlyFix.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FlyFix.java new file mode 100644 index 00000000..9ccaff31 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FlyFix.java @@ -0,0 +1,70 @@ +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import net.minecraft.client.Minecraft; +import net.minecraft.network.play.client.C13PacketPlayerAbilities; +import net.minecraft.network.play.server.S39PacketPlayerAbilities; + +public class FlyFix { + + private static boolean serverWantFly = false; + private static boolean clientWantFly = false; + private static long lastAbilitySend = 0; + + public static void onSendAbilities(C13PacketPlayerAbilities packet) { + if(!NotEnoughUpdates.INSTANCE.config.misc.flyFix) return; + if(Minecraft.getMinecraft().thePlayer == null) return; + if(!Minecraft.getMinecraft().thePlayer.capabilities.allowFlying) return; + if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; + if(SBInfo.getInstance().getLocation() == null) return; + if(!SBInfo.getInstance().getLocation().equals("dynamic")) return; + + long currentTime = System.currentTimeMillis(); + + clientWantFly = packet.isFlying(); + if(clientWantFly != serverWantFly) lastAbilitySend = currentTime; + } + + public static void onReceiveAbilities(S39PacketPlayerAbilities packet) { + if(!NotEnoughUpdates.INSTANCE.config.misc.flyFix) return; + if(Minecraft.getMinecraft().thePlayer == null) return; + if(!Minecraft.getMinecraft().thePlayer.capabilities.allowFlying) return; + if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; + if(SBInfo.getInstance().getLocation() == null) return; + if(!SBInfo.getInstance().getLocation().equals("dynamic")) return; + + long currentTime = System.currentTimeMillis(); + + serverWantFly = packet.isFlying(); + if(serverWantFly != clientWantFly) { + if(currentTime - lastAbilitySend > 0 && currentTime - lastAbilitySend < 500) { + packet.setFlying(clientWantFly); + } else { + clientWantFly = serverWantFly; + } + } + } + + public static void tick() { + if(!NotEnoughUpdates.INSTANCE.config.misc.flyFix) return; + if(Minecraft.getMinecraft().thePlayer == null) return; + if(!Minecraft.getMinecraft().thePlayer.capabilities.allowFlying) return; + if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; + if(SBInfo.getInstance().getLocation() == null) return; + if(!SBInfo.getInstance().getLocation().equals("dynamic")) return; + + long currentTime = System.currentTimeMillis(); + + if(currentTime - lastAbilitySend > 1000 && currentTime - lastAbilitySend < 5000) { + if(clientWantFly != serverWantFly) { + Minecraft.getMinecraft().thePlayer.capabilities.isFlying = serverWantFly; + Minecraft.getMinecraft().thePlayer.sendPlayerAbilities(); + clientWantFly = serverWantFly; + } + } else { + clientWantFly = Minecraft.getMinecraft().thePlayer.capabilities.isFlying; + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java index 8b130d24..1c509359 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java @@ -2,7 +2,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import io.github.moulberry.notenoughupdates.overlays.CommissionOverlay; +import io.github.moulberry.notenoughupdates.overlays.MiningOverlay; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; @@ -38,7 +38,7 @@ public class MiningStuff { SBInfo.getInstance().getLocation().startsWith("mining_") && state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) { - for(String s : CommissionOverlay.commissionProgress.keySet()) { + for(String s : MiningOverlay.commissionProgress.keySet()) { if(s.contains("Titanium")) { BlockPos pos = packetIn.getBlockPosition(); @@ -193,7 +193,8 @@ public class MiningStuff { if(NotEnoughUpdates.INSTANCE.config.mining.dontMineStone && state != null && SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().startsWith("mining_") && - state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.STONE) { + (state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.STONE || + state.getBlock() == Blocks.cobblestone)) { return true; } return false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java index d3c96896..fb6fba4e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java @@ -2,11 +2,15 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; import net.minecraft.inventory.Container; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import org.lwjgl.input.Keyboard; 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.CallbackInfoReturnable; @Mixin(Container.class) public class MixinContainer { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java index 12d1f929..0ca0133b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -83,6 +83,7 @@ public abstract class MixinGuiContainer extends GuiScreen { @Redirect(method="drawSlot", at=@At(value="INVOKE", target=TARGET_GETSTACK)) public ItemStack drawSlot_getStack(Slot slot) { GuiContainer $this = (GuiContainer)(Object)this; + ItemStack stack = slot.getStack(); if(stack != null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java index 876338da..5cb2dc8d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java @@ -1,19 +1,21 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; -import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; +import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; -import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C13PacketPlayerAbilities; import net.minecraft.network.play.server.S23PacketBlockChange; import net.minecraft.network.play.server.S2FPacketSetSlot; +import net.minecraft.network.play.server.S39PacketPlayerAbilities; +import org.lwjgl.opengl.Display; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(NetHandlerPlayClient.class) public class MixinNetHandlerPlayClient { @@ -40,6 +42,19 @@ public class MixinNetHandlerPlayClient { ItemCooldowns.processBlockChangePacket(packetIn); } + @Inject(method="handlePlayerAbilities", at=@At("HEAD")) + public void handlePlayerAbilities(S39PacketPlayerAbilities packetIn, CallbackInfo ci) { + FlyFix.onReceiveAbilities(packetIn); + } + + @Inject(method="addToSendQueue", at=@At("HEAD")) + public void addToSendQueue(Packet packet, CallbackInfo ci) { + if(packet instanceof C13PacketPlayerAbilities) { + C13PacketPlayerAbilities abilities = (C13PacketPlayerAbilities) packet; + FlyFix.onSendAbilities(abilities); + } + } + } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java index 69444c45..2183e437 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java @@ -4,7 +4,9 @@ import io.github.moulberry.notenoughupdates.miscfeatures.DwarvenMinesTextures; import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff; +import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.network.play.client.C07PacketPlayerDigging; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import org.spongepowered.asm.mixin.Mixin; @@ -20,6 +22,7 @@ public class MixinPlayerControllerMP { ItemCooldowns.blockClicked(loc); if(MiningStuff.blockClicked(loc)) { cir.setReturnValue(false); + ((PlayerControllerMP)(Object)this).resetBlockRemoving(); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 19b9b7b0..3a2678b2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -2,17 +2,16 @@ package io.github.moulberry.notenoughupdates.options; import com.google.common.collect.Lists; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.core.config.Config; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.config.annotations.*; import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; -import io.github.moulberry.notenoughupdates.overlays.CommissionOverlay; -import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle; +import io.github.moulberry.notenoughupdates.overlays.*; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientCommandHandler; +import org.lwjgl.util.vector.Vector2f; import java.util.ArrayList; import java.util.Arrays; @@ -20,9 +19,21 @@ import java.util.List; public class NEUConfig extends Config { + private void editOverlay(String activeConfig, TextOverlay overlay, Position position) { + Vector2f size = overlay.getDummySize(); + int width = (int)size.x; + int height = (int)size.y; + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> { + overlay.renderDummy(); + OverlayManager.dontRenderOverlay = overlay.getClass(); + }, () -> { + }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper( + new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, activeConfig)) + )); + } + @Override public void executeRunnable(int runnableId) { - String activeConfigCategory = null; if(Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) { GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen; @@ -37,33 +48,7 @@ public class NEUConfig extends Config { ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neumap"); return; case 1: - final CommissionOverlay overlay = new CommissionOverlay(NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, () -> { - int style = NotEnoughUpdates.INSTANCE.config.mining.overlayStyle; - if(style >= 0 && style < TextOverlayStyle.values().length) { - return TextOverlayStyle.values()[style]; - } - return TextOverlayStyle.BACKGROUND; - }); - overlay.tick(); - if(overlay.overlayWidth <= 0 || overlay.overlayHeight <= 0) { - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( - NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, - 150, 75, () -> { - }, () -> { - }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper( - new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, activeConfigCategoryF)) - )); - } else { - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( - NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, - overlay.overlayWidth+10, overlay.overlayHeight+10, () -> { - overlay.render(); - NEUEventListener.dontRenderOverlay = CommissionOverlay.class; - }, () -> { - }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper( - new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, activeConfigCategoryF)) - )); - } + editOverlay(activeConfigCategory, OverlayManager.miningOverlay, mining.overlayPosition); return; case 2: Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( @@ -74,6 +59,9 @@ public class NEUConfig extends Config { new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, activeConfigCategoryF)) )); return; + case 3: + editOverlay(activeConfigCategory, OverlayManager.farmingOverlay, skillOverlays.farmingPosition); + return; } } @@ -128,6 +116,13 @@ public class NEUConfig extends Config { @Expose @Category( + name = "Skill Overlays", + desc = "Skill Overlays" + ) + public SkillOverlays skillOverlays = new SkillOverlays(); + + @Expose + @Category( name = "Dungeon Profit", desc = "Dungeon Profit" ) @@ -265,6 +260,14 @@ public class NEUConfig extends Config { @Expose @ConfigOption( + name = "Private Island Fly Fix", + desc = "Fix flying being delaying on private islands" + ) + @ConfigEditorBoolean + public boolean flyFix = true; + + @Expose + @ConfigOption( name = "Hide Potion Effects", desc = "Hide the potion effects inside your inventory while on skyblock" ) @@ -637,8 +640,17 @@ public class NEUConfig extends Config { public static class SkillOverlays { @Expose @ConfigOption( + name = "Enable Farming Overlay", + desc = "Show an overlay while farming with useful information" + ) + @ConfigEditorBoolean + public boolean farmingOverlay = true; + + @Expose + @ConfigOption( name = "Farming Text", - desc = "" + desc = "\u00a7eDrag text to change the appearance of the overlay\n" + + "\u00a7rHold a mathematical hoe or use an axe while gaining farming xp to show the overlay" ) @ConfigEditorDraggableList( exampleText = {"\u00a7bCounter: \u00a7e37,547,860", @@ -647,9 +659,31 @@ public class NEUConfig extends Config { "\u00a7bCurrent XP: \u00a7e6,734", "\u00a7bRemaining XP: \u00a7e3,265", "\u00a7bXP/h: \u00a7e238,129", - "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52"} + "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52", + "\u00a7bETA: 13h12m"} ) - public List<Integer> priceInfoAuc = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6)); + public List<Integer> farmingText = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 7, 6)); + + @Expose + @ConfigOption( + name = "Farming Position", + desc = "Change the position of the Farming overlay" + ) + @ConfigEditorButton( + runnableId = 3, + buttonText = "Edit" + ) + public Position farmingPosition = new Position(10, 200); + + @Expose + @ConfigOption( + name = "Farming Style", + desc = "Change the style of the Farming overlay" + ) + @ConfigEditorDropdown( + values = {"Background", "No Shadow", "Shadow", "Full Shadow"} + ) + public int farmingStyle = 0; } public static class DungeonProfit { @@ -840,87 +874,78 @@ public class NEUConfig extends Config { @Expose @ConfigOption( - name = "Overlay Position", - desc = "Change the position of the Dwarven Mines information overlay (commisions, powder & forge statuses)" - ) - @ConfigEditorButton( - runnableId = 1, - buttonText = "Edit" + name = "Drill Fuel Bar", + desc = "Show a fancy drill fuel bar when holding a drill in mining areas" ) - public Position overlayPosition = new Position(10, 100); + @ConfigEditorBoolean + public boolean drillFuelBar = true; @Expose @ConfigOption( - name = "Overlay Style", - desc = "Change the style of the Dwarven Mines information overlay" + name = "Fuel Bar Width", + desc = "Change the width of the drill fuel bar" ) - @ConfigEditorDropdown( - values = {"Background", "No Shadow", "Shadow", "Full Shadow"} + @ConfigEditorSlider( + minValue = 50, + maxValue = 400, + minStep = 10 ) - public int overlayStyle = 0; + public int drillFuelBarWidth = 200; @Expose @ConfigOption( - name = "Commissions Overlay", - desc = "Show current commissions on the screen while in Dwarven Mines" + name = "Fuel Bar Position", + desc = "Set the position of the drill fuel bar" ) - @ConfigEditorBoolean - public boolean commissionsOverlay = true; - - @Expose - @ConfigOption( - name = "Powder Overlay", - desc = "Show powder count on the screen while in Dwarven Mines" + @ConfigEditorButton( + runnableId = 2, + buttonText = "Edit" ) - @ConfigEditorBoolean - public boolean powderOverlay = true; + public Position drillFuelBarPosition = new Position(0, -100, true, false); - @Expose - @ConfigOption( - name = "Forges Overlay", - desc = "Show forge statuses on the screen while in Dwarven Mines" - ) - @ConfigEditorBoolean - public boolean forgeOverlay = true; @Expose @ConfigOption( - name = "Hide Empty Forges", - desc = "Hide empty forges in the information overlay" + name = "Dwarven Overlay", + desc = "Show an overlay with useful information on the screen while in Dwarven Mines" ) @ConfigEditorBoolean - public boolean hideEmptyForges = true; + public boolean dwarvenOverlay = true; @Expose @ConfigOption( - name = "Drill Fuel Bar", - desc = "Show a fancy drill fuel bar when holding a drill in mining areas" + name = "Dwarven Text", + desc = "\u00a7eDrag text to change the appearance of the overlay\n" + + "\u00a7rGo to the Dwarven Mines to show this overlay with useful information" ) - @ConfigEditorBoolean - public boolean drillFuelBar = true; + @ConfigEditorDraggableList( + exampleText = {"\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%", + "\u00a73Mithril Powder: \u00a726,243", + "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!", + "\u00a73Forge 2) \u00a77EMPTY\n\u00a73Forge 3) \u00a77EMPTY\n\u00a73Forge 4) \u00a77EMPTY"} + ) + public List<Integer> dwarvenText = new ArrayList<>(Arrays.asList(0, 1, 2, 3)); @Expose @ConfigOption( - name = "Fuel Bar Width", - desc = "Change the width of the drill fuel bar" + name = "Overlay Position", + desc = "Change the position of the Dwarven Mines information overlay (commisions, powder & forge statuses)" ) - @ConfigEditorSlider( - minValue = 50, - maxValue = 400, - minStep = 10 + @ConfigEditorButton( + runnableId = 1, + buttonText = "Edit" ) - public int drillFuelBarWidth = 200; + public Position overlayPosition = new Position(10, 100); @Expose @ConfigOption( - name = "Fuel Bar Position", - desc = "Set the position of the drill fuel bar" + name = "Overlay Style", + desc = "Change the style of the Dwarven Mines information overlay" ) - @ConfigEditorButton( - runnableId = 2, - buttonText = "Edit" + @ConfigEditorDropdown( + values = {"Background", "No Shadow", "Shadow", "Full Shadow"} ) - public Position drillFuelBarPosition = new Position(0, -100, true, false); + public int overlayStyle = 0; } public static class NeuAuctionHouse { @@ -1119,6 +1144,14 @@ public class NEUConfig extends Config { buttonText = "Edit" ) public int editDungeonMap = 0; + + @Expose + @ConfigOption( + name = "Show Own Head As Marker", + desc = "If you have the \"Head\" icon style selected, don't replace your green marker with a head" + ) + @ConfigEditorBoolean + public boolean showOwnHeadAsMarker = false; } public static class DungeonBlock { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java index 8b334a93..65e01a1d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java @@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; +import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; @@ -14,6 +15,7 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; import java.util.function.Supplier; public class FarmingOverlay extends TextOverlay { @@ -36,8 +38,8 @@ public class FarmingOverlay extends TextOverlay { private String skillType = "Farming"; - public FarmingOverlay(Position position, Supplier<TextOverlayStyle> styleSupplier) { - super(position, styleSupplier); + public FarmingOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) { + super(position, dummyStrings, styleSupplier); } private float interp(float now, float last) { @@ -52,6 +54,12 @@ public class FarmingOverlay extends TextOverlay { @Override public void update() { + if(!NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingOverlay) { + counter = -1; + overlayStrings = null; + return; + } + lastUpdate = System.currentTimeMillis(); counterLast = counter; xpGainHourLast = xpGainHour; @@ -88,7 +96,7 @@ public class FarmingOverlay extends TextOverlay { float delta = totalXp - lastTotalXp; if(delta > 0 && delta < 1000) { - xpGainQueue.add(delta); + xpGainQueue.add(0, delta); while (xpGainQueue.size() > 120) { xpGainQueue.removeLast(); } @@ -107,7 +115,6 @@ public class FarmingOverlay extends TextOverlay { lastTotalXp = totalXp; } - while(counterQueue.size() >= 4) { counterQueue.removeLast(); } @@ -133,6 +140,8 @@ public class FarmingOverlay extends TextOverlay { @Override public void updateFrequent() { + super.updateFrequent(); + if(counter < 0) { overlayStrings = null; } else { @@ -154,6 +163,16 @@ public class FarmingOverlay extends TextOverlay { String.format("%.2f", cpsInterp*60)); } + float xpInterp = xpGainHour; + if(xpGainHourLast == xpGainHour && xpGainHour <= 0) { + lineMap.put(5, EnumChatFormatting.AQUA+"XP/h: "+EnumChatFormatting.YELLOW+"N/A"); + } else { + xpInterp = interp(xpGainHour, xpGainHourLast); + + lineMap.put(5, EnumChatFormatting.AQUA+"XP/h: "+EnumChatFormatting.YELLOW+ + format.format(xpInterp)+(isFarming ? "" : EnumChatFormatting.RED + " (PAUSED)")); + } + if(skillInfo != null) { StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + skillType.substring(0, 4) + ": "); @@ -196,16 +215,15 @@ public class FarmingOverlay extends TextOverlay { lineMap.put(2, levelStr.toString()); lineMap.put(3, EnumChatFormatting.AQUA+"Current XP: " + EnumChatFormatting.YELLOW+ format.format(current)); lineMap.put(4, EnumChatFormatting.AQUA+"Remaining XP: " + EnumChatFormatting.YELLOW+ format.format(remaining)); + + if(xpGainHour < 1000) { + lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ "N/A"); + } else { + lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ Utils.prettyTime((long)(remaining)*1000*60*60/(long)xpInterp)); + } } - if(xpGainHourLast == xpGainHour && xpGainHour <= 0) { - lineMap.put(5, EnumChatFormatting.AQUA+"XP/h: "+EnumChatFormatting.YELLOW+"N/A"); - } else { - float xpInterp = interp(xpGainHour, xpGainHourLast); - lineMap.put(5, EnumChatFormatting.AQUA+"XP/h: "+EnumChatFormatting.YELLOW+ - format.format(xpInterp)+(isFarming ? "" : EnumChatFormatting.RED + " (PAUSED)")); - } float yaw = Minecraft.getMinecraft().thePlayer.rotationYawHead; yaw %= 360; @@ -215,11 +233,11 @@ public class FarmingOverlay extends TextOverlay { lineMap.put(6, EnumChatFormatting.AQUA+"Yaw: "+EnumChatFormatting.YELLOW+ String.format("%.2f", yaw)+EnumChatFormatting.BOLD+"\u1D52"); - /*for(int strIndex : NotEnoughUpdates.INSTANCE.config) { + for(int strIndex : NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingText) { if(lineMap.containsKey(strIndex)) { overlayStrings.add(lineMap.get(strIndex)); } - }*/ + } if(overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java index a2071065..aecd93d0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java @@ -79,8 +79,8 @@ public class FuelBar { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); Position position = NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition; - int x = position.getAbsX(scaledResolution); - int y = position.getAbsY(scaledResolution); + int x = position.getAbsX(scaledResolution, NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth); + int y = position.getAbsY(scaledResolution, 12); x -= NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth/2; renderBar(x, y+4, NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, fuelAmount); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CommissionOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index 2b07c597..d4671986 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CommissionOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -6,8 +6,6 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; -import io.github.moulberry.notenoughupdates.overlays.TextOverlay; -import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -23,10 +21,10 @@ import java.util.function.Supplier; import static net.minecraft.util.EnumChatFormatting.*; -public class CommissionOverlay extends TextOverlay { +public class MiningOverlay extends TextOverlay { - public CommissionOverlay(Position position, Supplier<TextOverlayStyle> styleSupplier) { - super(position, styleSupplier); + public MiningOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) { + super(position, dummyStrings, styleSupplier); } public static Map<String, Float> commissionProgress = new LinkedHashMap<>(); @@ -35,12 +33,14 @@ public class CommissionOverlay extends TextOverlay { public void update() { overlayStrings = null; + if(!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay) return; if(SBInfo.getInstance().getLocation() == null) return; if(!SBInfo.getInstance().getLocation().equals("mining_3")) return; overlayStrings = new ArrayList<>(); commissionProgress.clear(); List<String> forgeStrings = new ArrayList<>(); + List<String> forgeStringsEmpty = new ArrayList<>(); String mithrilPowder = null; boolean commissions = false; @@ -49,7 +49,7 @@ public class CommissionOverlay extends TextOverlay { for(NetworkPlayerInfo info : players) { String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); if(name.contains("Mithril Powder:")) { - mithrilPowder = Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", ""); + mithrilPowder = DARK_AQUA+Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", ""); } if(name.equals(RESET.toString()+BLUE+BOLD+"Forges"+RESET)) { commissions = false; @@ -63,8 +63,11 @@ public class CommissionOverlay extends TextOverlay { String clean = StringUtils.cleanColour(name); if(forges && clean.startsWith(" ")) { if(name.contains("LOCKED")) continue; - if(NotEnoughUpdates.INSTANCE.config.mining.hideEmptyForges && name.contains("EMPTY")) continue; - forgeStrings.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "")); + if(name.contains("EMPTY")) { + forgeStringsEmpty.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "")); + } else { + forgeStrings.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "")); + } } else if(commissions && clean.startsWith(" ")) { String[] split = clean.trim().split(": "); if(split.length == 2) { @@ -98,20 +101,13 @@ public class CommissionOverlay extends TextOverlay { col = GOLD; } - String valS = String.valueOf(entry.getValue()*100); - int periodIndex = valS.indexOf('.');//1.3 - if(periodIndex > 0) { - valS = valS.substring(0, Math.min(valS.length(), periodIndex+2)); - } - if(valS.endsWith("0")) { - valS = valS.substring(0, Math.max(0, valS.length()-2)); - } + String valS = Utils.floatToString(entry.getValue()*100, 1); commissionsStrings.add(DARK_AQUA+entry.getKey() + ": " + col+valS+"%"); } } - boolean hasAny = false; - if(NotEnoughUpdates.INSTANCE.config.mining.commissionsOverlay) { + /*boolean hasAny = false; + if(NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay) { overlayStrings.addAll(commissionsStrings); hasAny = true; } @@ -125,7 +121,22 @@ public class CommissionOverlay extends TextOverlay { if(NotEnoughUpdates.INSTANCE.config.mining.forgeOverlay) { if(hasAny) overlayStrings.add(null); overlayStrings.addAll(forgeStrings); + }*/ + + for(int index : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText) { + switch(index) { + case 0: + overlayStrings.addAll(commissionsStrings); break; + case 1: + overlayStrings.add(mithrilPowder); break; + case 2: + overlayStrings.addAll(forgeStrings); break; + case 3: + overlayStrings.addAll(forgeStringsEmpty); break; + } } + + if(overlayStrings.isEmpty()) overlayStrings = null; } private static final Ordering<NetworkPlayerInfo> playerOrdering = Ordering.from(new PlayerComparator()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java new file mode 100644 index 00000000..1f0cafbd --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java @@ -0,0 +1,61 @@ +package io.github.moulberry.notenoughupdates.overlays; + +import com.google.common.collect.Lists; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; + +import java.util.ArrayList; +import java.util.List; + +public class OverlayManager { + + public static Class<? extends TextOverlay> dontRenderOverlay = null; + + public static MiningOverlay miningOverlay; + public static FarmingOverlay farmingOverlay; + public static final List<TextOverlay> textOverlays = new ArrayList<>(); + + static { + List<String> miningDummy = Lists.newArrayList("\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%", + "\u00a73Mithril Powder: \u00a726,243", + "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!", + "\u00a73Forge 2) \u00a77EMPTY\n\u00a73Forge 3) \u00a77EMPTY\n\u00a73Forge 4) \u00a77EMPTY"); + miningOverlay = new MiningOverlay(NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, () -> { + List<String> strings = new ArrayList<>(); + for(int i : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText) { + if(i >= 0 && i < miningDummy.size()) strings.add(miningDummy.get(i)); + } + return strings; + }, () -> { + int style = NotEnoughUpdates.INSTANCE.config.mining.overlayStyle; + if(style >= 0 && style < TextOverlayStyle.values().length) { + return TextOverlayStyle.values()[style]; + } + return TextOverlayStyle.BACKGROUND; + }); + + List<String> farmingDummy = Lists.newArrayList("\u00a7bCounter: \u00a7e37,547,860", + "\u00a7bCrops/m: \u00a7e38.29", + "\u00a7bFarm: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%", + "\u00a7bCurrent XP: \u00a7e6,734", + "\u00a7bRemaining XP: \u00a7e3,265", + "\u00a7bXP/h: \u00a7e238,129", + "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52"); + farmingOverlay = new FarmingOverlay(NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingPosition, () -> { + List<String> strings = new ArrayList<>(); + for(int i : NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingText) { + if(i >= 0 && i < farmingDummy.size()) strings.add(farmingDummy.get(i)); + } + return strings; + }, () -> { + int style = NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingStyle; + if(style >= 0 && style < TextOverlayStyle.values().length) { + return TextOverlayStyle.values()[style]; + } + return TextOverlayStyle.BACKGROUND; + }); + + textOverlays.add(miningOverlay); + textOverlays.add(farmingOverlay); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java index c73c3b8d..30f2a9fb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java @@ -8,8 +8,10 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; +import org.lwjgl.util.vector.Vector2f; import java.awt.*; +import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; @@ -20,81 +22,110 @@ public abstract class TextOverlay { public int overlayWidth = -1; public int overlayHeight = -1; public List<String> overlayStrings = null; + private Supplier<List<String>> dummyStrings; + + public boolean shouldUpdateFrequent = false; private static final int PADDING_X = 5; private static final int PADDING_Y = 5; - public TextOverlay(Position position, Supplier<TextOverlayStyle> styleSupplier) { + public TextOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) { this.position = position; this.styleSupplier = styleSupplier; + if(dummyStrings == null) { + this.dummyStrings = () -> null; + } else { + this.dummyStrings = dummyStrings; + } } - public void tick() { - update(); + public Vector2f getDummySize() { + List<String> dummyStrings = this.dummyStrings.get(); - if(overlayStrings != null) { - overlayHeight = 0; - overlayWidth = 0; - for(String s : overlayStrings) { + if(dummyStrings != null) { + int overlayHeight = 0; + int overlayWidth = 0; + for(String s : dummyStrings) { if(s == null) { overlayHeight += 3; continue; } - int sWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s); - if(sWidth > overlayWidth) { - overlayWidth = sWidth; + for(String s2 : s.split("\n")) { + int sWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s2); + if(sWidth > overlayWidth) { + overlayWidth = sWidth; + } + overlayHeight += 10; } - overlayHeight += 10; } overlayHeight -= 2; + + return new Vector2f(overlayWidth+PADDING_X*2, overlayHeight+PADDING_Y*2); } + return new Vector2f(100, 50); + } + + public void tick() { + update(); } - public void updateFrequent() {}; + public void updateFrequent() {} public abstract void update(); + public void renderDummy() { + List<String> dummyStrings = this.dummyStrings.get(); + render(dummyStrings); + } + public void render() { - if(overlayStrings == null) return; + if(shouldUpdateFrequent) { + updateFrequent(); + shouldUpdateFrequent = false; + } + render(overlayStrings); + } - updateFrequent(); + private void render(List<String> strings) { + if(strings == null) return; - if(overlayStrings != null) { - overlayHeight = 0; - overlayWidth = 0; - for(String s : overlayStrings) { - if(s == null) { - overlayHeight += 3; - continue; - } - int sWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s); + overlayHeight = 0; + overlayWidth = 0; + for(String s : strings) { + if(s == null) { + overlayHeight += 3; + continue; + } + for(String s2 : s.split("\n")) { + int sWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s2); if(sWidth > overlayWidth) { overlayWidth = sWidth; } overlayHeight += 10; } - overlayHeight -= 2; - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + overlayHeight -= 2; - int x = position.getAbsX(scaledResolution); - int y = position.getAbsY(scaledResolution); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - TextOverlayStyle style = styleSupplier.get(); + int x = position.getAbsX(scaledResolution, overlayWidth+PADDING_X*2); + int y = position.getAbsY(scaledResolution, overlayHeight+PADDING_Y*2); - if(style == TextOverlayStyle.BACKGROUND) Gui.drawRect(x, y, x+overlayWidth+PADDING_X*2, y+overlayHeight+PADDING_Y*2, 0x80000000); + TextOverlayStyle style = styleSupplier.get(); - int yOff = 0; - for(String s : overlayStrings) { - if(s == null) { - yOff += 3; - } else { + if(style == TextOverlayStyle.BACKGROUND) Gui.drawRect(x, y, x+overlayWidth+PADDING_X*2, y+overlayHeight+PADDING_Y*2, 0x80000000); - GlStateManager.enableBlend(); - GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + int yOff = 0; + for(String s : strings) { + if(s == null) { + yOff += 3; + } else { + for(String s2 : s.split("\n")) { if(style == TextOverlayStyle.FULL_SHADOW) { - String clean = Utils.cleanColourNotModifiers(s); + String clean = Utils.cleanColourNotModifiers(s2); for(int xO=-2; xO<=2; xO++) { for(int yO=-2; yO<=2; yO++) { if(Math.abs(xO) != Math.abs(yO)) { @@ -105,8 +136,8 @@ public abstract class TextOverlay { } } } - Minecraft.getMinecraft().fontRendererObj.drawString(s, - x+PADDING_X, y+PADDING_Y+yOff, 0xffffff, style == TextOverlayStyle.MC_SHADOW); + Minecraft.getMinecraft().fontRendererObj.drawString(s2, + x+PADDING_X, y+PADDING_Y+yOff, 0xffffff, style == TextOverlayStyle.MC_SHADOW); yOff += 10; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index 227d94bd..f13f562e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -355,6 +355,8 @@ public class ProfileViewer { JsonObject inventoryInfo = getInventoryInfo(profileId); JsonObject profileInfo = getProfileInformation(profileId); + HashMap<String, Long> mostExpensiveInternal = new HashMap<>(); + long networth = 0; for(Map.Entry<String, JsonElement> entry : inventoryInfo.entrySet()) { if(entry.getValue().isJsonArray()) { @@ -393,7 +395,7 @@ public class ProfileViewer { if(internalname2 != null) { if(manager.auctionManager.isVanillaItem(internalname2)) continue; - JsonObject bzInfo2 = manager.auctionManager.getBazaarInfo(internalname); + JsonObject bzInfo2 = manager.auctionManager.getBazaarInfo(internalname2); int auctionPrice2; if(bzInfo2 != null) { @@ -406,6 +408,8 @@ public class ProfileViewer { } int count2 = items.getCompoundTagAt(j).getByte("Count"); + + mostExpensiveInternal.put(internalname2, auctionPrice2 * count2 + mostExpensiveInternal.getOrDefault(internalname2, 0L)); networth += auctionPrice2 * count2; } } @@ -417,6 +421,7 @@ public class ProfileViewer { if(element.getAsJsonObject().has("count")) { count = element.getAsJsonObject().get("count").getAsInt(); } + mostExpensiveInternal.put(internalname, auctionPrice * count + mostExpensiveInternal.getOrDefault(internalname, 0L)); networth += auctionPrice * count; } } @@ -424,6 +429,11 @@ public class ProfileViewer { } if(networth == 0) return -1; + //System.out.println(profileId); + for(Map.Entry<String, Long> entry : mostExpensiveInternal.entrySet()) { + //System.out.println(entry.getKey() + ":" + entry.getValue()); + } + networth = (int)(networth*1.3f); JsonObject petsInfo = getPetsInfo(profileId); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java index 5ef407f3..485ca19c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java @@ -14,6 +14,7 @@ public class Constants { public static JsonObject PARENTS; public static JsonObject ESSENCECOSTS; public static JsonObject FAIRYSOULS; + public static JsonObject REFORGESTONES; public static void reload() { BONUSES = Utils.getConstant("bonuses"); @@ -26,6 +27,7 @@ public class Constants { PARENTS = Utils.getConstant("parents"); ESSENCECOSTS = Utils.getConstant("essencecosts"); FAIRYSOULS = Utils.getConstant("fairy_souls"); + REFORGESTONES = Utils.getConstant("reforgestones"); } static { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index f452b406..4a72a85e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -270,6 +270,14 @@ public class Utils { return ""; } + public static String floatToString(float f, int decimals) { + if(decimals <= 0) { + return String.valueOf(Math.round(f)); + } else { + return String.format("%."+decimals+"f", f + 0.00001f); + } + } + public static void drawItemStackLinear(ItemStack stack, int x, int y) { if(stack == null)return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java index c88d09f9..7277f884 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java @@ -6,6 +6,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.HashMap; @@ -34,10 +35,10 @@ public class XPInformation { private static Pattern SKILL_PATTERN = Pattern.compile("\\+(\\d+(?:\\.\\d+)?) (.+) \\((\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:,\\d+)*(?:\\.\\d+)?)\\)"); public SkillInfo getSkillInfo(String skillName) { - return skillInfoMap.get(skillName); + return skillInfoMap.get(skillName.toLowerCase()); } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onChatReceived(ClientChatReceivedEvent event) { if(event.type == 2) { JsonObject leveling = Constants.LEVELING; @@ -71,7 +72,7 @@ public class XPInformation { skillInfo.level++; } - skillInfoMap.put(skillS, skillInfo); + skillInfoMap.put(skillS.toLowerCase(), skillInfo); } } } @@ -82,9 +83,23 @@ public class XPInformation { () -> {}, this::onApiUpdated); } + private static final String[] skills = {"taming","mining","foraging","enchanting","carpentry","farming","combat","fishing","alchemy","runecrafting"}; + private void onApiUpdated(ProfileViewer.Profile profile) { JsonObject skillInfo = profile.getSkillInfo(null); + for(String skill : skills) { + SkillInfo info = new SkillInfo(); + + float level = skillInfo.get("level_skill_"+skill).getAsFloat(); + + info.totalXp = skillInfo.get("experience_skill_"+skill).getAsFloat(); + info.currentXpMax = skillInfo.get("maxxp_skill_"+skill).getAsFloat(); + info.level = (int)level; + info.currentXp = (level%1)*info.currentXpMax; + + skillInfoMap.put(skill.toLowerCase(), info); + } } } |