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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
|
package me.Danker.utils;
import me.Danker.DankersSkyblockMod;
import me.Danker.features.ColouredNames;
import me.Danker.features.CrystalHollowWaypoints;
import me.Danker.features.GoldenEnchants;
import me.Danker.handlers.APIHandler;
import me.Danker.handlers.ConfigHandler;
import me.Danker.handlers.ScoreboardHandler;
import me.Danker.handlers.TextRenderer;
import net.minecraft.block.Block;
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.network.NetworkPlayerInfo;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.util.*;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class Utils {
public static boolean inSkyblock = false;
public static boolean inDungeons = false;
public static boolean inCrystalHollows = false;
public static int[] skillXPPerLevel = {0, 50, 125, 200, 300, 500, 750, 1000, 1500, 2000, 3500, 5000, 7500, 10000, 15000, 20000, 30000, 50000,
75000, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000,
1200000, 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000,
2300000, 2400000, 2500000, 2600000, 2750000, 2900000, 3100000, 3400000, 3700000, 4000000, 4300000,
4600000, 4900000, 5200000, 5500000, 5800000, 6100000, 6400000, 6700000, 7000000};
static int[] dungeonsXPPerLevel = {0, 50, 75, 110, 160, 230, 330, 470, 670, 950, 1340, 1890, 2665, 3760, 5260, 7380, 10300, 14400,
20000, 27600, 38000, 52500, 71500, 97000, 132000, 180000, 243000, 328000, 445000, 600000, 800000,
1065000, 1410000, 1900000, 2500000, 3300000, 4300000, 5600000, 7200000, 9200000, 12000000, 15000000,
19000000, 24000000, 30000000, 38000000, 48000000, 60000000, 75000000, 93000000, 116250000};
static int[] expertiseKills = {50, 100, 250, 500, 1000, 2500, 5500, 10000, 15000};
static Pattern boldPattern = Pattern.compile("(?i)\\u00A7L");
static Map<Character, Integer> romanNumerals = new HashMap<Character, Integer>(){{
put('I', 1);
put('V', 5);
put('X', 10);
put('L', 50);
put('C', 100);
put('D', 500);
put('M', 1000);
}};
public static int getItems(String item) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
double x = player.posX;
double y = player.posY;
double z = player.posZ;
AxisAlignedBB scan = new AxisAlignedBB(x - 6, y - 6, z - 6, x + 6, y + 6, z + 6);
List<EntityItem> items = mc.theWorld.getEntitiesWithinAABB(EntityItem.class, scan);
for (EntityItem i : items) {
String itemName = StringUtils.stripControlCodes(i.getEntityItem().getDisplayName());
if (itemName.equals(item)) return i.getEntityItem().stackSize;
}
// No items found
return 0;
}
public static String returnGoldenEnchants(String line) {
Matcher matcher = GoldenEnchants.t6EnchantPattern.matcher(line);
StringBuffer out = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(out, GoldenEnchants.t6Enchants.get(matcher.group(1)));
}
matcher.appendTail(out);
return out.toString();
}
public static List<String> getMatchingPlayers(String arg) {
List<String> matchingPlayers = new ArrayList<>();
Collection<NetworkPlayerInfo> players = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap();
for (NetworkPlayerInfo player : players) {
String playerName = player.getGameProfile().getName();
if (playerName.startsWith("!")) continue; // New tablist
if (playerName.toLowerCase().startsWith(arg.toLowerCase())) {
matchingPlayers.add(playerName);
}
}
return matchingPlayers;
}
public static void createTitle(String text, int seconds) {
Minecraft.getMinecraft().thePlayer.playSound("random.orb", 1, (float) 0.5);
DankersSkyblockMod.titleTimer = seconds * 20;
DankersSkyblockMod.showTitle = true;
DankersSkyblockMod.titleText = text;
}
public static void drawTitle(String text) {
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution scaledResolution = new ScaledResolution(mc);
int height = scaledResolution.getScaledHeight();
int width = scaledResolution.getScaledWidth();
int drawHeight = 0;
String[] splitText = text.split("\n");
for (String title : splitText) {
int textLength = mc.fontRendererObj.getStringWidth(title);
double scale = 4;
if (textLength * scale > (width * 0.9F)) {
scale = (width * 0.9F) / (float) textLength;
}
int titleX = (int) ((width / 2) - (textLength * scale / 2));
int titleY = (int) ((height * 0.45) / scale) + (int) (drawHeight * scale);
new TextRenderer(mc, title, titleX, titleY, scale);
drawHeight += mc.fontRendererObj.FONT_HEIGHT;
}
}
public static boolean isOnHypixel() {
Minecraft mc = Minecraft.getMinecraft();
if (mc != null && mc.theWorld != null && !mc.isSingleplayer()) {
return mc.getCurrentServerData().serverIP.toLowerCase().contains("hypixel");
}
return false;
}
public static void checkForSkyblock() {
Minecraft mc = Minecraft.getMinecraft();
if (mc != null && mc.theWorld != null && !mc.isSingleplayer()) {
ScoreObjective scoreboardObj = mc.theWorld.getScoreboard().getObjectiveInDisplaySlot(1);
if (scoreboardObj != null) {
String scObjName = ScoreboardHandler.cleanSB(scoreboardObj.getDisplayName());
if (scObjName.contains("SKYBLOCK")) {
inSkyblock = true;
return;
}
}
}
inSkyblock = false;
}
public static void checkForDungeons() {
if (inSkyblock) {
if (isInScoreboard("The Catacombs")) {
inDungeons = true;
return;
}
}
inDungeons = false;
}
public static void checkForCrystalHollows() {
if (inSkyblock) {
Collection<NetworkPlayerInfo> players = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap();
for (NetworkPlayerInfo player : players) {
if (player == null || player.getDisplayName() == null) continue;
if (player.getDisplayName().getUnformattedText().contains("Crystal Hollows")) {
inCrystalHollows = true;
return;
}
}
}
inCrystalHollows = false;
}
public static boolean isInScoreboard(String text) {
List<String> scoreboard = ScoreboardHandler.getSidebarLines();
for (String s : scoreboard) {
String sCleaned = ScoreboardHandler.cleanSB(s);
if (sCleaned.contains(text)) return true;
}
return false;
}
public static String capitalizeString(String string) {
String[] words = string.split("_");
for (int i = 0; i < words.length; i++) {
words[i] = words[i].substring(0, 1).toUpperCase() + words[i].substring(1).toLowerCase();
}
return String.join(" ", words);
}
public static double getPercentage(int num1, int num2) {
if (num2 == 0) return 0D;
double result = ((double) num1 * 100D) / (double) num2;
result = Math.round(result * 100D) / 100D;
return result;
}
public static void drawOnSlot(int size, int xSlotPos, int ySlotPos, int colour) {
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
int guiLeft = (sr.getScaledWidth() - 176) / 2;
int guiTop = (sr.getScaledHeight() - 222) / 2;
int x = guiLeft + xSlotPos;
int y = guiTop + ySlotPos;
// Move down when chest isn't 6 rows
if (size != 90) y += (6 - (size - 36) / 9) * 9;
GL11.glTranslated(0, 0, 1);
Gui.drawRect(x, y, x + 16, y + 16, colour);
GL11.glTranslated(0, 0, -1);
}
public static String getTimeBetween(double timeOne, double timeTwo) {
double secondsBetween = Math.floor(timeTwo - timeOne);
String timeFormatted;
int days;
int hours;
int minutes;
int seconds;
if (secondsBetween > 86400) {
// More than 1d, display #d#h
days = (int) (secondsBetween / 86400);
hours = (int) (secondsBetween % 86400 / 3600);
timeFormatted = days + "d" + hours + "h";
} else if (secondsBetween > 3600) {
// More than 1h, display #h#m
hours = (int) (secondsBetween / 3600);
minutes = (int) (secondsBetween % 3600 / 60);
timeFormatted = hours + "h" + minutes + "m";
} else {
// Display #m#s
minutes = (int) (secondsBetween / 60);
seconds = (int) (secondsBetween % 60);
timeFormatted = minutes + "m" + seconds + "s";
}
return timeFormatted;
}
public static String getMoneySpent(double coins) {
double coinsSpentMillions = coins / 1000000D;
coinsSpentMillions = Math.floor(coinsSpentMillions * 100D) / 100D;
return coinsSpentMillions + "M";
}
public static double xpToSkillLevel(double xp, int limit) {
for (int i = 0, xpAdded = 0; i < limit + 1; i++) {
xpAdded += skillXPPerLevel[i];
if (xp < xpAdded) {
return (i - 1) + (xp - (xpAdded - skillXPPerLevel[i])) / skillXPPerLevel[i];
}
}
return limit;
}
public static double xpToDungeonsLevel(double xp) {
for (int i = 0, xpAdded = 0; i < dungeonsXPPerLevel.length; i++) {
xpAdded += dungeonsXPPerLevel[i];
if (xp < xpAdded) {
double level = (i - 1) + (xp - (xpAdded - dungeonsXPPerLevel[i])) / dungeonsXPPerLevel[i];
return (double) Math.round(level * 100) / 100;
}
}
return 50D;
}
public static int expertiseKillsLeft(int kills) {
for (int i = 0; i < expertiseKills.length; i++) {
if (kills < expertiseKills[i]) {
return expertiseKills[i] - kills;
}
}
return -1;
}
// Only used when over limit
public static int getPastXpEarned(int currentLevelXp, int limit) {
if (currentLevelXp == 0) {
int xpAdded = 0;
for (int i = 1; i <= limit; i++) {
xpAdded += skillXPPerLevel[i];
}
return xpAdded;
}
for (int i = 1, xpAdded = 0; i <= limit; i++) {
xpAdded += skillXPPerLevel[i - 1];
if (currentLevelXp == skillXPPerLevel[i]) return xpAdded;
}
return 0;
}
public static double getTotalXpEarned(int currentLevel, double percentage) {
double progress = 0;
if (currentLevel < 60) progress = skillXPPerLevel[currentLevel + 1] * (percentage / 100D);
double xpAdded = 0;
for (int i = 1; i <= currentLevel; i++) {
xpAdded += skillXPPerLevel[i];
}
return xpAdded + progress;
}
public static String getColouredBoolean(boolean bool) {
return bool ? EnumChatFormatting.GREEN + "On" : EnumChatFormatting.RED + "Off";
}
// Taken from SkyblockAddons
public static List<String> getItemLore(ItemStack itemStack) {
final int NBT_INTEGER = 3;
final int NBT_STRING = 8;
final int NBT_LIST = 9;
final int NBT_COMPOUND = 10;
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("display", NBT_COMPOUND)) {
NBTTagCompound display = itemStack.getTagCompound().getCompoundTag("display");
if (display.hasKey("Lore", NBT_LIST)) {
NBTTagList lore = display.getTagList("Lore", NBT_STRING);
List<String> loreAsList = new ArrayList<>();
for (int lineNumber = 0; lineNumber < lore.tagCount(); lineNumber++) {
loreAsList.add(lore.getStringTagAt(lineNumber));
}
return Collections.unmodifiableList(loreAsList);
}
}
return Collections.emptyList();
}
public static boolean hasRightClickAbility(ItemStack itemStack) {
return Utils.getItemLore(itemStack).stream().anyMatch(line -> {
String stripped = StringUtils.stripControlCodes(line);
return stripped.startsWith("Item Ability:") && stripped.endsWith("RIGHT CLICK");
});
}
public static void draw3DLine(Vec3 pos1, Vec3 pos2, int colourInt, int lineWidth, boolean depth, float partialTicks) {
Entity render = Minecraft.getMinecraft().getRenderViewEntity();
WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
Color colour = new Color(colourInt);
double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
GlStateManager.pushMatrix();
GlStateManager.translate(-realX, -realY, -realZ);
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GL11.glLineWidth(lineWidth);
if (!depth) {
GL11.glDisable(GL11.GL_DEPTH_TEST);
GlStateManager.depthMask(false);
}
GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, colour.getAlpha() / 255f);
worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
worldRenderer.pos(pos1.xCoord, pos1.yCoord, pos1.zCoord).endVertex();
worldRenderer.pos(pos2.xCoord, pos2.yCoord, pos2.zCoord).endVertex();
Tessellator.getInstance().draw();
GlStateManager.translate(realX, realY, realZ);
if (!depth) {
GL11.glEnable(GL11.GL_DEPTH_TEST);
GlStateManager.depthMask(true);
}
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
public static void draw3DString(BlockPos pos, String text, int colour, float partialTicks) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
double x = (pos.getX() - player.lastTickPosX) + ((pos.getX() - player.posX) - (pos.getX() - player.lastTickPosX)) * partialTicks;
double y = (pos.getY() - player.lastTickPosY) + ((pos.getY() - player.posY) - (pos.getY() - player.lastTickPosY)) * partialTicks;
double z = (pos.getZ() - player.lastTickPosZ) + ((pos.getZ() - player.posZ) - (pos.getZ() - player.lastTickPosZ)) * partialTicks;
RenderManager renderManager = mc.getRenderManager();
float f = 1.6F;
float f1 = 0.016666668F * f;
int width = mc.fontRendererObj.getStringWidth(text) / 2;
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GL11.glNormal3f(0f, 1f, 0f);
GlStateManager.rotate(-renderManager.playerViewY, 0f, 1f, 0f);
GlStateManager.rotate(renderManager.playerViewX, 1f, 0f, 0f);
GlStateManager.scale(-f1, -f1, -f1);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
mc.fontRendererObj.drawString(text, -width, 0, colour);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
// I couldnt get waypoint strings to work so in the end I just copied from NEU
// If anyone sees this please help
/*public static void draw3DWaypointString(CrystalHollowWaypoints.Waypoint waypoint, float partialTicks) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
BlockPos pos = waypoint.pos;
double x = (pos.getX() - player.lastTickPosX) + ((pos.getX() - player.posX) - (pos.getX() - player.lastTickPosX)) * partialTicks;
double y = (pos.getY() - player.lastTickPosY) + ((pos.getY() - player.posY) - (pos.getY() - player.lastTickPosY)) * partialTicks;
double z = (pos.getZ() - player.lastTickPosZ) + ((pos.getZ() - player.posZ) - (pos.getZ() - player.lastTickPosZ)) * partialTicks;
double distance = player.getDistance(x, y, z);
if (distance > 12) {
x *= 12 / distance;
y *= 12 / distance;
z *= 12 / distance;
}
RenderManager renderManager = mc.getRenderManager();
Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
float f = 1.6F;
float f1 = 0.016666668F * f;
int width = mc.fontRendererObj.getStringWidth(waypoint.location) / 2;
int width2 = mc.fontRendererObj.getStringWidth(waypoint.getDistance(player)) / 2;
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GL11.glNormal3f(0f, 1f, 0f);
GlStateManager.rotate(-renderManager.playerViewY, 0f, 1f, 0f);
GlStateManager.rotate(renderManager.playerViewX, 1f, 0f, 0f);
GlStateManager.scale(-f1, -f1, -f1);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GlStateManager.depthMask(false);
mc.fontRendererObj.drawString(waypoint.location, -width, 0, 0x55FFFF);
GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.translate(0, -1, 0);
GlStateManager.rotate(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
mc.fontRendererObj.drawString(waypoint.getDistance(player), -width2, 0, 0xFFFF55);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GlStateManager.depthMask(true);
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}*/
// https://github.com/Moulberry/NotEnoughUpdates/blob/master/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java#L261
public static void draw3DWaypointString(CrystalHollowWaypoints.Waypoint waypoint, float partialTicks) {
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.pushMatrix();
Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
double x = waypoint.pos.getX()-viewerX+0.5f;
double y = waypoint.pos.getY()-viewerY-viewer.getEyeHeight();
double z = waypoint.pos.getZ()-viewerZ+0.5f;
double distSq = x*x + y*y + z*z;
double dist = Math.sqrt(distSq);
if(distSq > 144) {
x *= 12/dist;
y *= 12/dist;
z *= 12/dist;
}
GlStateManager.translate(x, y, z);
GlStateManager.translate(0, viewer.getEyeHeight(), 0);
renderNametag(EnumChatFormatting.AQUA + waypoint.location);
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.translate(0, -0.25f, 0);
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
renderNametag(EnumChatFormatting.YELLOW + waypoint.getDistance(Minecraft.getMinecraft().thePlayer));
GlStateManager.popMatrix();
GlStateManager.disableLighting();
}
// https://github.com/Moulberry/NotEnoughUpdates/blob/master/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java#L300
public static void renderNametag(String str) {
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
float f = 1.6F;
float f1 = 0.016666668F * f;
GlStateManager.pushMatrix();
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-f1, -f1, f1);
GlStateManager.disableLighting();
GlStateManager.depthMask(false);
GlStateManager.disableDepth();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
int i = 0;
int j = fontrenderer.getStringWidth(str) / 2;
GlStateManager.disableTexture2D();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127);
GlStateManager.depthMask(true);
fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1);
GlStateManager.enableDepth();
GlStateManager.enableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
public static void draw3DBox(AxisAlignedBB aabb, int colourInt, float partialTicks) {
Entity render = Minecraft.getMinecraft().getRenderViewEntity();
Color colour = new Color(colourInt);
double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
GlStateManager.pushMatrix();
GlStateManager.translate(-realX, -realY, -realZ);
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GL11.glLineWidth(2);
RenderGlobal.drawOutlinedBoundingBox(aabb, colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha());
GlStateManager.translate(realX, realY, realZ);
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
public static void drawFilled3DBox(AxisAlignedBB aabb, int colourInt, boolean translucent, boolean depth, float partialTicks) {
Entity render = Minecraft.getMinecraft().getRenderViewEntity();
WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
Color colour = new Color(colourInt);
double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
GlStateManager.pushMatrix();
GlStateManager.pushAttrib();
GlStateManager.translate(-realX, -realY, -realZ);
GlStateManager.disableTexture2D();
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.disableCull();
GlStateManager.tryBlendFuncSeparate(770, translucent ? 1 : 771, 1, 0);
if (!depth) {
GL11.glDisable(GL11.GL_DEPTH_TEST);
GlStateManager.depthMask(false);
}
GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, colour.getAlpha() / 255f);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
// Bottom
worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
// Top
worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
// West
worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
// East
worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
// North
worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
// South
worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();
Tessellator.getInstance().draw();
GlStateManager.translate(realX, realY, realZ);
if (!depth) {
GL11.glEnable(GL11.GL_DEPTH_TEST);
GlStateManager.depthMask(true);
}
GlStateManager.enableCull();
GlStateManager.disableAlpha();
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popAttrib();
GlStateManager.popMatrix();
}
public static void renderItem(ItemStack item, float x, float y, float z) {
GlStateManager.enableRescaleNormal();
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableDepth();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(item, 0, 0);
GlStateManager.popMatrix();
GlStateManager.disableDepth();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
}
public static BlockPos getFirstBlockPosAfterVectors(Minecraft mc, Vec3 pos1, Vec3 pos2, int strength, int distance) {
double x = pos2.xCoord - pos1.xCoord;
double y = pos2.yCoord - pos1.yCoord;
double z = pos2.zCoord - pos1.zCoord;
for (int i = strength; i < distance * strength; i++) { // Start at least 1 strength away
double newX = pos1.xCoord + ((x / strength) * i);
double newY = pos1.yCoord + ((y / strength) * i);
double newZ = pos1.zCoord + ((z / strength) * i);
BlockPos newBlock = new BlockPos(newX, newY, newZ);
if (mc.theWorld.getBlockState(newBlock).getBlock() != Blocks.air) {
return newBlock;
}
}
return null;
}
public static BlockPos getNearbyBlock(Minecraft mc, BlockPos pos, Block... blockTypes) {
if (pos == null) return null;
BlockPos pos1 = new BlockPos(pos.getX() - 2, pos.getY() - 3, pos.getZ() - 2);
BlockPos pos2 = new BlockPos(pos.getX() + 2, pos.getY() + 3, pos.getZ() + 2);
BlockPos closestBlock = null;
double closestBlockDistance = 99;
Iterable<BlockPos> blocks = BlockPos.getAllInBox(pos1, pos2);
for (BlockPos block : blocks) {
for (Block blockType : blockTypes) {
if (mc.theWorld.getBlockState(block).getBlock() == blockType && block.distanceSq(pos) < closestBlockDistance) {
closestBlock = block;
closestBlockDistance = block.distanceSq(pos);
}
}
}
return closestBlock;
}
public static BlockPos getBlockUnderItemFrame(EntityItemFrame itemFrame) {
switch (itemFrame.facingDirection) {
case NORTH:
return new BlockPos(itemFrame.posX, itemFrame.posY, itemFrame.posZ + 1);
case EAST:
return new BlockPos(itemFrame.posX - 1, itemFrame.posY, itemFrame.posZ - 0.5);
case SOUTH:
return new BlockPos(itemFrame.posX, itemFrame.posY, itemFrame.posZ - 1);
case WEST:
return new BlockPos(itemFrame.posX + 1, itemFrame.posY, itemFrame.posZ - 0.5);
default:
return null;
}
}
public static boolean isRealPlayer(EntityPlayer player) {
return player.getUniqueID().version() == 4 && !player.isPlayerSleeping();
}
public static String removeBold(String text) {
return boldPattern.matcher(text).replaceAll("");
}
public static int getIntFromString(String text, boolean romanNumeral) {
if (text.matches(".*\\d.*")) {
return Integer.parseInt(StringUtils.stripControlCodes(text).replaceAll("[^\\d]", ""));
} else if (romanNumeral) {
int number = 0;
for (int i = 0; i < text.length(); i++) {
if (!romanNumerals.containsKey(text.charAt(i))) continue;
int roman = romanNumerals.get(text.charAt(i));
if (i != text.length() - 1 && romanNumerals.containsKey(text.charAt(i + 1)) && roman < romanNumerals.get(text.charAt(i + 1))) {
number += romanNumerals.get(text.charAt(i + 1)) - roman;
i++;
} else {
number += roman;
}
}
return number;
}
return -1;
}
public static boolean skillsInitialized() {
return DankersSkyblockMod.miningLevel != -1;
}
public static int initializeSkill(ItemStack skillStack, String configValue) {
int level = -1;
if (skillStack != null) {
String display = skillStack.getDisplayName();
if (display.startsWith("§a")) {
if (display.contains(" ")) {
level = Utils.getIntFromString(display.substring(display.indexOf(" ") + 1), true);
} else {
level = 0;
}
}
}
ConfigHandler.writeIntConfig("skills", configValue, level);
return level;
}
public static void refreshRepo() {
DankersSkyblockMod.data = APIHandler.getResponse("https://raw.githubusercontent.com/bowser0000/SkyblockMod-REPO/main/data.json");
System.out.println("Loaded data from GitHub?: " + (DankersSkyblockMod.data != null && DankersSkyblockMod.data.has("trivia")));
ColouredNames.users = DankersSkyblockMod.data.get("colourednames").getAsJsonObject().entrySet().stream()
.map(Map.Entry::getKey)
.collect(Collectors.toCollection(ArrayList::new));
System.out.println("Refreshed DSM repo at " + System.currentTimeMillis());
}
}
|