Skip to content

Commit

Permalink
Fix missing repo crash in PetInvOverlay (Moulberry#305)
Browse files Browse the repository at this point in the history
* Fix missing repo crash in PetInvOverlay

* Add 2.1.md to *not* *satisfy* erymanthus (*not* RayDeezNuts)
  • Loading branch information
nea89o authored Sep 24, 2022
1 parent 9a0db02 commit 1e71e3e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions Update Notes/2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- Added carpentry skill to skill average - hannibal2
- Fixed sort order of fishing rods in profile viewer page - hannibal2
- Changing sort logic from strength plus damage to bin price for best weapons in pv inventory page - hannibal2
- Added pronouns to /pv - nea89

### **Minor Changes:**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ public String removeUnusedDecimal(double num) {
}
}

public HashMap<String, String> getLoreReplacements(String petname, String tier, int level) {
public HashMap<String, String> getPetLoreReplacements(String petname, String tier, int level) {
JsonObject petnums = null;
if (petname != null && tier != null) {
petnums = Constants.PETNUMS;
Expand Down Expand Up @@ -1392,7 +1392,7 @@ public HashMap<String, String> getLoreReplacements(String petname, String tier,
return replacements;
}

public HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level) {
public HashMap<String, String> getPetLoreReplacements(NBTTagCompound tag, int level) {
String petname = null;
String tier = null;
if (tag != null && tag.hasKey("ExtraAttributes")) {
Expand Down Expand Up @@ -1426,7 +1426,7 @@ public HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level
}
}
}
return getLoreReplacements(petname, tier, level);
return getPetLoreReplacements(petname, tier, level);
}

public NBTTagList processLore(JsonArray lore, HashMap<String, String> replacements) {
Expand Down Expand Up @@ -1497,7 +1497,7 @@ public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useRepla
HashMap<String, String> replacements = new HashMap<>();

if (useReplacements) {
replacements = getLoreReplacements(stack.getTagCompound(), -1);
replacements = getPetLoreReplacements(stack.getTagCompound(), -1);

String displayName = json.get("displayname").getAsString();
for (Map.Entry<String, String> entry : replacements.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private void updateGuiInfo(GuiScreen screen) {
slot4 = getWardrobeSlot(37);
}

if (screen instanceof GuiChest || screen instanceof GuiInventory) {
if ((screen instanceof GuiChest || screen instanceof GuiInventory) && NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay){
petStack = getRepoPetStack();
}
if ((!(screen instanceof GuiInventory) && !(screen instanceof GuiInvButtonEditor))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ public static String applyReplacements(Map<String, String> replacements, String
}

public static ItemStack createPetItemstackFromPetInfo(PetInfoOverlay.Pet currentPet) {
JsonObject pet = NotEnoughUpdates.INSTANCE.manager.getJsonForItem(NotEnoughUpdates.INSTANCE.manager.createItem(
currentPet.getPetId(false)));
String petname = currentPet.petType;
String tier = Utils.getRarityFromInt(currentPet.rarity.petId).toUpperCase();
String heldItem = currentPet.petItem;
Expand All @@ -187,11 +185,6 @@ public static ItemStack createPetItemstackFromPetInfo(PetInfoOverlay.Pet current
GuiProfileViewer.PetLevel levelObj = GuiProfileViewer.getPetLevel(petname, tier, exp);

float level = levelObj.level;
float currentLevelRequirement = levelObj.currentLevelRequirement;
float maxXP = levelObj.maxXP;
pet.addProperty("level", level);
pet.addProperty("currentLevelRequirement", currentLevelRequirement);
pet.addProperty("maxXP", maxXP);

ItemStack petItemstack = NotEnoughUpdates.INSTANCE.manager
.createItemResolutionQuery()
Expand All @@ -206,7 +199,7 @@ public static ItemStack createPetItemstackFromPetInfo(PetInfoOverlay.Pet current
"§c§l#neu-support §r§con §ldiscord.gg/moulberry"
));
}
Map<String, String> replacements = NotEnoughUpdates.INSTANCE.manager.getLoreReplacements(
Map<String, String> replacements = NotEnoughUpdates.INSTANCE.manager.getPetLoreReplacements(
petname,
tier,
MathHelper.floor_float(level)
Expand Down

0 comments on commit 1e71e3e

Please sign in to comment.