Skip to content

Commit

Permalink
Merge branch 'master' into numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs authored Dec 11, 2024
2 parents 98bf872 + 4af047d commit f12d7c9
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

package io.github.moulberry.notenoughupdates.miscfeatures;

import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand All @@ -33,13 +34,15 @@
import io.github.moulberry.notenoughupdates.events.SlotClickEvent;
import io.github.moulberry.notenoughupdates.listener.RenderListener;
import io.github.moulberry.notenoughupdates.miscfeatures.tablisttutorial.TablistAPI;
import io.github.moulberry.notenoughupdates.miscgui.itemcustomization.ItemCustomizeManager;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery;
import io.github.moulberry.notenoughupdates.util.PetLeveling;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.SkyBlockTime;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiChest;
Expand Down Expand Up @@ -283,6 +286,7 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
String heldItem = null;
PetLeveling.PetLevel level = null;
String skin = null;
int skinVariantSelected = -1;

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

if ("PET_ITEM_TIER_BOOST".equals(heldItem)) {
rarity = rarity.nextRarity();
if (rarity != Rarity.MYTHIC) {
rarity = rarity.nextRarity();
}
}

// Should only default if from item list and repo missing exp: 0
Expand All @@ -304,6 +310,13 @@ public static Pet getPetFromStack(NBTTagCompound tag) {
if (petInfo.has("skin")) {
skin = "PET_SKIN_" + petInfo.get("skin").getAsString();
}
// rn only golden dragon has selectable pet skins
if (petInfo.has("extraData")) {
JsonObject extraData = petInfo.get("extraData").getAsJsonObject();
if (petInfo.has("favorite_ancient_gdrag")) {
skinVariantSelected = extraData.get("favorite_ancient_gdrag").getAsInt();
}
}
}
}

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

return pet;
}
Expand Down Expand Up @@ -383,6 +397,15 @@ private List<String> createStringsForPet(Pet currentPet, boolean secondPet) {
EnumChatFormatting.GREEN + "[Lvl " + currentPet.petLevel.getCurrentLevel() + "] " +
currentPet.rarity.chatFormatting +
getPetNameFromId(currentPet.petType, currentPet.petLevel.getCurrentLevel());
if (currentPet.skin != null) {
JsonObject skinJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet.skin);
if (skinJson != null) {
String displayName = NotEnoughUpdates.INSTANCE.manager.jsonToStack(skinJson).getDisplayName();
String colourSt = Character.toString(Utils.getPrimaryColourCode(displayName));
EnumChatFormatting rarity = getRarityByColor(colourSt).chatFormatting;
petName += rarity + " ✦";
}
}

