19
19
20
20
package io .github .moulberry .notenoughupdates .miscfeatures ;
21
21
22
- import com .google .common .collect .Lists ;
23
22
import com .google .gson .Gson ;
24
23
import com .google .gson .GsonBuilder ;
24
+ import com .google .gson .JsonArray ;
25
+ import com .google .gson .JsonElement ;
25
26
import com .google .gson .JsonNull ;
26
27
import com .google .gson .JsonObject ;
27
28
import com .google .gson .JsonParser ;
33
34
import io .github .moulberry .notenoughupdates .events .SlotClickEvent ;
34
35
import io .github .moulberry .notenoughupdates .listener .RenderListener ;
35
36
import io .github .moulberry .notenoughupdates .miscfeatures .tablisttutorial .TablistAPI ;
37
+ import io .github .moulberry .notenoughupdates .miscgui .itemcustomization .ItemCustomizeManager ;
36
38
import io .github .moulberry .notenoughupdates .options .NEUConfig ;
37
39
import io .github .moulberry .notenoughupdates .overlays .TextOverlay ;
38
40
import io .github .moulberry .notenoughupdates .overlays .TextOverlayStyle ;
39
41
import io .github .moulberry .notenoughupdates .util .Constants ;
40
42
import io .github .moulberry .notenoughupdates .util .ItemResolutionQuery ;
41
43
import io .github .moulberry .notenoughupdates .util .PetLeveling ;
42
44
import io .github .moulberry .notenoughupdates .util .SBInfo ;
45
+ import io .github .moulberry .notenoughupdates .util .SkyBlockTime ;
43
46
import io .github .moulberry .notenoughupdates .util .Utils ;
44
47
import net .minecraft .client .Minecraft ;
45
48
import net .minecraft .client .gui .inventory .GuiChest ;
@@ -283,6 +286,7 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
283
286
String heldItem = null ;
284
287
PetLeveling .PetLevel level = null ;
285
288
String skin = null ;
289
+ int skinVariantSelected = -1 ;
286
290
287
291
if (tag != null && tag .hasKey ("ExtraAttributes" )) {
288
292
NBTTagCompound ea = tag .getCompoundTag ("ExtraAttributes" );
@@ -295,7 +299,9 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
295
299
}
296
300
297
301
if ("PET_ITEM_TIER_BOOST" .equals (heldItem )) {
298
- rarity = rarity .nextRarity ();
302
+ if (rarity != Rarity .MYTHIC ) {
303
+ rarity = rarity .nextRarity ();
304
+ }
299
305
}
300
306
301
307
// Should only default if from item list and repo missing exp: 0
@@ -304,6 +310,13 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
304
310
if (petInfo .has ("skin" )) {
305
311
skin = "PET_SKIN_" + petInfo .get ("skin" ).getAsString ();
306
312
}
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
+ }
307
320
}
308
321
}
309
322
@@ -323,6 +336,7 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
323
336
.getAsString ()
324
337
.toLowerCase (Locale .ROOT ) : "unknown" ;
325
338
pet .skin = skin ;
339
+ pet .skinVariantSelected = skinVariantSelected ;
326
340
327
341
return pet ;
328
342
}
@@ -383,6 +397,15 @@ private List<String> createStringsForPet(Pet currentPet, boolean secondPet) {
383
397
EnumChatFormatting .GREEN + "[Lvl " + currentPet .petLevel .getCurrentLevel () + "] " +
384
398
currentPet .rarity .chatFormatting +
385
399
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
+ }
386
409
387
410
float levelPercent = getLevelPercent (currentPet );
388
411
String lvlStringShort = null ;
@@ -477,11 +500,12 @@ private List<String> createStringsForPet(Pet currentPet, boolean secondPet) {
477
500
String finalPetItemStr = petItemStr ;
478
501
String finalLvlString = lvlString ;
479
502
String finalLvlStringShort = lvlStringShort ;
503
+ String finalPetName = petName ;
480
504
return new ArrayList <String >() {{
481
505
for (int index : NotEnoughUpdates .INSTANCE .config .petOverlay .petOverlayText ) {
482
506
switch (index ) {
483
507
case 0 :
484
- add (petName );
508
+ add (finalPetName );
485
509
break ;
486
510
case 1 :
487
511
if (finalLvlStringShort != null ) add (finalLvlStringShort );
@@ -595,6 +619,7 @@ public void render() {
595
619
int y = (int ) position .y ;
596
620
597
621
ItemStack stack = NotEnoughUpdates .INSTANCE .manager .jsonToStack (petItem );
622
+ getAnimatedSkin (stack , currentPet );
598
623
GlStateManager .enableDepth ();
599
624
GlStateManager .pushMatrix ();
600
625
Utils .pushGuiScale (NotEnoughUpdates .INSTANCE .config .locationedit .guiScale );
@@ -619,6 +644,7 @@ public void render() {
619
644
int y = (int ) position .y + (overlayStrings .size () - secondPetLines ) * 10 ;
620
645
621
646
ItemStack stack = NotEnoughUpdates .INSTANCE .manager .jsonToStack (petItem2 );
647
+ getAnimatedSkin (stack , currentPet2 );
622
648
GlStateManager .enableDepth ();
623
649
GlStateManager .pushMatrix ();
624
650
Utils .pushGuiScale (NotEnoughUpdates .INSTANCE .config .locationedit .guiScale );
@@ -703,36 +729,41 @@ public void render() {
703
729
}
704
730
}
705
731
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
+ }
723
764
}
724
765
}
725
766
726
- private static List <String > validXpTypes = Lists .newArrayList (
727
- "mining" ,
728
- "foraging" ,
729
- "enchanting" ,
730
- "farming" ,
731
- "combat" ,
732
- "fishing" ,
733
- "alchemy"
734
- );
735
-
736
767
@ SubscribeEvent
737
768
public void onStackClick (SlotClickEvent event ) {
738
769
// 0 through 8 are the mouse as well as the keyboard buttons, allow all of those
@@ -964,8 +995,7 @@ public void updatePetLevels() {
964
995
for (int i = 0 ; i < widgetLines .size (); i ++) {
965
996
String line = widgetLines .get (i );
966
997
String lineWithColours = line .replace ("§r" , "" ).trim ();
967
- line = Utils .cleanColour (line ).trim ().replace ("," , "" );
968
-
998
+ line = Utils .cleanColour (line ).replace ("," , "" ).replace ("✦" , "" ).trim ();
969
999
Matcher normalXPMatcher = TAB_LIST_XP .matcher (line );
970
1000
Matcher overflowXPMatcher = TAB_LIST_XP_OVERFLOW .matcher (line );
971
1001
@@ -982,7 +1012,7 @@ public void updatePetLevels() {
982
1012
}
983
1013
984
1014
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 ) {
986
1016
int rarity = getRarityByColor (petNameMatcher .group (2 )).petId ;
987
1017
String petItem = "" ;
988
1018
if (widgetLines .size () > i ) {
@@ -999,10 +1029,14 @@ public void updatePetLevels() {
999
1029
internalName = split [0 ];
1000
1030
}
1001
1031
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
+ }
1006
1040
}
1007
1041
lastPetCorrect = System .currentTimeMillis ();
1008
1042
}
@@ -1105,6 +1139,7 @@ public static class Pet {
1105
1139
public String petXpType ;
1106
1140
public String petItem ;
1107
1141
public String skin ;
1142
+ public int skinVariantSelected ;
1108
1143
public int candyUsed ;
1109
1144
1110
1145
public String getPetId (boolean withoutBoost ) {
0 commit comments