1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
package io.github.moulberry.notenoughupdates.miscfeatures;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.commons.lang3.text.WordUtils;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PetInfo {
private static final Pattern XP_GAIN_AND_SKILL_PATTERN = Pattern.compile("\\+(\\d*\\.?\\d*) (Farming|Mining|Combat|Foraging|Fishing|Enchanting|Alchemy) (\\(([0-9.,]+)/([0-9.,]+)\\))");
private static final Pattern XP_BOOST_PATTERN = Pattern.compile("PET_ITEM_(COMBAT|FISHING|MINING|FORAGING|ALL|FARMING)_(SKILL|SKILLS)_BOOST_(COMMON|UNCOMMON|RARE|EPIC)");
public enum Rarity {
COMMON(0, 0, 1, EnumChatFormatting.WHITE),
UNCOMMON(6, 1, 2, EnumChatFormatting.GREEN),
RARE(11, 2, 3, EnumChatFormatting.BLUE),
EPIC(16, 3, 4, EnumChatFormatting.DARK_PURPLE),
LEGENDARY(20, 4, 5, EnumChatFormatting.GOLD),
MYTHIC(20, 4, 5, EnumChatFormatting.LIGHT_PURPLE);
public int petOffset;
public EnumChatFormatting chatFormatting;
public int petId;
public int beastcreatMultiplyer;
Rarity(int petOffset, int petId, int beastcreatMultiplyer, EnumChatFormatting chatFormatting){
this.chatFormatting = chatFormatting;
this.petOffset = petOffset;
this.petId = petId;
this.beastcreatMultiplyer = beastcreatMultiplyer;
}
public static Rarity getRarityFromColor(EnumChatFormatting chatFormatting){
for (int i = 0; i < Rarity.values().length; i++) {
if (Rarity.values()[i].chatFormatting.equals(chatFormatting))
return Rarity.values()[i];
}
return COMMON;
}
}
public static class pet {
public String petType;
public double petExp;
public Rarity rarity;
public GuiProfileViewer.PetLevel petLevel;
public String petXpType;
public String petItem;
}
public static pet currentPet = null;
public static HashMap<String, pet> petList = new HashMap<>();
public static double currentXp = 0.0;
public static String currentXpType = "";
public static int tamingLevel = 1;
public static double beastMultiplier = 0;
public static boolean ignoreNextXp = false;
public static void clearPet(){ currentPet = null; }
public float getLevelPercent(){
DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
try {
return Float.parseFloat(df.format(currentPet.petLevel.levelPercentage * 100f ));
}catch (Exception ignored){ return 0; }
}
private static void getAndSetPet(ProfileViewer.Profile profile) {
JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile());
JsonObject skillInfo = profile.getSkillInfo(profile.getLatestProfile());
JsonObject invInfo = profile.getInventoryInfo(profile.getLatestProfile());
JsonObject profileInfo = profile.getProfileInformation(profile.getLatestProfile());
if (invInfo != null && profileInfo != null){
JsonObject stats = profileInfo.get("stats").getAsJsonObject();
boolean hasBeastmasterCrest = false;
Rarity currentBeastRarity = Rarity.COMMON;
for (JsonElement talisman : invInfo.get("talisman_bag").getAsJsonArray()) {
if (talisman.isJsonNull()) continue;
String internalName = talisman.getAsJsonObject().get("internalname").getAsString();
if (internalName.startsWith("BEASTMASTER_CREST")) {
hasBeastmasterCrest = true;
try {
Rarity talismanRarity = Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", ""));
if (talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer) currentBeastRarity = talismanRarity;
} catch (Exception ignored) {}
}
}
if (hasBeastmasterCrest) {
if (stats.has("mythos_kills")) {
int mk = stats.get("mythos_kills").getAsInt();
double petXpBoost = mk > 10000 ? 1 : mk > 7500 ? 0.9 : mk > 5000 ? 0.8 : mk > 2500 ? 0.7 :
mk > 1000 ? 0.6 : mk > 500 ? 0.5 : mk > 250 ? 0.4 : mk > 100 ? 0.3 : mk > 25 ? 0.2 : 0.1;
beastMultiplier = petXpBoost * currentBeastRarity.beastcreatMultiplyer;
}else beastMultiplier = 0.1 * currentBeastRarity.beastcreatMultiplyer;
}
}
if (skillInfo != null) tamingLevel = skillInfo.get("level_skill_taming").getAsInt();
JsonObject petsJson = Constants.PETS;
if (petsJson != null) {
if (petObject != null) {
boolean hasActivePet = false;
petList.clear();
for (int i = 0; i < petObject.getAsJsonArray("pets").size(); i++) {
JsonElement petElement = petObject.getAsJsonArray("pets").get(i);
JsonObject petObj = petElement.getAsJsonObject();
pet pet = new pet();
pet.petType = petObj.get("type").getAsString();
Rarity rarity;
try {
rarity = Rarity.valueOf(petObj.get("tier").getAsString());
} catch (Exception ignored) {
rarity = Rarity.COMMON;
}
pet.rarity = rarity;
pet.petExp = petObj.get("exp").getAsDouble();
pet.petLevel = GuiProfileViewer.getPetLevel(petsJson.get("pet_levels").getAsJsonArray(), rarity.petOffset, (float) pet.petExp);
JsonElement heldItem = petObj.get("heldItem");
pet.petItem = heldItem.isJsonNull() ? null : heldItem.getAsString();
JsonObject petTypes = petsJson.get("pet_types").getAsJsonObject();
pet.petXpType = petTypes.has(pet.petType) ? petTypes.get(pet.petType.toUpperCase()).getAsString().toLowerCase() : "unknown";
petList.put(pet.petType + ";" + pet.rarity.petId, pet);
if (petObj.get("active").getAsBoolean()) {
<
|