Skip to content

Commit f12d7c9

Browse files
authored
Merge branch 'master' into numbering
2 parents 98bf872 + 4af047d commit f12d7c9

File tree

2 files changed

+89
-41
lines changed

2 files changed

+89
-41
lines changed

src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java

Lines changed: 72 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
package io.github.moulberry.notenoughupdates.miscfeatures;
2121

22-
import com.google.common.collect.Lists;
2322
import com.google.gson.Gson;
2423
import com.google.gson.GsonBuilder;
24+
import com.google.gson.JsonArray;
25+
import com.google.gson.JsonElement;
2526
import com.google.gson.JsonNull;
2627
import com.google.gson.JsonObject;
2728
import com.google.gson.JsonParser;
@@ -33,13 +34,15 @@
3334
import io.github.moulberry.notenoughupdates.events.SlotClickEvent;
3435
import io.github.moulberry.notenoughupdates.listener.RenderListener;
3536
import io.github.moulberry.notenoughupdates.miscfeatures.tablisttutorial.TablistAPI;
37+
import io.github.moulberry.notenoughupdates.miscgui.itemcustomization.ItemCustomizeManager;
3638
import io.github.moulberry.notenoughupdates.options.NEUConfig;
3739
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
3840
import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle;
3941
import io.github.moulberry.notenoughupdates.util.Constants;
4042
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery;
4143
import io.github.moulberry.notenoughupdates.util.PetLeveling;
4244
import io.github.moulberry.notenoughupdates.util.SBInfo;
45+
import io.github.moulberry.notenoughupdates.util.SkyBlockTime;
4346
import io.github.moulberry.notenoughupdates.util.Utils;
4447
import net.minecraft.client.Minecraft;
4548
import net.minecraft.client.gui.inventory.GuiChest;
@@ -283,6 +286,7 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
283286
String heldItem = null;
284287
PetLeveling.PetLevel level = null;
285288
String skin = null;
289+
int skinVariantSelected = -1;
286290

287291
if (tag != null && tag.hasKey("ExtraAttributes")) {
288292
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
@@ -295,7 +299,9 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
295299
}
296300

297301
if ("PET_ITEM_TIER_BOOST".equals(heldItem)) {
298-
rarity = rarity.nextRarity();
302+
if (rarity != Rarity.MYTHIC) {
303+
rarity = rarity.nextRarity();
304+
}
299305
}
300306

301307
// Should only default if from item list and repo missing exp: 0
@@ -304,6 +310,13 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
304310
if (petInfo.has("skin")) {
305311
skin = "PET_SKIN_" + petInfo.get("skin").getAsString();
306312
}
313+
// rn only golden dragon has selectable pet skins
314+
if (petInfo.has("extraData")) {
315+
JsonObject extraData = petInfo.get("extraData").getAsJsonObject();
316+
if (petInfo.has("favorite_ancient_gdrag")) {
317+
skinVariantSelected = extraData.get("favorite_ancient_gdrag").getAsInt();
318+
}
319+
}
307320
}
308321
}
309322

@@ -323,6 +336,7 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
323336
.getAsString()
324337
.toLowerCase(Locale.ROOT) : "unknown";
325338
pet.skin = skin;
339+
pet.skinVariantSelected = skinVariantSelected;
326340

327341
return pet;
328342
}
@@ -383,6 +397,15 @@ private List<String> createStringsForPet(Pet currentPet, boolean secondPet) {
383397
EnumChatFormatting.GREEN + "[Lvl " + currentPet.petLevel.getCurrentLevel() + "] " +
384398
currentPet.rarity.chatFormatting +
385399
getPetNameFromId(currentPet.petType, currentPet.petLevel.getCurrentLevel());
400+
if (currentPet.skin != null) {
401+
JsonObject skinJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet.skin);
402+
if (skinJson != null) {
403+
String displayName = NotEnoughUpdates.INSTANCE.manager.jsonToStack(skinJson).getDisplayName();
404+
String colourSt = Character.toString(Utils.getPrimaryColourCode(displayName));
405+
EnumChatFormatting rarity = getRarityByColor(colourSt).chatFormatting;
406+
petName += rarity + " ✦";
407+
}
408+
}
386409

