aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Update Notes/2.1.md1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java88
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java24
6 files changed, 129 insertions, 1 deletions
diff --git a/Update Notes/2.1.md b/Update Notes/2.1.md
index 4dbf4587..338c898e 100644
--- a/Update Notes/2.1.md
+++ b/Update Notes/2.1.md
@@ -19,6 +19,7 @@
- Make cata xp in /pv be calculated on how many runs you have and shows master mode xp rates
- Hide mine waypoints when at location setting - Lulonaut
- Added some info panels to some settings in /neu
+- Added Kat Level After Upgrade Estimator - nea89
- Added /pv button in /neu
- Added pitch and coins/m as options in farming skill overlay
- Make it so tab completion in ah search GUI goes down the items - Lulonaut
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index bf3a0714..3aaad72c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates;
import com.google.gson.*;
import io.github.moulberry.notenoughupdates.auction.APIManager;
import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import io.github.moulberry.notenoughupdates.miscgui.KatSitterOverlay;
import io.github.moulberry.notenoughupdates.recipes.CraftingOverlay;
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe;
import io.github.moulberry.notenoughupdates.recipes.Ingredient;
@@ -82,6 +83,8 @@ public class NEUManager {
public File configFile;
public HotmInformation hotm;
+ public KatSitterOverlay katSitterOverlay;
+
public CraftingOverlay craftingOverlay;
public NEUManager(NotEnoughUpdates neu, File configLocation) {
@@ -90,7 +93,7 @@ public class NEUManager {
this.auctionManager = new APIManager(this);
this.hotm = new HotmInformation(neu);
this.craftingOverlay = new CraftingOverlay(this);
-
+ this.katSitterOverlay = new KatSitterOverlay();
GIT_COMMITS_URL = neu.config.hidden.repoCommitsURL;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java
new file mode 100644
index 00000000..39d3a673
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java
@@ -0,0 +1,88 @@
+package io.github.moulberry.notenoughupdates.miscgui;
+
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import io.github.moulberry.notenoughupdates.util.XPInformation;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.init.Blocks;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.client.event.GuiScreenEvent;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+public class KatSitterOverlay {
+ public KatSitterOverlay() {
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ @SubscribeEvent
+ public void onGuiDrawn(GuiScreenEvent.DrawScreenEvent.Post event) {
+ if (!(event.gui instanceof GuiChest)) return;
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.showKatSitting) return;
+ GuiChest gui = (GuiChest) event.gui;
+ ContainerChest container = (ContainerChest) gui.inventorySlots;
+ if (!"Pet Sitter".equals(container.getLowerChestInventory().getDisplayName().getUnformattedText())) return;
+ Slot slot = container.getSlot(13);
+ if (slot == null || !slot.getHasStack() || slot.getStack() == null) return;
+ ItemStack item = slot.getStack();
+ NBTTagCompound tagCompound = item.getTagCompound();
+ if (tagCompound == null || !tagCompound.hasKey("ExtraAttributes", 10)) return;
+ NBTTagCompound extra = tagCompound.getCompoundTag("ExtraAttributes");
+ if (extra == null || !extra.hasKey("id", 8) ||
+ !"PET".equals(extra.getString("id")) || !extra.hasKey("petInfo", 8))
+ return;
+ JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(extra.getString("petInfo"), JsonObject.class);
+ if (petInfo == null || !petInfo.has("exp") || !petInfo.has("tier") || !petInfo.has("type")) return;
+ String petId = petInfo.get("type").getAsString();
+ double xp = petInfo.get("exp").getAsDouble();
+ String rarity = petInfo.get("tier").getAsString();
+ Slot katSlot = container.getSlot(22);
+ String upgradedRarity = nextRarity(rarity);
+ boolean nextRarityPresent = katSlot.getStack() != null && katSlot.getStack().getItem() != Item.getItemFromBlock(Blocks.barrier) && upgradedRarity != null;
+ renderPetInformation(
+ (int) XPInformation.getInstance().getPetLevel(petId, xp, rarity),
+ nextRarityPresent ? (int) XPInformation.getInstance().getPetLevel(petId, xp, upgradedRarity) : null,
+ gui
+ );
+ }
+
+
+ public void renderPetInformation(int currentLevel, Integer upgradedLevel, GuiChest gui) {
+ FontRenderer font = Minecraft.getMinecraft().fontRendererObj;
+ String currentText = "Current pet level: " + currentLevel;
+ int currentWidth = font.getStringWidth(currentText);
+ String upgradedText = "Upgraded pet level: " + upgradedLevel;
+ int upgradedWidth = font.getStringWidth(upgradedText);
+ int left = gui.guiLeft - 30 - (upgradedLevel == null ? Math.max(upgradedWidth, currentWidth) : currentWidth);
+ GlStateManager.disableLighting();
+ GlStateManager.color(1F, 1F, 1F, 1F);
+ Utils.drawStringScaled(currentText, font, left, gui.guiTop + 25, false, 0xFFD700, 1F);
+ if (upgradedLevel != null)
+ Utils.drawStringScaled(upgradedText, font, left, gui.guiTop + 45, false, 0xFFD700, 1F);
+ }
+
+ public String nextRarity(String currentRarity) {
+ switch (currentRarity.intern()) {
+ case "COMMON":
+ return "UNCOMMON";
+ case "UNCOMMON":
+ return "RARE";
+ case "RARE":
+ return "EPIC";
+ case "EPIC":
+ return "LEGENDARY";
+ case "LEGENDARY":
+ return "MYTHIC";
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java
index a9adb4ad..7b0ed48c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java
@@ -105,4 +105,12 @@ public class PetOverlay {
)
@ConfigEditorBoolean
public boolean hidePetTooltip = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Show upgraded Pet Level",
+ desc = "Show the estimated pet level after an upgrade at Kats"
+ )
+ @ConfigEditorBoolean
+ public boolean showKatSitting = true;
}
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 3711f1e5..f09883eb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -830,6 +830,10 @@ public class Utils {
GlStateManager.scale(1 / factor, 1 / factor, 1);
}
+ public static void drawStringRightAligned(String str, FontRenderer fr, float x, float y , boolean shadow, int colour, float factor) {
+ drawStringScaled(str, fr, x - fr.getStringWidth(str) * factor, y, shadow, colour, factor);
+ }
+
public static void drawStringScaledMax(String str, FontRenderer fr, float x, float y, boolean shadow, int colour, float factor, int len) {
int strLen = fr.getStringWidth(str);
float f = len / (float) strLen;
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 cac4cf74..d1bed30e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
@@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.util;
import com.google.common.base.Splitter;
import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
@@ -13,6 +14,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
public class XPInformation {
private static final XPInformation INSTANCE = new XPInformation();
@@ -208,4 +212,24 @@ public class XPInformation {
skillInfoMap.put(skill.toLowerCase(), info);
}
}
+
+ public double getPetLevel(String petId, double exp, String rarity) {
+ Stream<JsonElement> pet_levels = StreamSupport.stream(Constants.PETS.get("pet_levels").getAsJsonArray().spliterator(), false);
+ int pet_rarity_offset = Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity).getAsInt();
+ JsonObject custom_pet_leveling = Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(petId);
+ List<Integer> xpLevelsRequired = pet_levels.skip(pet_rarity_offset).limit(100).map(JsonElement::getAsInt).collect(Collectors.toList());
+ if (custom_pet_leveling != null && custom_pet_leveling.get("type").getAsInt() == 1)
+ xpLevelsRequired.addAll(StreamSupport.stream(custom_pet_leveling.getAsJsonArray("pet_levels").spliterator(), false).map(JsonElement::getAsInt).collect(Collectors.toList()));
+ double remainingExp = exp;
+ for (int i = 0; i < xpLevelsRequired.size(); i++) {
+ int xpForCurrentLevel = xpLevelsRequired.get(i);
+ if (remainingExp >= xpForCurrentLevel) {
+ remainingExp -= xpForCurrentLevel;
+ } else {
+ return i + 1 + remainingExp / xpForCurrentLevel;
+ }
+ }
+ return xpLevelsRequired.size();
+ }
+
}