diff options
Diffstat (limited to 'src/main/java')
18 files changed, 362 insertions, 245 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index cafbff05..401898d2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -27,7 +27,94 @@ public class ItemPriceInformation { NumberFormat format = NumberFormat.getInstance(Locale.US); - if(auctionItem) { + if(bazaarItem) { + int[] lines = { + NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line1, + NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line2, + NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line3, + NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line4, + NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line5, + NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line6 + }; + + boolean added = false; + + boolean shiftPressed = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); + + int stackMultiplier = 1; + int shiftStackMultiplier = 64; + if(shiftPressed) { + stackMultiplier = shiftStackMultiplier; + } + + //values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"} + for(int lineId : lines) { + switch (lineId) { + case 0: + continue; + case 1: + if(bazaarInfo.has("avg_buy")) { + if(!added) { + tooltip.add(""); + if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); + added = true; + } + int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*stackMultiplier; + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); + } + break; + case 2: + if(bazaarInfo.has("avg_sell")) { + if(!added) { + tooltip.add(""); + if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); + added = true; + } + int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*stackMultiplier; + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); + } + break; + case 3: + if(bazaarInfo.has("curr_buy")) { + if(!added) { + tooltip.add(""); + if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); + added = true; + } + int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*stackMultiplier; + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); + } + break; + case 4: + if(bazaarInfo.has("curr_sell")) { + if(!added) { + tooltip.add(""); + if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); + added = true; + } + int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*stackMultiplier; + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); + } + break; + case 5: + if(craftCost.fromRecipe) { + if(!added) { + tooltip.add(""); + added = true; + } + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Raw Craft Cost: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)craftCost.craftCost)+" coins"); + } + break; + } + } + + return added; + } else if(auctionItem) { int[] lines = { NotEnoughUpdates.INSTANCE.config.priceInfoAuc.line1, NotEnoughUpdates.INSTANCE.config.priceInfoAuc.line2, @@ -151,93 +238,6 @@ public class ItemPriceInformation { } return added; - } else if(bazaarItem) { - int[] lines = { - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line1, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line2, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line3, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line4, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line5, - NotEnoughUpdates.INSTANCE.config.priceInfoBaz.line6 - }; - - boolean added = false; - - boolean shiftPressed = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT); - - int stackMultiplier = 1; - int shiftStackMultiplier = 64; - if(shiftPressed) { - stackMultiplier = shiftStackMultiplier; - } - - //values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"} - for(int lineId : lines) { - switch (lineId) { - case 0: - continue; - case 1: - if(bazaarInfo.has("avg_buy")) { - if(!added) { - tooltip.add(""); - if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); - added = true; - } - int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*stackMultiplier; - tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); - } - break; - case 2: - if(bazaarInfo.has("avg_sell")) { - if(!added) { - tooltip.add(""); - if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); - added = true; - } - int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*stackMultiplier; - tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); - } - break; - case 3: - if(bazaarInfo.has("curr_buy")) { - if(!added) { - tooltip.add(""); - if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); - added = true; - } - int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*stackMultiplier; - tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); - } - break; - case 4: - if(bazaarInfo.has("curr_sell")) { - if(!added) { - tooltip.add(""); - if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]"); - added = true; - } - int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*stackMultiplier; - tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); - } - break; - case 5: - if(craftCost.fromRecipe) { - if(!added) { - tooltip.add(""); - added = true; - } - tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Raw Craft Cost: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)craftCost.craftCost)+" coins"); - } - break; - } - } - - return added; } return false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 9e31c19e..8a842558 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -3,8 +3,6 @@ package io.github.moulberry.notenoughupdates; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; @@ -13,7 +11,6 @@ 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.mixins.MinecraftAccessor; import io.github.moulberry.notenoughupdates.overlays.CommissionOverlay; import io.github.moulberry.notenoughupdates.overlays.FarmingOverlay; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; @@ -30,7 +27,8 @@ import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiEditSign; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.texture.ITextureObject; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; import net.minecraft.init.Blocks; @@ -41,10 +39,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.*; import net.minecraftforge.client.event.*; import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -53,7 +48,6 @@ 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.io.FileUtils; import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -64,8 +58,6 @@ import java.awt.*; import java.awt.datatransfer.StringSelection; import java.io.File; import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; import java.text.NumberFormat; import java.util.List; import java.util.*; @@ -188,7 +180,6 @@ public class NEUEventListener { }); } } else if(!toPreload.isEmpty()) { - System.out.println("Preload size:"+toPreload.size()); Utils.drawItemStack(toPreload.get(0), -100, -100); toPreload.remove(0); } else { @@ -207,6 +198,14 @@ public class NEUEventListener { } DungeonWin.tick(); if(longUpdate) { + /*for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { + if(entity instanceof EntityArmorStand) { + EntityArmorStand stand = (EntityArmorStand) entity; + stand.setInvisible(false); + stand.getDataWatcher().updateObject(10, (byte)(stand.getDataWatcher().getWatchableObjectByte(10) & 0b1111111101111)); + } + }*/ + CrystalOverlay.tick(); DwarvenMinesTextures.tick(); FairySouls.tick(); @@ -626,6 +625,51 @@ public class NEUEventListener { } } + private IChatComponent processChatComponent(IChatComponent chatComponent) { + IChatComponent newComponent; + if(chatComponent instanceof ChatComponentText) { + ChatComponentText text = (ChatComponentText) chatComponent; + + newComponent = new ChatComponentText(processText(text.getUnformattedTextForChat())); + newComponent.setChatStyle(text.getChatStyle().createShallowCopy()); + + for(IChatComponent sibling : text.getSiblings()) { + newComponent.appendSibling(processChatComponent(sibling)); + } + } else if(chatComponent instanceof ChatComponentTranslation) { + ChatComponentTranslation trans = (ChatComponentTranslation) chatComponent; + + Object[] args = trans.getFormatArgs(); + Object[] newArgs = new Object[args.length]; + for(int i=0; i<trans.getFormatArgs().length; i++) { + if(args[i] instanceof IChatComponent) { + newArgs[i] = processChatComponent((IChatComponent) args[i]); + } else { + newArgs[i] = args[i]; + } + } + newComponent = new ChatComponentTranslation(trans.getKey(), newArgs); + + for(IChatComponent sibling : trans.getSiblings()) { + newComponent.appendSibling(processChatComponent(sibling)); + } + } else { + newComponent = chatComponent.createCopy(); + } + + return newComponent; + } + + private String processText(String text) { + if(SBInfo.getInstance().getLocation() == null) return text; + if(!SBInfo.getInstance().getLocation().startsWith("mining_")) return text; + + if(Minecraft.getMinecraft().thePlayer == null) return text; + if(!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return text; + + return Utils.trimIgnoreColour(text.replaceAll(EnumChatFormatting.DARK_GREEN+"\\S+ Drill Fuel", "")); + } + /** * 1) When receiving "You are playing on profile" messages, will set the current profile. * 2) When a /viewrecipe command fails (i.e. player does not have recipe unlocked, will open the custom recipe GUI) @@ -633,6 +677,11 @@ public class NEUEventListener { */ @SubscribeEvent(priority = EventPriority.LOW) public void onGuiChat(ClientChatReceivedEvent e) { + if(e.type == 2) { + e.message = processChatComponent(e.message); + return; + } + DungeonWin.onChatMessage(e); String r = null; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index cd81da0b..592ed628 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1227,19 +1227,22 @@ public class NEUOverlay extends Gui { this.searchedItems = searchedItems; this.searchedItemsSubgroup = searchedItemsSubgroup; - searchedItemsArr = null; + this.searchedItemsArr = null; + redrawItems = true; }); } /** * Returns an index-able array containing the elements in searchedItems. - * Whenever searchedItems is updated via the above method, the array is recreated here. + * Whenever searchedItems is updated in updateSearch(), the array is recreated here. */ public JsonObject[] getSearchedItems() { - if(searchedItems==null) { + if(searchedItems == null) { updateSearch(); + return new JsonObject[0]; } + if(searchedItemsArr==null) { searchedItemsArr = new JsonObject[searchedItems.size()]; int i=0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index b70dcc24..adfe13d5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -660,6 +660,13 @@ 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"); + } + }); + SimpleCommand viewCataCommand = new SimpleCommand("cata", new SimpleCommand.ProcessCommandRunnable() { @Override public void processCommand(ICommandSender sender, String[] args) { @@ -818,24 +825,19 @@ public class NotEnoughUpdates { } }); - SimpleCommand settingsCommand = new SimpleCommand("neu", new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - openGui = new GuiScreenElementWrapper(new NEUConfigEditor(config)); - } - }); - - SimpleCommand settingsCommand2 = new SimpleCommand("neusettings", new SimpleCommand.ProcessCommandRunnable() { - public void processCommand(ICommandSender sender, String[] args) { - openGui = new GuiScreenElementWrapper(new NEUConfigEditor(config)); - } - }); - - SimpleCommand settingsCommand3 = new SimpleCommand("neuconfig", new SimpleCommand.ProcessCommandRunnable() { + SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - openGui = new GuiScreenElementWrapper(new NEUConfigEditor(config)); + if(args.length > 0) { + openGui = new GuiScreenElementWrapper(new NEUConfigEditor(config, StringUtils.join(args, " "))); + } else { + openGui = new GuiScreenElementWrapper(new NEUConfigEditor(config)); + } } - }); + }; + SimpleCommand settingsCommand = new SimpleCommand("neu", settingsRunnable); + SimpleCommand settingsCommand2 = new SimpleCommand("neusettings", settingsRunnable); + SimpleCommand settingsCommand3 = new SimpleCommand("neuconfig", settingsRunnable); SimpleCommand calendarCommand = new SimpleCommand("neucalendar", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { @@ -922,6 +924,7 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(joinDungeonCommand); ClientCommandHandler.instance.registerCommand(viewProfileCommand); ClientCommandHandler.instance.registerCommand(viewProfileShortCommand); + ClientCommandHandler.instance.registerCommand(dhCommand); if(!Loader.isModLoaded("skyblockextras")) ClientCommandHandler.instance.registerCommand(viewCataCommand); ClientCommandHandler.instance.registerCommand(peekCommand); ClientCommandHandler.instance.registerCommand(tutorialCommand); @@ -1059,27 +1062,12 @@ public class NotEnoughUpdates { return hasSkyblockScoreboard; } - //Stolen from Biscut's SkyblockAddons public void updateSkyblockScoreboard() { - final Pattern SERVER_BRAND_PATTERN = Pattern.compile("(.+) <- (?:.+)"); - Minecraft mc = Minecraft.getMinecraft(); if (mc != null && mc.theWorld != null && mc.thePlayer != null) { - if (!mc.isSingleplayer() && mc.thePlayer.getClientBrand() != null) { - Matcher matcher = SERVER_BRAND_PATTERN.matcher(mc.thePlayer.getClientBrand()); - - if (matcher.find()) { - // Group 1 is the server brand. - if(!matcher.group(1).toLowerCase().contains("hypixel")) { - hasSkyblockScoreboard = false; - return; - } - } else { - hasSkyblockScoreboard = false; - return; - } - } else { + if (mc.isSingleplayer() || mc.thePlayer.getClientBrand() == null || + !mc.thePlayer.getClientBrand().toLowerCase().contains("hypixel")) { hasSkyblockScoreboard = false; return; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java index c270397b..8d32d6c3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java @@ -7,7 +7,7 @@ import java.io.IOException; public class GuiScreenElementWrapper extends GuiScreen { - private final GuiElement element; + public final GuiElement element; public GuiScreenElementWrapper(GuiElement element) { this.element = element; 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 fa51cdca..16ce5875 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -366,7 +366,7 @@ public class DungeonMap { private HashMap<Integer, Float> borderRadiusCache = new HashMap<>(); public float getBorderRadius() { - int borderSizeOption = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize; + int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium"; int style = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle; @@ -414,7 +414,7 @@ public class DungeonMap { maxRoomY = Math.max(offset.y, maxRoomY); } - int borderSizeOption = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize; + int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); int renderRoomSize = getRenderRoomSize(); int renderConnSize = getRenderConnSize(); @@ -434,7 +434,7 @@ public class DungeonMap { int mapSizeX; int mapSizeY; if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle <= 1) { - mapSizeX = 80 + (int)Math.round(40*NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); + mapSizeX = 80 + Math.round(40*NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); } else { mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 1 ? 120 : borderSizeOption == 2 ? 160 : 240; } @@ -653,7 +653,8 @@ public class DungeonMap { pixelWidth = pixelHeight = 12; } GlStateManager.color(1, 1, 1, 1); - if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 1 && + if((playerMarkerMapPositions.size() <= 1 || minU != 1/4f) && + NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 1 && playerSkinMap.containsKey(entry.getKey())) { Minecraft.getMinecraft().getTextureManager().bindTexture(playerSkinMap.get(entry.getKey())); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java index 1bcd7fe8..c6f00c56 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java @@ -140,6 +140,8 @@ public class DungeonWin { } public static void onChatMessage(ClientChatReceivedEvent e) { + if(e.type == 2) return; + if(NotEnoughUpdates.INSTANCE.config.dungeonWin.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeonWin.enableDungeonWin) return; long currentTime = System.currentTimeMillis(); String unformatted = Utils.cleanColour(e.message.getUnformattedText()); @@ -165,7 +167,7 @@ public class DungeonWin { TEAM_SCORE = D; break; } - SES.schedule(()->{ + SES.schedule(()-> { NotEnoughUpdates.INSTANCE.sendChatMessage("/showextrastats"); }, 100L, TimeUnit.MILLISECONDS); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java index c011ac9b..36f4b908 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java @@ -31,12 +31,16 @@ public class DamageCommas { if(formatted.length() >= 7 && formatted.startsWith("\u00A7f\u2727") && formatted.endsWith("\u2727\u00a7r")) { + StringBuilder builder = new StringBuilder(); boolean numLast = false; boolean colLast = false; + boolean colLastLast; int numCount = 0; for(int i=formatted.length()-4; i>=3; i--) { char c = formatted.charAt(i); + colLastLast = colLast; + if(c == '\u00a7') { if(numLast) numCount--; numLast = false; @@ -53,8 +57,8 @@ public class DamageCommas { numLast = false; } + if(colLastLast && numLast && numCount > 1 && (numCount-1) % 3 == 0) builder.append(','); builder.append(c); - if(numLast && numCount % 3 == 0) builder.append(','); } ChatComponentText ret = new ChatComponentText("\u00A7f\u2727"+builder.reverse().toString()+"\u2727\u00a7r"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java index 42712c39..856a9d86 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java @@ -54,23 +54,27 @@ public class DwarvenMinesTextures { private static long time; private static boolean error = false; - public static boolean shouldBeRetextured(BlockPos pos) { - if(error) return false; - if(Minecraft.getMinecraft().theWorld == null) return false; + public static int retexture(BlockPos pos) { + if(error) return 0; + if(Minecraft.getMinecraft().theWorld == null) return 0; - if(SBInfo.getInstance().getLocation() == null) return false; - if(!SBInfo.getInstance().getLocation().equals("mining_3")) return false; + if(SBInfo.getInstance().getLocation() == null) return 0; + if(!SBInfo.getInstance().getLocation().equals("mining_3")) return 0; IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(pos); boolean titanium = state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH; if(titanium) { IBlockState plus = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(1, 0, 0)); if(plus.getBlock() == Blocks.double_stone_slab) { - return false; + return 1; } IBlockState minus = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(-1, 0, 0)); if(minus.getBlock() == Blocks.double_stone_slab) { - return false; + return 1; + } + IBlockState above = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(0, 1, 0)); + if(above.getBlock() == Blocks.stone_slab) { + return 1; } } @@ -94,9 +98,8 @@ public class DwarvenMinesTextures { } } } catch(Exception e) { - e.printStackTrace(); error = true; - return false; + return 1; } } if(ignoredChunks != null) { @@ -106,10 +109,10 @@ public class DwarvenMinesTextures { lastRetextureCheck.put(pair, time); if(ignoredChunks.contains(pair)) { - return false; + return 1; } if(titanium) { - return true; + return 2; } if(!loadedChunkData.containsKey(pair)) { @@ -153,7 +156,6 @@ public class DwarvenMinesTextures { } } } catch(Exception e) { - e.printStackTrace(); loadedChunkData.put(pair, null); } } @@ -169,11 +171,11 @@ public class DwarvenMinesTextures { if(map.containsKey(offset)) { IgnoreColumn ignore = map.get(offset); if(ignore.always) { - return false; + return 1; } else { int y = pos.getY(); if(y >= ignore.minY && y <= ignore.maxY) { - return false; + return 1; } } } @@ -181,7 +183,7 @@ public class DwarvenMinesTextures { } } - return true; + return 2; } /*@SubscribeEvent 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 1502cf4a..e206fdcc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java @@ -181,7 +181,7 @@ public class DwarvenMinesWaypoints { for(Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) { if(entry.getKey().equals(powderGhastLocation)) { renderWayPoint(EnumChatFormatting.GOLD+"Powder Ghast", - new Vector3f(entry.getValue()).translate(0, 5, 0), event.partialTicks); + new Vector3f(entry.getValue()).translate(0, 15, 0), event.partialTicks); break; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MinecraftAccessor.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MinecraftAccessor.java deleted file mode 100644 index b40d418b..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MinecraftAccessor.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.github.moulberry.notenoughupdates.mixins; - -import net.minecraft.client.Minecraft; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.io.File; - -@Mixin(Minecraft.class) -public interface MinecraftAccessor { - - @Accessor - public File getFileAssets(); - -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java index 4a282d09..19cc7606 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java @@ -28,7 +28,10 @@ public class MixinWorld { @Inject(method="getBiomeGenForCoords", at=@At("HEAD"), cancellable = true) public void getBiomeGenForCoords(BlockPos pos, CallbackInfoReturnable<BiomeGenBase> cir) { - if(DwarvenMinesTextures.shouldBeRetextured(pos)) { + int retexture = DwarvenMinesTextures.retexture(pos); + if(retexture == 1) { + cir.setReturnValue(BiomeGenBase.extremeHillsPlus); + } else if(retexture == 2) { cir.setReturnValue(BiomeGenBase.extremeHillsEdge); } } 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 ca0ebb2e..2e7afe97 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -1,7 +1,6 @@ package io.github.moulberry.notenoughupdates.options; import com.google.common.collect.Lists; -import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; import io.github.moulberry.notenoughupdates.NEUEventListener; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; @@ -21,6 +20,16 @@ public class NEUConfig extends Config { @Override public void executeRunnable(int runnableId) { + + String activeConfigCategory = null; + if(Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) { + GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen; + if(wrapper.element instanceof NEUConfigEditor) { + activeConfigCategory = ((NEUConfigEditor)wrapper.element).getSelectedCategory(); + } + } + final String activeConfigCategoryF = activeConfigCategory; + switch (runnableId) { case 0: ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neumap"); @@ -34,14 +43,13 @@ public class NEUConfig extends Config { return TextOverlayStyle.BACKGROUND; }); overlay.tick(); - JsonObject test = null; if(overlay.overlayWidth <= 0 || overlay.overlayHeight <= 0) { Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, - 300, 100, () -> { + 150, 75, () -> { }, () -> { }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper( - new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config)) + new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, activeConfigCategoryF)) )); } else { Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( @@ -51,7 +59,7 @@ public class NEUConfig extends Config { NEUEventListener.dontRenderOverlay = CommissionOverlay.class; }, () -> { }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper( - new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config)) + new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, activeConfigCategoryF)) )); } return; @@ -61,7 +69,7 @@ public class NEUConfig extends Config { NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12, () -> { }, () -> { }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper( - new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config)) + new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, activeConfigCategoryF)) )); return; } @@ -1338,7 +1346,7 @@ public class NEUConfig extends Config { maxValue = 5, minStep = 0.25f ) - public int dmBorderSize = 1; + public float dmBorderSize = 1; @Expose @ConfigOption( @@ -1350,7 +1358,7 @@ public class NEUConfig extends Config { maxValue = 5, minStep = 0.25f ) - public int dmRoomSize = 1; + public float dmRoomSize = 1; @Expose @ConfigOption( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java index d870e858..0b00cd5a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -55,15 +55,44 @@ public class NEUConfigEditor extends GuiElement { private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> processedConfig; public NEUConfigEditor(Config config) { + this(config, null); + } + + public NEUConfigEditor(Config config, String categoryOpen) { this.openedMillis = System.currentTimeMillis(); this.processedConfig = ConfigProcessor.create(config); + + if(categoryOpen != null) { + for(String category : processedConfig.keySet()) { + if(category.equalsIgnoreCase(categoryOpen)) { + selectedCategory = category; + break; + } + } + if(selectedCategory == null) { + for(String category : processedConfig.keySet()) { + if(category.toLowerCase().startsWith(categoryOpen.toLowerCase())) { + selectedCategory = category; + break; + } + } + } + if(selectedCategory == null) { + for(String category : processedConfig.keySet()) { + if(category.toLowerCase().contains(categoryOpen.toLowerCase())) { + selectedCategory = category; + break; + } + } + } + } } private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> getCurrentConfigEditing() { return processedConfig; } - private String getSelectedCategory() { + public String getSelectedCategory() { return selectedCategory; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CommissionOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CommissionOverlay.java index 1920c49a..2b07c597 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CommissionOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CommissionOverlay.java @@ -9,6 +9,7 @@ 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; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.scoreboard.ScorePlayerTeam; @@ -48,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 = trimIgnoreColour(name); + mithrilPowder = Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", ""); } if(name.equals(RESET.toString()+BLUE+BOLD+"Forges"+RESET)) { commissions = false; @@ -63,7 +64,7 @@ public class CommissionOverlay extends TextOverlay { if(forges && clean.startsWith(" ")) { if(name.contains("LOCKED")) continue; if(NotEnoughUpdates.INSTANCE.config.mining.hideEmptyForges && name.contains("EMPTY")) continue; - forgeStrings.add(DARK_AQUA+"Forge "+trimIgnoreColour(name)); + 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) { @@ -127,25 +128,6 @@ public class CommissionOverlay extends TextOverlay { } } - private String trimIgnoreColour(String str) { - str = str.trim(); - boolean colourCodeLast = false; - for(int i=0; i<str.length(); i++) { - char c = str.charAt(i); - if(colourCodeLast) { - colourCodeLast = false; - continue; - } - if(c == '\u00A7') { - colourCodeLast = true; - } else if(c != ' ') { - return str.substring(i); - } - } - - return ""; - } - private static final Ordering<NetworkPlayerInfo> playerOrdering = Ordering.from(new PlayerComparator()); @SideOnly(Side.CLIENT) 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 e32e2c87..b391628d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java @@ -1,5 +1,6 @@ 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.XPInformation; @@ -23,16 +24,31 @@ public class FarmingOverlay extends TextOverlay { private float cropsPerSecond = 0; private LinkedList<Integer> counterQueue = new LinkedList<>(); + private XPInformation.SkillInfo skillInfo = null; + private XPInformation.SkillInfo skillInfoLast = null; + private float lastTotalXp = -1; private boolean isFarming = false; private LinkedList<Float> xpGainQueue = new LinkedList<>(); private float xpGainHourLast = -1; private float xpGainHour = -1; + private String skillType = "Farming"; + public FarmingOverlay(Position position, Supplier<TextOverlayStyle> styleSupplier) { super(position, styleSupplier); } + private float interp(float now, float last) { + float interp = now; + if(last >= 0 && last != now) { + float factor = (System.currentTimeMillis()-lastUpdate)/1000f; + factor = LerpUtils.clampZeroOne(factor); + interp = last + (now - last) * factor; + } + return interp; + } + @Override public void update() { lastUpdate = System.currentTimeMillis(); @@ -40,7 +56,30 @@ public class FarmingOverlay extends TextOverlay { xpGainHourLast = xpGainHour; counter = -1; - XPInformation.SkillInfo skillInfo = XPInformation.getInstance().getSkillInfo("Farming"); + if(Minecraft.getMinecraft().thePlayer == null) return; + + ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem(); + if(stack != null && stack.hasTagCompound()) { + NBTTagCompound tag = stack.getTagCompound(); + + if(tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + + if(ea.hasKey("mined_crops", 99)) { + counter = ea.getInteger("mined_crops"); + counterQueue.add(0, counter); + } + } + } + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); + if(internalname != null && internalname.startsWith("THEORETICAL_HOE_WARTS")) { + skillType = "Alchemy"; + } else { + skillType = "Farming"; + } + + skillInfoLast = skillInfo; + skillInfo = XPInformation.getInstance().getSkillInfo(skillType); if(skillInfo != null) { float totalXp = skillInfo.totalXp; @@ -67,21 +106,6 @@ public class FarmingOverlay extends TextOverlay { lastTotalXp = totalXp; } - if(Minecraft.getMinecraft().thePlayer == null) return; - - ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem(); - if(stack != null && stack.hasTagCompound()) { - NBTTagCompound tag = stack.getTagCompound(); - - if(tag.hasKey("ExtraAttributes", 10)) { - NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - - if(ea.hasKey("mined_crops", 99)) { - counter = ea.getInteger("mined_crops"); - counterQueue.add(0, counter); - } - } - } while(counterQueue.size() >= 4) { counterQueue.removeLast(); @@ -113,12 +137,7 @@ public class FarmingOverlay extends TextOverlay { } else { overlayStrings = new ArrayList<>(); - int counterInterp = counter; - if(counterLast > 0 && counterLast != counter) { - float factor = (System.currentTimeMillis()-lastUpdate)/1000f; - factor = LerpUtils.clampZeroOne(factor); - counterInterp = (int)(counterLast + (counter - counterLast) * factor); - } + int counterInterp = (int)interp(counter, counterLast); NumberFormat format = NumberFormat.getIntegerInstance(); overlayStrings.add(EnumChatFormatting.AQUA+"Counter: "+EnumChatFormatting.YELLOW+format.format(counterInterp)); @@ -126,20 +145,14 @@ public class FarmingOverlay extends TextOverlay { if(cropsPerSecondLast == cropsPerSecond && cropsPerSecond <= 0) { overlayStrings.add(EnumChatFormatting.AQUA+"Crops/m: "+EnumChatFormatting.YELLOW+"N/A"); } else { - float cpsInterp = cropsPerSecond; - if(cropsPerSecondLast >= 0 && cropsPerSecondLast != cropsPerSecond) { - float factor = (System.currentTimeMillis()-lastUpdate)/1000f; - factor = LerpUtils.clampZeroOne(factor); - cpsInterp = cropsPerSecondLast + (cropsPerSecond - cropsPerSecondLast) * factor; - } + float cpsInterp = interp(cropsPerSecond, cropsPerSecondLast); overlayStrings.add(EnumChatFormatting.AQUA+"Crops/m: "+EnumChatFormatting.YELLOW+ String.format("%.2f", cpsInterp*60)); } - XPInformation.SkillInfo skillInfo = XPInformation.getInstance().getSkillInfo("Farming"); if(skillInfo != null) { - StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + "Level: "); + StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + skillType.substring(0, 4) + ": "); levelStr.append(EnumChatFormatting.YELLOW) .append(skillInfo.level) @@ -147,6 +160,9 @@ public class FarmingOverlay extends TextOverlay { .append(" ["); float progress = skillInfo.currentXp / skillInfo.currentXpMax; + if(skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) { + progress = interp(progress, skillInfoLast.currentXp / skillInfoLast.currentXpMax); + } float lines = 25; for(int i=0; i<lines; i++) { @@ -164,22 +180,25 @@ public class FarmingOverlay extends TextOverlay { .append((int)(progress*100)) .append("%"); + int current = (int)skillInfo.currentXp; + if(skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) { + current = (int)interp(current, skillInfoLast.currentXp); + } + + int remaining = (int)(skillInfo.currentXpMax - skillInfo.currentXp); + if(skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) { + remaining = (int)interp(remaining, (int)(skillInfoLast.currentXpMax - skillInfoLast.currentXp)); + } + overlayStrings.add(levelStr.toString()); - overlayStrings.add(EnumChatFormatting.AQUA+"Current XP: " + EnumChatFormatting.YELLOW+ - format.format((int)skillInfo.currentXp)); - overlayStrings.add(EnumChatFormatting.AQUA+"Remaining XP: " + EnumChatFormatting.YELLOW+ - format.format((int)(skillInfo.currentXpMax - skillInfo.currentXp))); + overlayStrings.add(EnumChatFormatting.AQUA+"Current XP: " + EnumChatFormatting.YELLOW+ format.format(current)); + overlayStrings.add(EnumChatFormatting.AQUA+"Remaining XP: " + EnumChatFormatting.YELLOW+ format.format(remaining)); } if(xpGainHourLast == xpGainHour && xpGainHour <= 0) { overlayStrings.add(EnumChatFormatting.AQUA+"XP/h: "+EnumChatFormatting.YELLOW+"N/A"); } else { - float xpInterp = xpGainHour; - if(xpGainHourLast >= 0 && cropsPerSecondLast != xpGainHour) { - float factor = (System.currentTimeMillis()-lastUpdate)/1000f; - factor = LerpUtils.clampZeroOne(factor); - xpInterp = xpGainHourLast + (xpGainHour - xpGainHourLast) * factor; - } + float xpInterp = interp(xpGainHour, xpGainHourLast); overlayStrings.add(EnumChatFormatting.AQUA+"XP/h: "+EnumChatFormatting.YELLOW+ format.format(xpInterp)+(isFarming ? "" : EnumChatFormatting.RED + " (PAUSED)")); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 0ee6e2ff..c42f2697 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -2288,7 +2288,7 @@ public class GuiProfileViewer extends GuiScreen { if(n % 1 == 0) { return Integer.toString((int)n); } else { - return Double.toString(n); + return String.format("%.2f", n); } } 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 e40edd4f..f452b406 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -228,6 +228,48 @@ public class Utils { : shortNumberFormat(d, iteration+1)); } + public static String trimIgnoreColour(String str) { + return trimIgnoreColourStart(trimIgnoreColourEnd(str)); + } + + public static String trimIgnoreColourStart(String str) { + str = str.trim(); + boolean colourCodeLast = false; + StringBuilder colours = new StringBuilder(); + for(int i=0; i<str.length(); i++) { + char c = str.charAt(i); + if(colourCodeLast) { + colours.append('\u00a7').append(c); + colourCodeLast = false; + continue; + } + if(c == '\u00A7') { + colourCodeLast = true; + } else if(c != ' ') { + return colours.append(str.substring(i)).toString(); + } + } + + return ""; + } + + public static String trimIgnoreColourEnd(String str) { + str = str.trim(); + for(int i=str.length()-1; i>=0; i--) { + char c = str.charAt(i); + if(c == ' ') { + continue; + } else if(i > 0 && str.charAt(i-1) == '\u00a7') { + i--; + continue; + } + + return str.substring(0, i+1); + } + + return ""; + } + public static void drawItemStackLinear(ItemStack stack, int x, int y) { if(stack == null)return; |