387410
float levelPercent = getLevelPercent(currentPet);
388411
String lvlStringShort = null;
@@ -477,11 +500,12 @@ private List<String> createStringsForPet(Pet currentPet, boolean secondPet) {
477500
String finalPetItemStr = petItemStr;
478501
String finalLvlString = lvlString;
479502
String finalLvlStringShort = lvlStringShort;
503+
String finalPetName = petName;
480504
return new ArrayList<String>() {{
481505
for (int index : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) {
482506
switch (index) {
483507
case 0:
484-
add(petName);
508+
add(finalPetName);
485509
break;
486510
case 1:
487511
if (finalLvlStringShort != null) add(finalLvlStringShort);
@@ -595,6 +619,7 @@ public void render() {
595619
int y = (int) position.y;
596620

597621
ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem);
622+
getAnimatedSkin(stack, currentPet);
598623
GlStateManager.enableDepth();
599624
GlStateManager.pushMatrix();
600625
Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale);
@@ -619,6 +644,7 @@ public void render() {
619644
int y = (int) position.y + (overlayStrings.size() - secondPetLines) * 10;
620645

621646
ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem2);
647+
getAnimatedSkin(stack, currentPet2);
622648
GlStateManager.enableDepth();
623649
GlStateManager.pushMatrix();
624650
Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale);
@@ -703,36 +729,41 @@ public void render() {
703729
}
704730
}
705731

706-
public static float getBoostMultiplier(String boostName) {
707-
if (boostName == null) return 1;
708-
boostName = boostName.toLowerCase(Locale.ROOT);
709-
if (boostName.equalsIgnoreCase("PET_ITEM_ALL_SKILLS_BOOST_COMMON")) {
710-
return 1.1f;
711-
} else if (boostName.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
712-
return 1.2f;
713-
} else if (boostName.endsWith("epic")) {
714-
return 1.5f;
715-
} else if (boostName.endsWith("rare")) {
716-
return 1.4f;
717-
} else if (boostName.endsWith("uncommon")) {
718-
return 1.3f;
719-
} else if (boostName.endsWith("common")) {
720-
return 1.2f;
721-
} else {
722-
return 1;
732+
private void getAnimatedSkin(ItemStack stack, Pet currentPet) {
733+
NBTTagCompound tagCompound = stack.getTagCompound();
734+
if (tagCompound != null) {
735+
String skin = currentPet.skin;
736+
if (currentPet.skinVariantSelected >= 0) {
737+
JsonObject animatedSkulls = Constants.ANIMATEDSKULLS;
738+
if (animatedSkulls == null) return;
739+
if (!animatedSkulls.has("pet_skin_variant")) return;
740+
JsonElement pet_skin_variant = animatedSkulls.get("pet_skin_variant");
741+
if (!pet_skin_variant.getAsJsonObject().has(skin)) return;
742+
JsonArray skinsArray = pet_skin_variant.getAsJsonObject().get(skin).getAsJsonArray();
743+
if (skinsArray.size() <= currentPet.skinVariantSelected) return;
744+
skin = skinsArray.get(currentPet.skinVariantSelected).getAsString();
745+
}
746+
if ("PET_SKIN_FOUR_SEASONS_GRIFFIN".equals(skin)) {
747+
String monthName = SkyBlockTime.now().getMonthName();
748+
if (monthName.contains("Spring")) {
749+
skin = "PET_SKIN_FOUR_SEASONS_GRIFFIN_SPRING";
750+
} else if (monthName.contains("Summer")) {
751+
skin = "PET_SKIN_FOUR_SEASONS_GRIFFIN_SUMMER";
752+
} else if (monthName.contains("Autumn")) {
753+
skin = "PET_SKIN_FOUR_SEASONS_GRIFFIN_AUTUMN";
754+
} else if (monthName.contains("Winter")) {
755+
skin = "PET_SKIN_FOUR_SEASONS_GRIFFIN_WINTER";
756+
}
757+
758+
}
759+
NBTTagCompound customSkull = ItemCustomizeManager.getAnimatedCustomSkull(skin, "");
760+
if (customSkull != null) {
761+
tagCompound.removeTag("SkullOwner");
762+
tagCompound.setTag("SkullOwner", customSkull);
763+
}
723764
}
724765
}
725766

726-
private static List<String> validXpTypes = Lists.newArrayList(
727-
"mining",
728-
"foraging",
729-
"enchanting",
730-
"farming",
731-
"combat",
732-
"fishing",
733-
"alchemy"
734-
);
735-
736767
@SubscribeEvent
737768
public void onStackClick(SlotClickEvent event) {
738769
// 0 through 8 are the mouse as well as the keyboard buttons, allow all of those
@@ -964,8 +995,7 @@ public void updatePetLevels() {
964995
for (int i = 0; i < widgetLines.size(); i++) {
965996
String line = widgetLines.get(i);
966997
String lineWithColours = line.replace("§r", "").trim();
967-
line = Utils.cleanColour(line).trim().replace(",", "");
968-
998+
line = Utils.cleanColour(line).replace(",", "").replace("✦", "").trim();
969999
Matcher normalXPMatcher = TAB_LIST_XP.matcher(line);
9701000
Matcher overflowXPMatcher = TAB_LIST_XP_OVERFLOW.matcher(line);
9711001

@@ -982,7 +1012,7 @@ public void updatePetLevels() {
9821012
}
9831013

9841014
if (!getPetNameFromId(currentPet.petType, currentPet.petLevel.getCurrentLevel()).equalsIgnoreCase(petName)) {
985-
if (lastPetCorrect == -1 || lastPetCorrect > 0 && System.currentTimeMillis() - lastPetCorrect > 5000) {
1015+
if (lastPetCorrect == -1 || lastPetCorrect > 0 && System.currentTimeMillis() - lastPetCorrect > 6000) {
9861016
int rarity = getRarityByColor(petNameMatcher.group(2)).petId;
9871017
String petItem = "";
9881018
if (widgetLines.size() > i) {
@@ -999,10 +1029,14 @@ public void updatePetLevels() {
9991029
internalName = split[0];
10001030
}
10011031

1002-
int closestPetIndex = getClosestPetIndex(internalName, rarity, petItem, petLevel);
1003-
if (closestPetIndex != -1) {
1004-
//If it is -1 your petcache is probably outdated and you need to open /pets, but im sure they can work it out
1005-
setCurrentPet(closestPetIndex);
1032+
if ((currentPet.petItem != null && !currentPet.petItem.equals(petItem)) || currentPet.rarity.petId != rarity ||
1033+
currentPet.petLevel.getCurrentLevel() != petLevel) {
1034+
int closestPetIndex = getClosestPetIndex(internalName, rarity, petItem, petLevel);
1035+
1036+
if (closestPetIndex != -1 && closestPetIndex != config.selectedPet) {
1037+
//If it is -1 your petcache is probably outdated and you need to open /pets, but im sure they can work it out
1038+
setCurrentPet(closestPetIndex);
1039+
}
10061040
}
10071041
lastPetCorrect = System.currentTimeMillis();
10081042
}
@@ -1105,6 +1139,7 @@ public static class Pet {
11051139
public String petXpType;
11061140
public String petItem;
11071141
public String skin;
1142+
public int skinVariantSelected;
11081143
public int candyUsed;
11091144

11101145
public String getPetId(boolean withoutBoost) {

src/main/java/io/github/moulberry/notenoughupdates/miscgui/itemcustomization/ItemCustomizeManager.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,17 +516,30 @@ public static NBTTagCompound getAnimatedCustomSkull(String itemID, String textur
516516

517517
if (customSkulls.containsKey(itemID)) {
518518
AnimatedSkull animatedSkull = customSkulls.get(itemID);
519+
if (animatedSkull == null) return null;
519520
int ticks = animatedSkull.ticks;
520521
int animatedIndex = ItemCustomizationUtils.getTicksForList(ticks, animatedSkull.skullOwners.size(), presetIndex);
521522
return animatedSkull.skullOwners.get(animatedIndex);
522523
}
523524

524525
JsonObject animatedSkulls = Constants.ANIMATEDSKULLS;
525-
if (animatedSkulls == null) return null;
526-
if (!animatedSkulls.has("skins")) return null;
527-
if (!animatedSkulls.get("skins").getAsJsonObject().has(itemID)) return null;
526+
if (animatedSkulls == null) {
527+
customSkulls.put(itemID, null);
528+
return null;
529+
}
530+
if (!animatedSkulls.has("skins")) {
531+
customSkulls.put(itemID, null);
532+
return null;
533+
}
534+
if (!animatedSkulls.get("skins").getAsJsonObject().has(itemID)) {
535+
customSkulls.put(itemID, null);
536+
return null;
537+
}
528538
JsonObject skin = animatedSkulls.get("skins").getAsJsonObject().get(itemID).getAsJsonObject();
529-
if (!skin.has("textures")) return null;
539+
if (!skin.has("textures")) {
540+
customSkulls.put(itemID, null);
541+
return null;
542+
}
530543
JsonArray skullTextures = skin.get("textures").getAsJsonArray();
531544

532545
int ticks = skin.get("ticks").getAsInt();

0 commit comments

Comments
 (0)