diff options
Diffstat (limited to 'src')
5 files changed, 135 insertions, 23 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index cb6a38ab..4fdddffc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -2398,9 +2398,9 @@ public class NEUEventListener { tag.getCompoundTag("ExtraAttributes").getString("petInfo"), JsonObject.class); if (petInfo.has("exp") && petInfo.get("exp").isJsonPrimitive()) { JsonPrimitive exp = petInfo.getAsJsonPrimitive("exp"); - int rarityOffset = Constants.PETS.get("pet_rarity_offset").getAsJsonObject().get( + String petName = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt(); - petlevel = GuiProfileViewer.getPetLevel(Constants.PETS.get("pet_levels").getAsJsonArray(), rarityOffset, exp.getAsLong()); + petlevel = GuiProfileViewer.getPetLevel(petName, Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip)), exp.getAsLong()); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 80fc0667..5fef4c62 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -1208,10 +1208,17 @@ public class NEUManager { HashMap<String, String> replacements = new HashMap<>(); if(level < 1) { - replacements.put("LVL", "1\u27A1100"); + if (Constants.PETS.has("custom_pet_leveling") && Constants.PETS.getAsJsonObject("custom_pet_leveling").has(petname) && Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(petname).has("max_level")){ + int maxLvl = Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(petname).get("max_level").getAsInt(); + replacements.put("LVL", "1\u27A1"+maxLvl); + } else { + replacements.put("LVL", "1\u27A1100"); + } } else { replacements.put("LVL", ""+level); } + + if(petnums != null) { if(petnums.has(petname)) { JsonObject petInfo = petnums.get(petname).getAsJsonObject(); @@ -1227,8 +1234,18 @@ public class NEUManager { if(level < 1) { JsonArray otherNumsMin = min.get("otherNums").getAsJsonArray(); JsonArray otherNumsMax = max.get("otherNums").getAsJsonArray(); + boolean addZero = false; + if(petInfoTier.has("stats_levelling_curve")){ + String[] stringArray = petInfoTier.get("stats_levelling_curve").getAsString().split(":"); + if(stringArray.length == 3) { + int type = Integer.parseInt(stringArray[2]); + if(type == 1){ + addZero = true; + } + } + } for(int i=0; i<otherNumsMax.size(); i++) { - replacements.put(""+i, removeUnusedDecimal(Math.floor(otherNumsMin.get(i).getAsFloat()*10)/10f)+ + replacements.put(""+i, (addZero?"0\u27A1":"")+removeUnusedDecimal(Math.floor(otherNumsMin.get(i).getAsFloat()*10)/10f)+ "\u27A1"+removeUnusedDecimal(Math.floor(otherNumsMax.get(i).getAsFloat()*10)/10f)); } @@ -1236,25 +1253,64 @@ public class NEUManager { int statMax = (int)Math.floor(entry.getValue().getAsFloat()); int statMin = (int)Math.floor(min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat()); String statStr = (statMin>0?"+":"")+statMin+"\u27A1"+statMax; + statStr = (addZero?"0\u27A1":"")+statStr; replacements.put(entry.getKey(), statStr); } } else { - float minMix = (100-level)/99f; - float maxMix = (level-1)/99f; + + int minStatsLevel = 0; + int maxStatsLevel = 100; + int statsLevelingType = -1; + + int statsLevel = level; + + + if(petInfoTier.has("stats_levelling_curve")) { + String[] stringArray = petInfoTier.get("stats_levelling_curve").getAsString().split(":"); + if (stringArray.length == 3) { + minStatsLevel = Integer.parseInt(stringArray[0]); + maxStatsLevel = Integer.parseInt(stringArray[1]); + statsLevelingType = Integer.parseInt(stringArray[2]); + switch (statsLevelingType) { + //Case for maybe a pet that might exist + case 0: + case 1: + if (level < minStatsLevel) { + statsLevel = 1; + } else if (level < maxStatsLevel) { + statsLevel = level - minStatsLevel + 1; + } else { + statsLevel = maxStatsLevel - minStatsLevel + 1; + } + break; + + } + } + } + float minMix = (maxStatsLevel-(minStatsLevel-(statsLevelingType==-1?0:1))-statsLevel)/99f; + float maxMix = (statsLevel-1)/99f; JsonArray otherNumsMin = min.get("otherNums").getAsJsonArray(); JsonArray otherNumsMax = max.get("otherNums").getAsJsonArray(); for(int i=0; i<otherNumsMax.size(); i++) { float val = otherNumsMin.get(i).getAsFloat()*minMix + otherNumsMax.get(i).getAsFloat()*maxMix; - replacements.put(""+i, removeUnusedDecimal(Math.floor(val*10)/10f)); + if(statsLevelingType == 1 && level < minStatsLevel){ + replacements.put("" + i, "0"); + } else { + replacements.put("" + i, removeUnusedDecimal(Math.floor(val * 10) / 10f)); + } } for(Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) { - float statMax = entry.getValue().getAsFloat(); - float statMin = min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat(); - float val = statMin*minMix + statMax*maxMix; - String statStr = (statMin>0?"+":"")+(int)Math.floor(val); - replacements.put(entry.getKey(), statStr); + if(statsLevelingType == 1 && level < minStatsLevel) { + replacements.put(entry.getKey(), "0"); + } else { + float statMax = entry.getValue().getAsFloat(); + float statMin = min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat(); + float val = statMin * minMix + statMax * maxMix; + String statStr = (statMin > 0 ? "+" : "") + (int) Math.floor(val); + replacements.put(entry.getKey(), statStr); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index 7769c274..5313afd9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -1018,7 +1018,7 @@ public class PetInfoOverlay extends TextOverlay { JsonObject petsJson = Constants.PETS; if(currentPet != null && petsJson != null) { - currentPet.petLevel = GuiProfileViewer.getPetLevel(petsJson.get("pet_levels").getAsJsonArray(), currentPet.rarity.petOffset, currentPet.petLevel.totalXp); + currentPet.petLevel = GuiProfileViewer.getPetLevel(currentPet.petItem, currentPet.rarity.name(), currentPet.petLevel.totalXp); } } 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 3c448cda..a45524ba 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -1209,7 +1209,65 @@ public class GuiProfileViewer extends GuiScreen { public float totalXp; } - public static PetLevel getPetLevel(JsonArray levels, int offset, float exp) { + private static JsonObject getPetInfo(String pet_name, String rarity){ + JsonObject petInfo = new JsonObject(); + //System.out.println(pet_name); + //System.out.println(rarity); + + if(Constants.PETS.has("custom_pet_leveling") && Constants.PETS.getAsJsonObject("custom_pet_leveling").has(pet_name)){ + JsonObject pet = Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(pet_name); + if(pet.has("type") && pet.has("pet_levels")){ + int type = pet.get("type").getAsInt(); + switch (type) { + case 1: + JsonArray defaultLevels = Constants.PETS.getAsJsonArray("pet_levels"); + defaultLevels.addAll(pet.getAsJsonArray("pet_levels")); + petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels")); + break; + case 2: + petInfo.add("pet_levels", pet.getAsJsonArray("pet_levels")); + break; + default: + petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels")); + break; + } + } else { + petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels")); + } + if(pet.has("max_level")){ + petInfo.add("max_level", pet.get("max_level")); + } else { + petInfo.add("max_level", new JsonPrimitive(100)); + } + + if(pet.has("pet_rarity_offset")){ + petInfo.add("offset", pet.get("pet_rarity_offset")); + } else { + petInfo.add("offset", Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity)); + } + + } else { + //System.out.println("Default Path"); + petInfo.add("offset", Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity)); + petInfo.add("max_level", new JsonPrimitive(100)); + petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels")); + } + + + return petInfo; + + } + + public static PetLevel getPetLevel(String pet_name, String rarity, float exp) { + + JsonObject petInfo = getPetInfo(pet_name, rarity); + int offset = petInfo.get("offset").getAsInt(); + int maxPetLevel = petInfo.get("max_level").getAsInt(); + JsonArray levels = petInfo.getAsJsonArray("pet_levels"); + System.out.println("Offset: "+offset); + System.out.println("MaxPetLevel: "+maxPetLevel); + + float xpTotal = 0; float level = 1; float currentLevelRequirement = 0; @@ -1217,7 +1275,7 @@ public class GuiProfileViewer extends GuiScreen { boolean addLevel = true; - for(int i=offset; i<offset+99; i++) { + for(int i=offset; i<offset+maxPetLevel-1; i++) { if(addLevel) { currentLevelRequirement = levels.get(i).getAsFloat(); xpTotal += currentLevelRequirement; @@ -1228,15 +1286,17 @@ public class GuiProfileViewer extends GuiScreen { level += 1; } } else { + xpTotal += levels.get(i).getAsFloat(); + } } level += currentLevelProgress/currentLevelRequirement; if(level <= 0) { level = 1; - } else if(level > 100) { - level = 100; + } else if(level > maxPetLevel) { + level = maxPetLevel; } PetLevel levelObj = new PetLevel(); levelObj.level = level; @@ -1355,10 +1415,8 @@ public class GuiProfileViewer extends GuiScreen { tierNum = ""+(Integer.parseInt(tierNum)+1); } - int petRarityOffset = petsJson.get("pet_rarity_offset").getAsJsonObject().get(tier).getAsInt(); - JsonArray levelsArr = petsJson.get("pet_levels").getAsJsonArray(); + PetLevel levelObj = GuiProfileViewer.getPetLevel(petname, tier, exp); - PetLevel levelObj = getPetLevel(levelsArr, petRarityOffset, exp); float level = levelObj.level; float currentLevelRequirement = levelObj.currentLevelRequirement; float maxXP = levelObj.maxXP; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java index c95fadf0..76427cc8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java @@ -471,10 +471,8 @@ public class PlayerStats { tierNum = ""+(Integer.parseInt(tierNum)+1); } - int petRarityOffset = petsJson.get("pet_rarity_offset").getAsJsonObject().get(tier).getAsInt(); - JsonArray levelsArr = petsJson.get("pet_levels").getAsJsonArray(); + GuiProfileViewer.PetLevel levelObj = GuiProfileViewer.getPetLevel(petname, tier, exp); - GuiProfileViewer.PetLevel levelObj = GuiProfileViewer.getPetLevel(levelsArr, petRarityOffset, exp); float level = levelObj.level; float currentLevelRequirement = levelObj.currentLevelRequirement; float maxXP = levelObj.maxXP; |