summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfo.java372
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java68
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java8
7 files changed, 465 insertions, 10 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index 070b2d66..d2eaea1b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -203,6 +203,9 @@ public class NEUEventListener {
ProfileApiSyncer.getInstance().tick();
DamageCommas.tick();
BackgroundBlur.markDirty();
+ if(neu.config.overlay.enablePetInfo || neu.config.treecap.enableMonkeyCheck || neu.config.notifications.showWrongPetMsg){
+ PetInfo.longTick();
+ }
for(TextOverlay overlay : OverlayManager.textOverlays) {
overlay.tick();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 1dbbb956..d072612b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -916,6 +916,7 @@ public class NotEnoughUpdates {
MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints());
MinecraftForge.EVENT_BUS.register(new FuelBar());
MinecraftForge.EVENT_BUS.register(XPInformation.getInstance());
+ MinecraftForge.EVENT_BUS.register(new PetInfo());
ClientCommandHandler.instance.registerCommand(collectionLogCommand);
ClientCommandHandler.instance.registerCommand(cosmeticsCommand);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
index 45d55b1d..8e334d3b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
@@ -318,7 +318,7 @@ public class CustomItemEffects {
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)event.partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)event.partialTicks;
- if(NotEnoughUpdates.INSTANCE.config.treecapOverlay.enableTreecapOverlay &&
+ if(NotEnoughUpdates.INSTANCE.config.treecap.enableTreecapOverlay &&
(heldInternal.equals("JUNGLE_AXE") || heldInternal.equals("TREECAPITATOR_AXE"))) {
int maxWood = 10;
if(heldInternal.equals("TREECAPITATOR_AXE")) maxWood = 35;
@@ -378,7 +378,7 @@ public class CustomItemEffects {
drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
.expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
- random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.config.treecapOverlay.treecapOverlayColour);
+ random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.config.treecap.treecapOverlayColour);
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
index f567ead5..f3a21b1d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
@@ -52,6 +52,19 @@ public class ItemCooldowns {
blocksClicked.clear();
}
+ public static long getTreecapCooldownWithPet(){
+ if (NotEnoughUpdates.INSTANCE.config.treecap.enableMonkeyCheck && PetInfo.currentPet != null) {
+ PetInfo.pet pet = PetInfo.currentPet;
+ if (pet.petLevel != null &&
+ pet.petType.equalsIgnoreCase("monkey") &&
+ pet.rarity.equals(PetInfo.Rarity.LEGENDARY)
+ ) {
+ return 2000 - (int) (2000 * (0.005 * (int) PetInfo.currentPet.petLevel.level));
+ }
+ }
+ return 2000;
+ }
+
public static void blockClicked(BlockPos pos) {
long currentTime = System.currentTimeMillis();
blocksClicked.put(currentTime, pos);
@@ -74,7 +87,7 @@ public class ItemCooldowns {
if(internalname != null) {
if(treecapitatorCooldownMillisRemaining < 0 &&
(internalname.equals("TREECAPITATOR_AXE") || internalname.equals("JUNGLE_AXE"))) {
- treecapitatorCooldownMillisRemaining = 2*1000;
+ treecapitatorCooldownMillisRemaining = getTreecapCooldownWithPet();
}
}
}
@@ -120,10 +133,10 @@ public class ItemCooldowns {
return -1;
}
- if(treecapitatorCooldownMillisRemaining > 2*1000) {
+ if(treecapitatorCooldownMillisRemaining > getTreecapCooldownWithPet()) {
return stack.getItemDamage();
}
- float dura = (float)(treecapitatorCooldownMillisRemaining/(2.0*1000.0));
+ float dura = (treecapitatorCooldownMillisRemaining/(float)getTreecapCooldownWithPet());
durabilityOverrideMap.put(stack, dura);
return dura;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfo.java
new file mode 100644
index 00000000..49b6c164
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfo.java
@@ -0,0 +1,372 @@
+package io.github.moulberry.notenoughupdates.miscfeatures;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor;
+import io.github.moulberry.notenoughupdates.options.NEUConfig;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
+import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.client.event.ClientChatReceivedEvent;
+import net.minecraftforge.client.event.RenderGameOverlayEvent;
+import net.minecraftforge.event.world.WorldEvent;
+import net.minecraftforge.fml.common.Loader;
+import net.minecraftforge.fml.common.eventhandler.EventPriority;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import org.apache.commons.lang3.text.WordUtils;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class PetInfo {
+
+ private static final Pattern XP_GAIN_AND_SKILL_PATTERN = Pattern.compile("\\+(\\d*\\.?\\d*) (Farming|Mining|Combat|Foraging|Fishing|Enchanting|Alchemy) (\\(([0-9.,]+)/([0-9.,]+)\\))");
+ private static final Pattern XP_BOOST_PATTERN = Pattern.compile("PET_ITEM_(COMBAT|FISHING|MINING|FORAGING|ALL|FARMING)_(SKILL|SKILLS)_BOOST_(COMMON|UNCOMMON|RARE|EPIC)");
+
+ public enum Rarity {
+ COMMON(0, 0, 1, EnumChatFormatting.WHITE),
+ UNCOMMON(6, 1, 2, EnumChatFormatting.GREEN),
+ RARE(11, 2, 3, EnumChatFormatting.BLUE),
+ EPIC(16, 3, 4, EnumChatFormatting.DARK_PURPLE),
+ LEGENDARY(20, 4, 5, EnumChatFormatting.GOLD),
+ MYTHIC(20, 4, 5, EnumChatFormatting.LIGHT_PURPLE);
+
+ public int petOffset;
+ public EnumChatFormatting chatFormatting;
+ public int petId;
+ public int beastcreatMultiplyer;
+
+ Rarity(int petOffset, int petId, int beastcreatMultiplyer, EnumChatFormatting chatFormatting){
+ this.chatFormatting = chatFormatting;
+ this.petOffset = petOffset;
+ this.petId = petId;
+ this.beastcreatMultiplyer = beastcreatMultiplyer;
+ }
+
+ public static Rarity getRarityFromColor(EnumChatFormatting chatFormatting){
+ for (int i = 0; i < Rarity.values().length; i++) {
+ if (Rarity.values()[i].chatFormatting.equals(chatFormatting))
+ return Rarity.values()[i];
+ }
+ return COMMON;
+ }
+ }
+
+ public static class pet {
+ public String petType;
+ public double petExp;
+ public Rarity rarity;
+ public GuiProfileViewer.PetLevel petLevel;
+ public String petXpType;
+ public String petItem;
+ }
+
+ public static pet currentPet = null;
+ public static HashMap<String, pet> petList = new HashMap<>();
+
+ public static double currentXp = 0.0;
+ public static String currentXpType = "";
+ public static int tamingLevel = 1;
+ public static double beastMultiplier = 0;
+ public static boolean ignoreNextXp = false;
+
+ public static void clearPet(){ currentPet = null; }
+
+ public float getLevelPercent(){
+ DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
+ try {
+ return Float.parseFloat(df.format(currentPet.petLevel.levelPercentage * 100f ));
+ }catch (Exception ignored){ return 0; }
+ }
+
+ private static void getAndSetPet(ProfileViewer.Profile profile) {
+ JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile());
+ JsonObject skillInfo = profile.getSkillInfo(profile.getLatestProfile());
+ JsonObject invInfo = profile.getInventoryInfo(profile.getLatestProfile());
+ JsonObject profileInfo = profile.getProfileInformation(profile.getLatestProfile());
+ if (invInfo != null && profileInfo != null){
+ JsonObject stats = profileInfo.get("stats").getAsJsonObject();
+ boolean hasBeastmasterCrest = false;
+ Rarity currentBeastRarity = Rarity.COMMON;
+ for (JsonElement talisman : invInfo.get("talisman_bag").getAsJsonArray()) {
+ if (talisman.isJsonNull()) continue;
+ String internalName = talisman.getAsJsonObject().get("internalname").getAsString();
+ if (internalName.startsWith("BEASTMASTER_CREST")) {
+ hasBeastmasterCrest = true;
+ try {
+ Rarity talismanRarity = Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", ""));
+ if (talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer) currentBeastRarity = talismanRarity;
+ } catch (Exception ignored) {}
+ }
+ }
+ if (hasBeastmasterCrest) {
+ if (stats.has("mythos_kills")) {
+ int mk = stats.get("mythos_kills").getAsInt();
+ double petXpBoost = mk > 10000 ? 1 : mk > 7500 ? 0.9 : mk > 5000 ? 0.8 : mk > 2500 ? 0.7 :
+ mk > 1000 ? 0.6 : mk > 500 ? 0.5 : mk > 250 ? 0.4 : mk > 100 ? 0.3 : mk > 25 ? 0.2 : 0.1;
+ beastMultiplier = petXpBoost * currentBeastRarity.beastcreatMultiplyer;
+ }else beastMultiplier = 0.1 * currentBeastRarity.beastcreatMultiplyer;
+ }
+ }
+ if (skillInfo != null) tamingLevel = skillInfo.get("level_skill_taming").getAsInt();
+ JsonObject petsJson = Constants.PETS;
+ if (petsJson != null) {
+ if (petObject != null) {
+ boolean hasActivePet = false;
+ petList.clear();
+
+ for (int i = 0; i < petObject.getAsJsonArray("pets").size(); i++) {
+ JsonElement petElement = petObject.getAsJsonArray("pets").get(i);
+ JsonObject petObj = petElement.getAsJsonObject();
+ pet pet = new pet();
+ pet.petType = petObj.get("type").getAsString();
+ Rarity rarity;
+ try {
+ rarity = Rarity.valueOf(petObj.get("tier").getAsString());
+ } catch (Exception ignored) {
+ rarity = Rarity.COMMON;
+ }
+ pet.rarity = rarity;
+ pet.petExp = petObj.get("exp").getAsDouble();
+ pet.petLevel = GuiProfileViewer.getPetLevel(petsJson.get("pet_levels").getAsJsonArray(), rarity.petOffset, (float) pet.petExp);
+ JsonElement heldItem = petObj.get("heldItem");
+ pet.petItem = heldItem.isJsonNull() ? null : heldItem.getAsString();
+ JsonObject petTypes = petsJson.get("pet_types").getAsJsonObject();
+ pet.petXpType = petTypes.has(pet.petType) ? petTypes.get(pet.petType.toUpperCase()).getAsString().toLowerCase() : "unknown";
+
+ petList.put(pet.petType + ";" + pet.rarity.petId, pet);
+ if (petObj.get("active").getAsBoolean()) {
+ hasActivePet = true;
+ if (currentPet == null || (pet.petType.equalsIgnoreCase(currentPet.petType) && pet.rarity.equals(currentPet.rarity))) {
+ if (currentPet != null && ((currentPet.petLevel.level == pet.petLevel.level && currentPet.petLevel.levelPercentage > pet.petLevel.levelPercentage) || currentPet.petLevel.level > pet.petLevel.level))
+ pet.petLevel = currentPet.petLevel;
+ currentPet = pet;
+ }
+ }
+ }
+ if (!hasActivePet){
+ clearPet();
+ }
+ }
+ }
+ }
+
+ public static void longTick(){
+ NEUConfig config = NotEnoughUpdates.INSTANCE.config;
+ int updateTime = 90000;
+ if ((config.treecap.enableMonkeyCheck || config.notifications.showWrongPetMsg) && !config.overlay.enablePetInfo) updateTime = 300000;
+
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()){
+ ProfileApiSyncer.getInstance().requestResync("petinfo", updateTime, () -> {}, PetInfo::getAndSetPet);
+ }
+ }
+
+ public static float getCurrentLevelReqs(float level, pet pet){
+ JsonObject petsJson = Constants.PETS;
+ if (petsJson != null){
+ return petsJson.get("pet_levels").getAsJsonArray().get((int) (level+pet.rarity.petOffset)).getAsFloat();
+ }
+ return 0;
+ }
+
+ public static double getBoostMultiplyer(String boostName){
+ if (boostName == null) return 1;
+ if (boostName.equalsIgnoreCase("PET_ITEM_ALL_SKILLS_BOOST_COMMON")) {
+ return 1.1;
+ }else if (boostName.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")){
+ return 1.2;
+ }else if (boostName.endsWith("epic")){
+ return 1.5;
+ }else if (boostName.endsWith("rare")){
+ return 1.4;
+ }else if (boostName.endsWith("uncommon")){
+ return 1.3;
+ }else if (boostName.endsWith("common")){
+ return 1.2;
+ }
+ else return 1;
+ }
+
+ public static double getXpGain(pet pet, double xp, String xpType){
+ double tamingPercent = 1.0 + (tamingLevel / 100f);
+ xp = xp * tamingPercent;
+ xp = xp + (xp * beastMultiplier);
+ if (pet.petXpType != null && !pet.petXpType.equalsIgnoreCase(xpType)){
+ xp = ((xpType.equalsIgnoreCase("alchemy") && !pet.petXpType.equalsIgnoreCase("alchemy")) || xpType.equalsIgnoreCase("enchanting") ) ?
+ xp * 0.08 : xp * 0.33;
+ }
+ if (xpType.equalsIgnoreCase("mining") || xpType.equalsIgnoreCase("fishing")){
+ xp = xp * 1.5;
+ }
+ if (pet.petItem != null) {
+ Matcher petItemMatcher = XP_BOOST_PATTERN.matcher(pet.petItem);
+ if ((petItemMatcher.matches() && petItemMatcher.group(1).equalsIgnoreCase(pet.petXpType)) || pet.petItem.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST"))
+ xp = xp * getBoostMultiplyer(pet.petItem);
+ }
+ return xp;
+ }
+
+
+ @SubscribeEvent
+ public void onOverlayDrawn(RenderGameOverlayEvent.Post event) {
+ NEUConfig config = NotEnoughUpdates.INSTANCE.config;
+ if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && config.overlay.enablePetInfo && ((event.type == null && Loader.isModLoaded("labymod")) ||
+ event.type == RenderGameOverlayEvent.ElementType.ALL)
+ ){
+ Minecraft mc = Minecraft.getMinecraft();
+ if (mc.gameSettings.showDebugInfo ||
+ (mc.gameSettings.keyBindPlayerList.isKeyDown() &&
+ (!mc.isIntegratedServerRunning() ||
+ mc.thePlayer.sendQueue.getPlayerInfoMap().size() > 1))) {
+ return;
+ }
+
+ if (currentPet != null && currentPet.petLevel != null && !currentPet.petType.isEmpty()) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ FontRenderer font = mc.fontRendererObj;
+
+ int overlayStyle = config.overlay.petInfoOverlayStyle;
+
+ String petName = EnumChatFormatting.GREEN + "[Lvl " + (int) currentPet.petLevel.level + "] " + currentPet.rarity.chatFormatting +
+ WordUtils.capitalizeFully(currentPet.petType.replace("_", " "));
+ String lvlString = EnumChatFormatting.AQUA + "" + Utils.shortNumberFormat((currentPet.petLevel.currentLevelRequirement * currentPet.petLevel.levelPercentage), 0) + "/" + Utils.shortNumberFormat(currentPet.petLevel.currentLevelRequirement, 0) + EnumChatFormatting.YELLOW + " (" + getLevelPercent() + "%)";
+
+ int xPos = config.overlay.petInfoPosition.getAbsX(scaledResolution, Math.max(font.getStringWidth(petName), font.getStringWidth(lvlString)) + 20);
+ int yPos = config.overlay.petInfoPosition.getAbsY(scaledResolution, (currentPet.petLevel.level < 100 ? 22 : 11)) + 2;
+
+ if (!(mc.currentScreen instanceof GuiPositionEditor) && overlayStyle == 0)
+ Gui.drawRect(xPos, yPos-2, xPos+Math.max(font.getStringWidth(lvlString), font.getStringWidth(petName))+20, yPos+(currentPet.petLevel.level < 100 ? 20 : 16), 0x80000000);
+
+ if (overlayStyle == 3) {
+ for (int xO = -2; xO <= 2; xO++) {
+ for (int yO = -2; yO <= 2; yO++) {
+ if (Math.abs(xO) != Math.abs(yO)) {
+ font.drawString(Utils.cleanColour(petName), xPos + 20 + xO / 2f, yPos + (currentPet.petLevel.level < 100 ? 0 : 4) + yO / 2f, 0x000000, false);
+ }
+ }
+ }
+ }
+
+ font.drawString(petName, xPos + 20, yPos + (currentPet.petLevel.level < 100 ? 0 : 4), 0xffffff, overlayStyle == 2);
+ if (currentPet.petLevel.level < 100){
+ if (overlayStyle == 3) {
+ for (int xO = -2; xO <= 2; xO++) {
+ for (int yO = -2; yO <= 2; yO++) {
+ if (Math.abs(xO) != Math.abs(yO)) {
+ font.drawString(Utils.cleanColour(lvlString), xPos + 20 + xO / 2f, yPos + font.FONT_HEIGHT + yO / 2f, 0x000000, false);
+ }
+ }
+ }
+ }
+ font.drawString(lvlString, xPos + 20, yPos + font.FONT_HEIGHT, 0xffffff, overlayStyle == 2);
+ }
+
+ JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet.petType+";"+currentPet.rarity.petId);
+ if(petItem != null) {
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem, false, false, false);
+ Utils.drawItemStack(stack, xPos, yPos);
+ }
+ GlStateManager.color(0,0,0);
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void switchWorld(WorldEvent.Load event) {
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ ProfileApiSyncer.getInstance().requestResync("petinfo", 10000, () -> {
+ }, PetInfo::getAndSetPet);
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ public void onChatReceived(ClientChatReceivedEvent event) {
+ NEUConfig config = NotEnoughUpdates.INSTANCE.config;
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && (config.overlay.enablePetInfo || config.treecap.enableMonkeyCheck || config.notifications.showWrongPetMsg)) {
+ if (event.type == 0) {
+ String chatMessage = Utils.cleanColour(event.message.getUnformattedText());
+ String petLevelMessage = "your " + (currentPet != null ? currentPet.petType.toLowerCase().replace("_", " ") : "") + " levelled up to level";
+ if (chatMessage.toLowerCase().startsWith("you summoned your")) {
+ String pet = chatMessage.trim().toUpperCase().replace("YOU SUMMONED YOUR ", "").replace("!", "").replace(" ", "_");
+ Rarity rarity = event.message.getSiblings().size() == 3 ? Rarity.getRarityFromColor(event.message.getSiblings().get(1).getChatStyle().getColor()) : Rarity.COMMON;
+ if (petList.containsKey(pet + ";" + rarity.petId)) {
+ if (currentPet != null) petList.put(currentPet.petType + ";" + currentPet.rarity.petId, currentPet);
+ pet summonedPet = new pet();
+ summonedPet.petType = pet;
+ summonedPet.rarity = rarity;
+ summonedPet.petLevel = petList.get(pet + ";" + rarity.petId).petLevel;
+ summonedPet.petXpType = petList.get(pet + ";" + rarity.petId).petXpType;
+ currentPet = summonedPet;
+ }
+ } else if (chatMessage.toLowerCase().startsWith("you despawned your")) {
+ if (currentPet != null) {
+ petList.put(currentPet.petType + ";" + currentPet.rarity.petId, currentPet);
+ }
+ clearPet();
+ } else if (chatMessage.toLowerCase().startsWith(petLevelMessage)) {
+ if (currentPet != null) {
+ try {
+ ignoreNextXp = true;
+ currentPet.petLevel.level = Integer.parseInt(chatMessage.toLowerCase().replace(petLevelMessage, "").replace("!", "").replace(" ", ""));
+ currentPet.petLevel.levelPercentage = 0;
+ currentPet.petLevel.currentLevelRequirement = getCurrentLevelReqs(currentPet.petLevel.level, currentPet);
+ } catch (Exception ignored) {}
+ }
+ } else if (chatMessage.toLowerCase().contains("switching to profile")) {
+ clearPet();
+ petList.clear();
+ }
+ }
+ if (event.type == 2) {
+ String[] parts = Utils.cleanColour(event.message.getUnformattedText()).split(" {3,}");
+ if (parts.length == 3) {
+ Matcher matcher = XP_GAIN_AND_SKILL_PATTERN.matcher(parts[1].trim());
+ if (currentPet != null && matcher.matches()) {
+ String oldXpType = currentXpType;
+ currentXpType = matcher.group(2);
+ try {
+ double actionXp = Double.parseDouble(matcher.group(4).replace(",", ""));
+ if (actionXp != currentXp && actionXp != 0) {
+ if (NotEnoughUpdates.INSTANCE.config.notifications.showWrongPetMsg &&
+ currentXpType.equalsIgnoreCase(oldXpType) &&
+ !currentXpType.equalsIgnoreCase(currentPet.petXpType)
+ ){
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "[NEU]" + EnumChatFormatting.GOLD + " \u26A0 You're using a " + WordUtils.capitalizeFully(currentPet.petXpType) + " pet while gathering " + WordUtils.capitalizeFully(currentXpType) + " skill xp."));
+ }
+ double xpGain = !currentXpType.equalsIgnoreCase(oldXpType) ? Double.parseDouble(matcher.group(1)) : actionXp - currentXp;
+ currentXp = actionXp;
+ double xp = currentPet.petLevel.levelPercentage * currentPet.petLevel.currentLevelRequirement;
+ double newXp = xp + getXpGain(currentPet, xpGain, currentXpType);
+ if (ignoreNextXp) {
+ //TODO : This needs to be changed to a better system as you can lose accuracy of levels with this,
+ // will fix it self when it syncs to the api
+ ignoreNextXp = false;
+ } else {
+ currentPet.petExp = newXp;
+ currentPet.petLevel.levelPercentage = (float) (currentPet.petExp / currentPet.petLevel.currentLevelRequirement);
+ }
+ }
+ }catch (NumberFormatException ignored){}
+ }
+ }
+ }
+ }
+ }
+}
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 045b4cdb..1c0528da 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -62,6 +62,15 @@ public class NEUConfig extends Config {
case 3:
editOverlay(activeConfigCategory, OverlayManager.farmingOverlay, skillOverlays.farmingPosition);
return;
+ case 4:
+ Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(
+ NotEnoughUpdates.INSTANCE.config.overlay.petInfoPosition,
+ 150, 22, () -> {
+ }, () -> {
+ }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(
+ new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, activeConfigCategoryF))
+ ));
+ return;
}
}
@@ -184,7 +193,14 @@ public class NEUConfig extends Config {
name = "Treecap Overlay",
desc = "Treecap Overlay"
)
- public TreecapOverlay treecapOverlay = new TreecapOverlay();
+ public Treecap treecap = new Treecap();
+
+ @Expose
+ @Category(
+ name = "Overlays",
+ desc = "Overlays"
+ )
+ public Overlay overlay = new Overlay();
@Expose
@Category(
@@ -307,6 +323,14 @@ public class NEUConfig extends Config {
)
@ConfigEditorBoolean
public boolean showUpdateMsg = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Wrong Pet",
+ desc = "Gives a notification in chat whenever you're using a pet that doesnt match the same xp you're gathering."
+ )
+ @ConfigEditorBoolean
+ public boolean showWrongPetMsg = false;
}
public static class Itemlist {
@@ -1088,7 +1112,7 @@ public class NEUConfig extends Config {
public boolean customTradePriceStyle = true;
}
- public static class TreecapOverlay {
+ public static class Treecap {
@Expose
@ConfigOption(
name = "Enable Treecap Overlay",
@@ -1104,6 +1128,46 @@ public class NEUConfig extends Config {
)
@ConfigEditorColour
public String treecapOverlayColour = "00:50:64:224:208";
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Monkey Pet Check",
+ desc = "Will check use the API to check what pet you're using\nto determine the cooldown based off of if you have monkey pet."
+ )
+ @ConfigEditorBoolean
+
+ public boolean enableMonkeyCheck = false;
+ }
+
+ public static class Overlay {
+ @Expose
+ @ConfigOption(
+ name = "Enable Pet Info Overlay",
+ desc = "Shows current active pet and pet exp on screen."
+ )
+ @ConfigEditorBoolean
+ public boolean enablePetInfo = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Pet Info Position",
+ desc = "The position of the pet info."
+ )
+ @ConfigEditorButton(
+ runnableId = 4,
+ buttonText = "Edit"
+ )
+ public Position petInfoPosition = new Position(0, 15);
+
+ @Expose
+ @ConfigOption(
+ name = "Pet Info Overlay Style",
+ desc = "Change the style of the Pet Info overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ public int petInfoOverlayStyle = 0;
}
public static class BuilderWand {
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 ce42b810..c47a1091 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -1011,9 +1011,10 @@ public class GuiProfileViewer extends GuiScreen {
}
public static class PetLevel {
- float level;
- float currentLevelRequirement;
- float maxXP;
+ public float level;
+ public float currentLevelRequirement;
+ public float maxXP;
+ public float levelPercentage;
}
public static PetLevel getPetLevel(JsonArray levels, int offset, float exp) {
@@ -1050,6 +1051,7 @@ public class GuiProfileViewer extends GuiScreen {
levelObj.level = level;
levelObj.currentLevelRequirement = currentLevelRequirement;
levelObj.maxXP = xpTotal;
+ levelObj.levelPercentage = remainingToNextLevel;
return levelObj;
}