float levelPercent = getLevelPercent(currentPet);
String lvlStringShort = null;
Expand Down Expand Up @@ -477,11 +500,12 @@ private List<String> createStringsForPet(Pet currentPet, boolean secondPet) {
String finalPetItemStr = petItemStr;
String finalLvlString = lvlString;
String finalLvlStringShort = lvlStringShort;
String finalPetName = petName;
return new ArrayList<String>() {{
for (int index : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) {
switch (index) {
case 0:
add(petName);
add(finalPetName);
break;
case 1:
if (finalLvlStringShort != null) add(finalLvlStringShort);
Expand Down Expand Up @@ -595,6 +619,7 @@ public void render() {
int y = (int) position.y;

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

ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem2);
getAnimatedSkin(stack, currentPet2);
GlStateManager.enableDepth();
GlStateManager.pushMatrix();
Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale);
Expand Down Expand Up @@ -703,36 +729,41 @@ public void render() {
}
}

public static float getBoostMultiplier(String boostName) {
if (boostName == null) return 1;
boostName = boostName.toLowerCase(Locale.ROOT);
if (boostName.equalsIgnoreCase("PET_ITEM_ALL_SKILLS_BOOST_COMMON")) {
return 1.1f;
} else if (boostName.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
return 1.2f;
} else if (boostName.endsWith("epic")) {
return 1.5f;
} else if (boostName.endsWith("rare")) {
return 1.4f;
} else if (boostName.endsWith("uncommon")) {
return 1.3f;
} else if (boostName.endsWith("common")) {
return 1.2f;
} else {
return 1;
private void getAnimatedSkin(ItemStack stack, Pet currentPet) {
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound != null) {
String skin = currentPet.skin;
if (currentPet.skinVariantSelected >= 0) {
JsonObject animatedSkulls = Constants.ANIMATEDSKULLS;
if (animatedSkulls == null) return;
if (!animatedSkulls.has("pet_skin_variant")) return;
JsonElement pet_skin_variant = animatedSkulls.get("pet_skin_variant");
if (!pet_skin_variant.getAsJsonObject().has(skin)) return;
JsonArray skinsArray = pet_skin_variant.getAsJsonObject().get(skin).getAsJsonArray();
if (skinsArray.size() <= currentPet.skinVariantSelected) return;
skin = skinsArray.get(currentPet.skinVariantSelected).getAsString();
}
if ("PET_SKIN_FOUR_SEASONS_GRIFFIN".equals(skin)) {
String monthName = SkyBlockTime.now().getMonthName();
if (monthName.contains("Spring")) {
skin = "PET_SKIN_FOUR_SEASONS_GRIFFIN_SPRING";
} else if (monthName.contains("Summer")) {
skin = "PET_SKIN_FOUR_SEASONS_GRIFFIN_SUMMER";
} else if (monthName.contains("Autumn")) {
skin = "PET_SKIN_FOUR_SEASONS_GRIFFIN_AUTUMN";
} else if (monthName.contains("Winter")) {
skin = "PET_SKIN_FOUR_SEASONS_GRIFFIN_WINTER";
}

}
NBTTagCompound customSkull = ItemCustomizeManager.getAnimatedCustomSkull(skin, "");
if (customSkull != null) {
tagCompound.removeTag("SkullOwner");
tagCompound.setTag("SkullOwner", customSkull);
}
}
}

private static List<String> validXpTypes = Lists.newArrayList(
"mining",
"foraging",
"enchanting",
"farming",
"combat",
"fishing",
"alchemy"
);

@SubscribeEvent
public void onStackClick(SlotClickEvent event) {
// 0 through 8 are the mouse as well as the keyboard buttons, allow all of those
Expand Down Expand Up @@ -964,8 +995,7 @@ public void updatePetLevels() {
for (int i = 0; i < widgetLines.size(); i++) {
String line = widgetLines.get(i);
String lineWithColours = line.replace("§r", "").trim();
line = Utils.cleanColour(line).trim().replace(",", "");

line = Utils.cleanColour(line).replace(",", "").replace("✦", "").trim();
Matcher normalXPMatcher = TAB_LIST_XP.matcher(line);
Matcher overflowXPMatcher = TAB_LIST_XP_OVERFLOW.matcher(line);

Expand All @@ -982,7 +1012,7 @@ public void updatePetLevels() {
}

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

int closestPetIndex = getClosestPetIndex(internalName, rarity, petItem, petLevel);
if (closestPetIndex != -1) {
//If it is -1 your petcache is probably outdated and you need to open /pets, but im sure they can work it out
setCurrentPet(closestPetIndex);
if ((currentPet.petItem != null && !currentPet.petItem.equals(petItem)) || currentPet.rarity.petId != rarity ||
currentPet.petLevel.getCurrentLevel() != petLevel) {
int closestPetIndex = getClosestPetIndex(internalName, rarity, petItem, petLevel);

if (closestPetIndex != -1 && closestPetIndex != config.selectedPet) {
//If it is -1 your petcache is probably outdated and you need to open /pets, but im sure they can work it out
setCurrentPet(closestPetIndex);
}
}
lastPetCorrect = System.currentTimeMillis();
}
Expand Down Expand Up @@ -1105,6 +1139,7 @@ public static class Pet {
public String petXpType;
public String petItem;
public String skin;
public int skinVariantSelected;
public int candyUsed;

public String getPetId(boolean withoutBoost) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,17 +516,30 @@ public static NBTTagCompound getAnimatedCustomSkull(String itemID, String textur

if (customSkulls.containsKey(itemID)) {
AnimatedSkull animatedSkull = customSkulls.get(itemID);
if (animatedSkull == null) return null;
int ticks = animatedSkull.ticks;
int animatedIndex = ItemCustomizationUtils.getTicksForList(ticks, animatedSkull.skullOwners.size(), presetIndex);
return animatedSkull.skullOwners.get(animatedIndex);
}

JsonObject animatedSkulls = Constants.ANIMATEDSKULLS;
if (animatedSkulls == null) return null;
if (!animatedSkulls.has("skins")) return null;
if (!animatedSkulls.get("skins").getAsJsonObject().has(itemID)) return null;
if (animatedSkulls == null) {
customSkulls.put(itemID, null);
return null;
}
if (!animatedSkulls.has("skins")) {
customSkulls.put(itemID, null);
return null;
}
if (!animatedSkulls.get("skins").getAsJsonObject().has(itemID)) {
customSkulls.put(itemID, null);
return null;
}
JsonObject skin = animatedSkulls.get("skins").getAsJsonObject().get(itemID).getAsJsonObject();
if (!skin.has("textures")) return null;
if (!skin.has("textures")) {
customSkulls.put(itemID, null);
return null;
}
JsonArray skullTextures = skin.get("textures").getAsJsonArray();

int ticks = skin.get("ticks").getAsInt();
Expand Down

0 comments on commit f12d7c9

Please sign in to comment.