-
Notifications
You must be signed in to change notification settings - Fork 7
/
ZanRadar.java
1459 lines (1271 loc) · 63.3 KB
/
ZanRadar.java
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
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package net.minecraft.src;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D; //
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStream; //
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import java.util.zip.ZipFile;
import javax.imageio.ImageIO;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import net.minecraft.client.Minecraft;
import net.minecraft.src.mamiyaotaru.Contact;
import net.minecraft.src.mamiyaotaru.EnumOptionsHelperMinimap;
import net.minecraft.src.mamiyaotaru.EnumOptionsMinimap;
public class ZanRadar {
private Minecraft game;
private Tessellator tesselator = Tessellator.instance;
/*Render texture*/
private RenderEngine renderEngine;
/*Font rendering class*/
private FontRenderer fontRenderer;
public ZanMinimap minimap = null;
/*Display anything at all, menu, etc..*/
private boolean enabled = true;
/*Hide just the tracker*/ // if integrated with Zan's, equivalent to disabling mob overlay
public boolean hide = false;
public boolean showHostiles = true;
public boolean showPlayers = true;
public boolean showNeutrals = false;
public boolean outlines = true;
public boolean filtering = true;
public boolean showHelmets = true;
/*Have we finished loading icons (done in thread)*/
private boolean completedLoading = false;
/*Holds error exceptions thrown*/
private String error = "";
/*Moblist update interval*/
private int timer = 500;
/*Time remaining to show error thrown for*/
private int ztimer = 0;
/*Direction you're facing*/
private float direction = 0.0f;
/*Last X coordinate rendered*/
private double lastX = 0;
/*Last Z coordinate rendered*/
private double lastZ = 0;
/*Last Y coordinate rendered*/
private int lastY = 0;
private int lastZoom;
/*list of moving contacts*/
private ArrayList<Contact> contacts = new ArrayList(40);
public TreeMap<String, Integer> mpContacts = new TreeMap(String.CASE_INSENSITIVE_ORDER);
private ITexturePack pack = null;
private final int BLANK = 0; // for spiders being ridden (rendered by the skeleton)
private final int BLANKHOSTILE = 1; // unknown (mod) mobs. at least show red / blue / green for hostile / neutral / tame
private final int BLANKNEUTRAL = 2;
private final int BLANKTAME = 3;
private final int BAT = 4;
private final int BLAZE = 5;
private final int CATBLACK = 6;
private final int CATRED = 7;
private final int CATSIAMESE = 8;
private final int CAVESPIDER = 9;
private final int CHICKEN = 10;
private final int COW = 11;
private final int CREEPER = 12;
private final int ENDERDRAGON = 13;
private final int ENDERMAN = 14;
private final int GHAST = 15;
private final int GHASTATTACKING = 16;
private final int IRONGOLEM = 17;
private final int MAGMA = 18;
private final int MOOSHROOM = 19;
private final int OCELOT = 20;
private final int PIG = 21;
private final int PIGZOMBIE = 22;
private final int PLAYER = 23;
private final int SHEEP = 24;
private final int SILVERFISH = 25;
private final int SKELETON = 26;
private final int SKELETONWITHER = 27;
private final int SLIME = 28;
private final int SNOWGOLEM = 29;
private final int SPIDER = 30;
private final int SPIDERJOCKEY = 31;
private final int SPIDERJOCKEYWITHER = 32;
private final int SQUID = 33;
private final int VILLAGER = 34;
private final int WITCH = 35;
private final int WITHER = 36;
private final int WITHERINVULNERABLE = 37;
private final int WOLF = 38;
private final int WOLFANGRY = 39;
private final int WOLFTAME = 40;
private final int ZOMBIE = 41;
private final int ZOMBIEVILLAGER = 42;
private BufferedImage[][] icons = new BufferedImage[43][2];
private int[][] imageRef = new int[44][2];
/** hardcoding size here instead of after squarifiying images, in case I ever want to allow higher def images in icons
* currently full screen is showing icons at double their resolution. Can allow higher. Reading size then would just
* display them even bigger, and still double their resolution. Code here what they should be, then can worry about resolution later
*/
// size with smallest power of two that leaves blank area on all sides
private int[] size = {4, 16, 16, 16, 16, 16, 8, 8, 8, 16, 8, 16, 16, 32, 16, 32, 32, 16, 16, 16, 8, 16, 16, 16, 8, 8, 16, 16, 16, 16, 16, 32, 32, 16, 16, 16, 32, 32, 16, 16, 16, 16, 16};
// size before squarifying
private int[] sizeBase = {2, 8, 8, 8, 8, 8, 5, 5, 5, 8, 6, 10, 8, 16, 8, 16, 16, 8, 8, 10, 5, 8, 8, 8, 6, 6, 8, 8, 8, 8, 8, 8, 8, 6, 8, 10, 24, 24, 6, 6, 6, 8, 8};
// size with smallest power of two that holds the image. Image can be right up to the edge - possibly less desirable for filtering
//private int[] size = {2, 8, 8, 8, 16, 8, 8, 8, 8, 8, 8, 16, 8, 32, 8, 16, 16, 16, 8, 16, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 8, 16, 16, 32, 32, 8, 8, 8, 8, 16};//new int[26];
// bat is 8 without ears 16 with. cow (and mooshroom) is 8 without horns 16 with. dragon is 16 without crests 32 with
private final int CLOTH = 0;
//private final int CLOTHOVERLAY = 1;
//private final int CLOTHOUTER = 2;
//private final int CLOTHOVERLAYOUTER = 3;
private final int CHAIN = 4;
private final int IRON = 6;
private final int GOLD = 8;
private final int DIAMOND = 10;
private BufferedImage[][] armorIcons = new BufferedImage[12][2];
private int[][] armorImageRef = new int[12][2];
public ZanRadar(ZanMinimap minimap) {
this.minimap = minimap;
this.renderEngine = minimap.renderEngine;
for (int t = 0; t < icons.length; t++) {
imageRef[t][0]=-1;
imageRef[t][1]=-1;
}
for (int t = 0; t < armorIcons.length; t++) {
armorImageRef[t][0]=-1;
armorImageRef[t][1]=-1;
}
loadDefaultIcons();
// loadTexturePackIcons();
}
private void loadDefaultIcons() {
// Read from a file
//File file = new File("image.gif");
//image = ImageIO.read(file);
// Read from an input stream
//InputStream is = new BufferedInputStream(
// new FileInputStream("image.gif"));
//image = ImageIO.read(is);
// Read from a URL
//URL url = new URL("http://hostname.com/image.gif");
//image = ImageIO.read(url);
//File file = new File("c:/terrain.png");
//java.awt.Image terrain = ImageIO.read(file);
}
public void loadTexturePackIcons() {
//System.out.println("loading icons " + pack.func_77531_d() + " * " + pack.func_77536_b() + " * " + pack.func_77537_e() + " * " + pack.func_77538_c());
try {
// Read from a file
//File file = new File("image.gif");
//image = ImageIO.read(file);
// Read from an input stream
//InputStream is = new BufferedInputStream(
// new FileInputStream("image.gif"));
//image = ImageIO.read(is);
// Read from a URL
//URL url = new URL("http://hostname.com/image.gif");
//image = ImageIO.read(url);
//File file = new File("c:/terrain.png");
//java.awt.Image terrain = ImageIO.read(file);
//System.out.println("WIDTH: " + terrain.getWidth(null));
icons[BLANK][0] = blankImage("bat", 2, 2);
icons[BLANKHOSTILE][0] = addCharacter(blankImage("zombie", 8, 8, 255, 0, 0, 255), "?");
icons[BLANKNEUTRAL][0] = addCharacter(blankImage("cow", 8, 8, 85, 100, 255, 255), "?");
icons[BLANKTAME][0] = addCharacter(blankImage("wolf", 8, 8, 0, 255, 0, 255), "?");
//icons[BAT][0] = loadImage("bat", 6, 6, 6, 6, 64, 64); // without initial whitespace
icons[BAT][0] = addImages(addImages(addImages(blankImage("bat", 8, 10, 64, 64), loadImage("bat", 25, 1, 3, 4), 0, 0, 8, 10), flipHorizontal(loadImage("bat", 25, 1, 3, 4)), 5, 0, 8, 10), loadImage("bat", 6, 6, 6, 6), 1, 2, 8, 10); // ears then head
icons[BLAZE][0] = loadImage("fire", 8, 8, 8, 8);
icons[CATBLACK][0] = addImages(addImages(addImages(addImages(blankImage("cat_black", 5, 5), loadImage("cat_black", 5, 5, 5, 4), 0, 1, 5, 5), loadImage("cat_black", 2, 26, 3, 2), 1, 3, 5, 5), loadImage("cat_black", 2, 12, 1, 1), 1, 0, 5, 5), loadImage("cat_black", 8, 12, 1, 1), 3, 0, 5, 5);;
icons[CATRED][0] = addImages(addImages(addImages(addImages(blankImage("cat_red", 5, 5), loadImage("cat_red", 5, 5, 5, 4), 0, 1, 5, 5), loadImage("cat_red", 2, 26, 3, 2), 1, 3, 5, 5), loadImage("cat_red", 2, 12, 1, 1), 1, 0, 5, 5), loadImage("cat_red", 8, 12, 1, 1), 3, 0, 5, 5);;
icons[CATSIAMESE][0] = addImages(addImages(addImages(addImages(blankImage("cat_siamese", 5, 5), loadImage("cat_siamese", 5, 5, 5, 4), 0, 1, 5, 5), loadImage("cat_siamese", 2, 26, 3, 2), 1, 3, 5, 5), loadImage("cat_siamese", 2, 12, 1, 1), 1, 0, 5, 5), loadImage("cat_siamese", 8, 12, 1, 1), 3, 0, 5, 5);;
icons[CAVESPIDER][0] = addImages(addImages(blankImage("cavespider", 8, 8), loadImage("cavespider", 6, 6, 6, 6), 1, 1, 8, 8), loadImage("cavespider", 40, 12, 8, 8), 0, 0, 8, 8); // head first (it's the biggest)((NOPE, blank image first)) then thorax then head. In case head is invisible, this gives us the thorax
icons[CHICKEN][0] = addImages(addImages(loadImage("chicken", 2, 3, 6, 6), loadImage("chicken", 16, 2, 4, 2), 1, 2, 6, 6), loadImage("chicken", 16, 6, 2, 2), 2, 4, 6, 6);
//icons[COW][0] = loadImage("cow", 6, 6, 8, 8); // pre horns
icons[COW][0] = addImages(addImages(addImages(blankImage("cow", 10, 10), loadImage("cow", 6, 6, 8, 8), 1, 1, 10, 10), loadImage("cow", 23, 1, 1, 3), 0, 0, 10, 10), loadImage("cow", 23, 1, 1, 3), 9, 0, 10, 10);
icons[CREEPER][0] = loadImage("creeper", 8, 8, 8, 8);
//icons[ENDERDRAGON][0] = addImages(addImages(loadImage("enderdragon/ender", 128, 46, 16, 16, 256, 256), loadImage("enderdragon/ender", 192, 60, 12, 5, 256, 256), 2, 7, 16, 16), loadImage("enderdragon/ender", 192, 81, 12, 4, 256, 256), 2, 12, 16, 16); // with jaws
//icons[ENDERDRAGON][0] = addImages(addImages(addImages(addImages(loadImage("enderdragon/ender", 128, 46, 16, 16, 256, 256), loadImage("enderdragon/ender", 192, 60, 12, 5, 256, 256), 2, 7, 16, 16), loadImage("enderdragon/ender", 192, 81, 12, 4, 256, 256), 2, 12, 16, 16), loadImage("enderdragon/ender", 116, 4, 2, 2, 256, 256), 3, 5, 16, 16), flipHorizontal(loadImage("enderdragon/ender", 116, 4, 2, 2, 256, 256)), 11, 5, 16, 16); // nostrils (block eyes, not super visible)
icons[ENDERDRAGON][0] = addImages(addImages(addImages(addImages(addImages(blankImage("enderdragon/ender", 16, 20, 256, 256), loadImage("enderdragon/ender", 128, 46, 16, 16, 256, 256), 0, 4, 16, 16), loadImage("enderdragon/ender", 192, 60, 12, 5, 256, 256), 2, 11, 16, 16), loadImage("enderdragon/ender", 192, 81, 12, 4, 256, 256), 2, 16, 16, 16), loadImage("enderdragon/ender", 6, 6, 2, 4, 256, 256), 3, 0, 16, 16), flipHorizontal(loadImage("enderdragon/ender", 6, 6, 2, 4, 256, 256)), 11, 0, 16, 16); // with head crests no nostrils. base, head, upper jaw, lower jaw, left crest, right crest
icons[ENDERMAN][0] = addImages(addImages(addImages(loadImage("enderman", 8, 8, 8, 8), loadImage("enderman", 8, 24, 8, 8), 0, 0, 8, 8), loadImage("enderman", 8, 8, 8, 8), 0, 0, 8, 8), loadImage("enderman_eyes", 8, 12, 8, 1), 0, 4, 8, 8); // head twice, once to establish size, then again because it goes over the jaw
icons[GHAST][0] = loadImage("ghast", 16, 16, 16, 16);
icons[GHASTATTACKING][0] = loadImage("ghast_fire", 16, 16, 16, 16);
//icons[IRONGOLEM][0] = loadImage("villager_golem", 8, 8, 8, 10, 128, 128); // pre blank image for protruding nose
icons[IRONGOLEM][0] = addImages(addImages(blankImage("villager_golem", 8, 12, 128, 128), loadImage("villager_golem", 8, 8, 8, 10, 128, 128), 0, 1, 8, 12), loadImage("villager_golem", 26, 2, 2, 4, 128, 128), 3, 8, 8, 12); // pre blank image for protruding nose
icons[MAGMA][0] = addImages(addImages(loadImage("lava", 8, 8, 8, 8), loadImage("lava", 32, 18, 8, 1), 0, 3, 8, 8), loadImage("lava", 32, 27, 8, 1), 0, 4, 8, 8);
icons[MOOSHROOM][0] = addImages(addImages(addImages(blankImage("redcow", 10, 10), loadImage("redcow", 6, 6, 8, 8), 1, 1, 10, 10), loadImage("redcow", 23, 1, 1, 3), 0, 0, 10, 10), loadImage("redcow", 23, 1, 1, 3), 9, 0, 10, 10);
//icons[OCELOT][0] = addImages(loadImage("ozelot", 5, 5, 5, 5), loadImage("ozelot", 2, 26, 3, 2), 1, 2, 5, 5); // pre ears
icons[OCELOT][0] = addImages(addImages(addImages(addImages(blankImage("ozelot", 5, 5), loadImage("ozelot", 5, 5, 5, 4), 0, 1, 5, 5), loadImage("ozelot", 2, 26, 3, 2), 1, 3, 5, 5), loadImage("ozelot", 2, 12, 1, 1), 1, 0, 5, 5), loadImage("ozelot", 8, 12, 1, 1), 3, 0, 5, 5);;
icons[PIG][0] = addImages(loadImage("pig", 8, 8, 8, 8), loadImage("pig", 16, 17, 6, 3), 1, 4, 8, 8);
icons[PIGZOMBIE][0] = addImages(loadImage("pigzombie", 8, 8, 8, 8), loadImage("pigzombie", 40, 8, 8, 8), 0, 0, 8, 8);
icons[PLAYER][0] = addImages(loadImage("char", 8, 8, 8, 8), loadImage("char", 40, 8, 8, 8), 0, 0, 8, 8);
icons[SHEEP][0] = loadImage("sheep", 8, 8, 6, 6);
icons[SILVERFISH][0] = addImages(loadImage("silverfish", 22, 20, 6, 6), loadImage("silverfish", 2, 2, 3, 2), 2, 2, 6, 6);
icons[SKELETON][0] = addImages(loadImage("skeleton", 8, 8, 8, 8), loadImage("skeleton", 40, 8, 8, 8), 0, 0, 8, 8);
icons[SKELETONWITHER][0] = addImages(loadImage("skeleton_wither", 8, 8, 8, 8), loadImage("skeleton_wither", 40, 8, 8, 8), 0, 0, 8, 8);
//icons[SLIME][0] = addImages(addImages(addImages(loadImage("slime", 8, 8, 8, 8), loadImage("slime", 6, 22, 6 ,6), 1, 1, 8, 8), loadImage("slime", 34, 6, 2, 2), 1, 2, 8, 8), loadImage("slime", 34, 2, 2, 2), 5, 2, 8, 8); // old one pre grab whitespace (and inside on top of outside)
icons[SLIME][0] = addImages(addImages(addImages(addImages(addImages(blankImage("slime", 8, 8), loadImage("slime", 6, 22, 6 ,6), 1, 1, 8, 8), loadImage("slime", 34, 6, 2, 2), 5, 2, 8, 8), loadImage("slime", 34, 2, 2, 2), 1, 2, 8, 8), loadImage("slime", 33, 9, 1, 1), 4, 5, 8, 8), loadImage("slime", 8, 8, 8, 8), 0, 0, 8, 8); // blank template, inner, left eye, right eye, mouth, outer see through body
icons[SNOWGOLEM][0] = loadImage("snowman", 8, 8, 8, 8, 64, 64);
icons[SPIDER][0] = addImages(addImages(blankImage("spider", 8, 8), loadImage("spider", 6, 6, 6, 6), 1, 1, 8, 8), loadImage("spider", 40, 12, 8, 8), 0, 0, 8, 8);
icons[SPIDERJOCKEY][0] = addImages(addImages(blankImage("skeleton", 8, 16), icons[SKELETON][0], 0, 0, 8, 16), icons[SPIDER][0], 0, 8, 8, 16);
icons[SPIDERJOCKEYWITHER][0] = addImages(addImages(blankImage("skeleton_wither", 8, 16), icons[SKELETONWITHER][0], 0, 0, 8, 16), icons[SPIDER][0], 0, 8, 8, 16);
icons[SQUID][0] = scaleImage(loadImage("squid", 12, 12, 12, 16), 0.5f); // squid is too big for what it is
//icons[VILLAGER][0] = addImages(loadImage("villager/farmer", 8, 8, 8, 10, 64, 64), loadImage("villager/farmer", 26, 2, 2, 3, 64, 64), 3, 7, 8, 10); // pre blank image for protruding nose
icons[VILLAGER][0] = addImages(addImages(blankImage("villager/farmer", 8, 12), loadImage("villager/farmer", 8, 8, 8, 10, 64, 64), 0, 1, 8, 12), loadImage("villager/farmer", 26, 2, 2, 4, 64, 64), 3, 8, 8, 12);
//icons[WITCH][0] = addImages(addImages(loadImage("villager/witch", 8, 8, 8, 10, 64, 128), loadImage("villager/witch", 26, 2, 2, 3, 64, 128), 3, 7, 8, 10), loadImage("villager/witch", 11, 75, 8, 2, 64, 128), 0, 0, 8, 10); // old one pre grabbing whitespace first
icons[WITCH][0] = addImages(addImages(addImages(addImages(addImages(blankImage("villager/witch", 10, 16, 64, 128), loadImage("villager/witch", 8, 8, 8, 10, 64, 128), 1, 5, 10, 16), loadImage("villager/witch", 26, 2, 2, 4, 64, 128), 4, 12, 10, 16), loadImage("villager/witch", 10, 74, 10, 3, 64, 128), 0, 4, 10, 16), loadImage("villager/witch", 7, 83, 7, 4, 64, 128), 1.5f, 0, 10, 16), loadImage("villager/witch", 1, 1, 1, 1, 64, 128), 5, 14, 10, 16); // base face nose hatbrim hatnext
icons[WITHER][0] = addImages(addImages(addImages(blankImage("wither", 24, 10, 64, 64), loadImage("wither", 8, 8, 8, 8, 64, 64), 8, 0, 24, 10), loadImage("wither", 38, 6, 6, 6, 64, 64), 0, 2, 24, 10), loadImage("wither", 38, 6, 6, 6, 64, 64), 18, 2, 24, 10);
icons[WITHERINVULNERABLE][0] = addImages(addImages(addImages(blankImage("wither_invul", 24, 10, 64, 64), loadImage("wither_invul", 8, 8, 8, 8, 64, 64), 8, 0, 24, 10), loadImage("wither_invul", 38, 6, 6, 6, 64, 64), 0, 2, 24, 10), loadImage("wither_invul", 38, 6, 6, 6, 64, 64), 18, 2, 24, 10);
//icons[WOLF][0] = addImages(loadImage("wolf", 4, 4, 6, 6), loadImage("wolf", 4, 14, 3, 3), 1.5f, 3, 6, 6); // square before blankimage
icons[WOLF][0] = addImages(addImages(addImages(addImages(blankImage("wolf", 6, 8), loadImage("wolf", 4, 4, 6, 6), 0, 2, 6, 8), loadImage("wolf", 4, 14, 3, 3), 1.5f, 5, 6, 8), loadImage("wolf", 17, 15, 2, 2), 0, 0, 6, 8), loadImage("wolf", 17, 15, 2, 2), 4, 0, 6, 8);
icons[WOLFANGRY][0] = addImages(addImages(addImages(addImages(blankImage("wolf_angry", 6, 8), loadImage("wolf_angry", 4, 4, 6, 6), 0, 2, 6, 8), loadImage("wolf_angry", 4, 14, 3, 3), 1.5f, 5, 6, 8), loadImage("wolf_angry", 17, 15, 2, 2), 0, 0, 6, 8), loadImage("wolf_angry", 17, 15, 2, 2), 4, 0, 6, 8);
icons[WOLFTAME][0] = addImages(addImages(addImages(addImages(blankImage("wolf_tame", 6, 8), loadImage("wolf_tame", 4, 4, 6, 6), 0, 2, 6, 8), loadImage("wolf_tame", 4, 14, 3, 3), 1.5f, 5, 6, 8), loadImage("wolf_tame", 17, 15, 2, 2), 0, 0, 6, 8), loadImage("wolf_tame", 17, 15, 2, 2), 4, 0, 6, 8);
icons[ZOMBIE][0] = addImages(loadImage("zombie", 8, 8, 8, 8, 64, 64), loadImage("zombie", 40, 8, 8, 8, 64, 64), 0, 0, 8, 8); // height changed. doesn't actually matter, scale is done by checking image width. Just for consistency though
//icons[ZOMBIEVILLAGER][0] = addImages(loadImage("zombie_villager", 8, 40, 8, 10, 64, 64), loadImage("zombie_villager", 26, 34, 2, 3, 64, 64), 3, 7, 8, 10); // pre blank image for protruding nose
icons[ZOMBIEVILLAGER][0] = addImages(addImages(blankImage("zombie_villager", 8, 12, 64, 64), loadImage("zombie_villager", 8, 40, 8, 10, 64, 64), 0, 1, 8, 12), loadImage("zombie_villager", 26, 34, 2, 4, 64, 64), 3, 8, 8, 12);
int oldGenericPlayerRef = imageRef[PLAYER][1];
for (int t = 0; t < icons.length; t++) {
if (imageRef[t][0] != -1)
glah(imageRef[t][0]);
if (imageRef[t][1] != -1)
glah(imageRef[t][1]);
//icons[t]=into128(icons[t]);
float scale = (float)(icons[t][0].getWidth())/(float)sizeBase[t];
icons[t][1] = fillOutline(intoSquare(scaleImage(icons[t][0], 2f/scale)));
icons[t][0] = fillOutline(intoSquare(scaleImage(icons[t][0], 1f/scale)));
if (renderEngine!=null) {
imageRef[t][0]=this.tex(icons[t][0]);
imageRef[t][1]=this.tex(icons[t][1]);
}
else {
imageRef[t][0]=-1;
imageRef[t][1]=-1;
}
}
int newGenericPlayerRef = imageRef[PLAYER][1];
replaceGenericPlayerRefs(oldGenericPlayerRef, newGenericPlayerRef);
armorIcons[CLOTH][0] = loadImage("/armor/", "cloth_1", 8, 8, 8, 8);
armorIcons[CLOTH+1][0] = loadImage("/armor/", "cloth_1", 40, 8, 8, 8);
armorIcons[CLOTH+2][0] = loadImage("/armor/", "cloth_1_b", 8, 8, 8, 8);
armorIcons[CLOTH+3][0] = loadImage("/armor/", "cloth_1_b", 40, 8, 8, 8);
/*
armorIcons[CHAIN][0] = loadImage("/armor/", "chain_1", 8, 8, 8, 8);
armorIcons[CHAIN+1][0] = loadImage("/armor/", "chain_1", 40, 8, 8, 8);
armorIcons[IRON][0] = loadImage("/armor/", "iron_1", 8, 8, 8, 8);
armorIcons[IRON+1][0] = loadImage("/armor/", "iron_1", 40, 8, 8, 8);
armorIcons[GOLD][0] = loadImage("/armor/", "gold_1", 8, 8, 8, 8);
armorIcons[GOLD+1][0] = loadImage("/armor/", "gold_1", 40, 8, 8, 8);
armorIcons[DIAMOND][0] = loadImage("/armor/", "diamond_1", 8, 8, 8, 8);
armorIcons[DIAMOND+1][0] = loadImage("/armor/", "diamond_1", 40, 8, 8, 8);
*/
armorIcons[CHAIN][0] = addImages(loadImage("/armor/", "chain_1", 8, 8, 8, 8), loadImage("/armor/", "chain_1", 40, 8, 8, 8), 0, 0, 8, 8);;
armorIcons[IRON][0] = addImages(loadImage("/armor/", "iron_1", 8, 8, 8, 8), loadImage("/armor/", "iron_1", 40, 8, 8, 8), 0, 0, 8, 8);;
armorIcons[GOLD][0] = addImages(loadImage("/armor/", "gold_1", 8, 8, 8, 8), loadImage("/armor/", "gold_1", 40, 8, 8, 8), 0, 0, 8, 8);;
armorIcons[DIAMOND][0] = addImages(loadImage("/armor/", "diamond_1", 8, 8, 8, 8), loadImage("/armor/", "diamond_1", 40, 8, 8, 8), 0, 0, 8, 8);;
armorIcons[CHAIN+1][0] = icons[BLANK][0];
armorIcons[IRON+1][0] = icons[BLANK][0];
armorIcons[GOLD+1][0] = icons[BLANK][0];
armorIcons[DIAMOND+1][0] = icons[BLANK][0];
for (int t = 0; t < armorIcons.length; t++) {
if (armorImageRef[t][0] != -1)
glah(armorImageRef[t][0]);
if (armorImageRef[t][1] != -1)
glah(armorImageRef[t][1]);
//icons[t]=into128(icons[t]);
float scale = (float)(armorIcons[t][0].getWidth())/8f;
armorIcons[t][1] = fillOutline(intoSquare(scaleImage(armorIcons[t][0], 2f/scale)), true, t);
armorIcons[t][0] = fillOutline(intoSquare(scaleImage(armorIcons[t][0], 1f/scale)), true, t);
if (renderEngine!=null) {
armorImageRef[t][0]=this.tex(armorIcons[t][0]);
armorImageRef[t][1]=this.tex(armorIcons[t][1]);
}
else {
armorImageRef[t][0]=-1;
armorImageRef[t][1]=-1;
}
}
completedLoading = true;
}
catch (Exception e) {
System.out.println("Failed getting mobs " + e.getLocalizedMessage());
}
}
private BufferedImage blankImage(String path, int w, int h) {
return blankImage(path, w, h, 64, 32);
}
private BufferedImage blankImage(String path, int w, int h, int imageWidth, int imageHeight) {
return blankImage(path, w, h, imageWidth, imageHeight, 0, 0, 0, 0);
}
private BufferedImage blankImage(String path, int w, int h, int r, int g, int b, int a) {
return blankImage(path, w, h, 64, 32, r, g, b, a);
}
private BufferedImage blankImage(String path, int w, int h, int imageWidth, int imageHeight, int r, int g, int b, int a) {
try {
String fullPath = "/mob/" + path + ".png";
InputStream is = pack.getResourceAsStream(fullPath);
BufferedImage mobSkin = ImageIO.read(is);
is.close();
BufferedImage temp = new BufferedImage(w * mobSkin.getWidth() / imageWidth, h * mobSkin.getWidth() / imageWidth, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2 = temp.createGraphics();
g2.setColor(new Color(r, g, b, a));
g2.fillRect(0, 0, temp.getWidth(), temp.getHeight());
g2.dispose();
return temp;
}
catch (Exception e) {
System.out.println("Failed getting mob: " + path + " - " + e.getLocalizedMessage());
return null;
}
}
private BufferedImage addCharacter(BufferedImage image, String character) {
Graphics2D g2 = image.createGraphics();
g2.setColor(new Color(0, 0, 0, 255));
g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
g2.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, image.getHeight()));
java.awt.FontMetrics fm = g2.getFontMetrics();
int x = (image.getWidth() - fm.stringWidth("?")) / 2;
int y = (fm.getAscent() + (image.getHeight() - (fm.getAscent() + fm.getDescent())) / 2);
g2.drawString("?", x, y);
g2.dispose();
return image;
}
// load image with the default path (mob)
private BufferedImage loadImage(String name, int x, int y, int w, int h, int imageWidth, int imageHeight) {
return loadImage("/mob/", name, x, y, w, h, imageWidth, imageHeight);
}
// load image with the default dimensions (most common anyway, 64x32 in default)
private BufferedImage loadImage(String path, String name, int x, int y, int w, int h) {
return loadImage(path, name, x, y, w, h, 64, 32);
}
// load image with the default path (mob) and dimensions (most common anyway, 64x32 in default)
private BufferedImage loadImage(String name, int x, int y, int w, int h) {
return loadImage("/mob/", name, x, y, w, h, 64, 32);
}
private BufferedImage loadImage(String path, String name, int x, int y, int w, int h, int imageWidth, int imageHeight) {
try {
String fullPath = path + name + ".png";
InputStream is = pack.getResourceAsStream(fullPath);
BufferedImage mobSkin = ImageIO.read(is);
is.close();
// System.out.println(path + " is type " + mobSkin.getType());
// convert to TYPE_4BYTE_ABGR if it isn't. TYPE_BYTE_INDEXED break all over
// actually do below in case we get passed something in a bad format
return loadImage(mobSkin, x, y, w, h, imageWidth, imageHeight);
}
catch (Exception e) {
System.out.println("Failed getting mob: " + name + " - " + e.getLocalizedMessage());
return null;
}
}
// load image with the default dimensions (most common anyway, 64x32 in default)
private BufferedImage loadImage(BufferedImage mobSkin, int x, int y, int w, int h) {
return loadImage(mobSkin, x, y, w, h, 64, 32);
}
// load bits from an already loaded bufferedImage (like the image RenderEngine returns for a multiplayer skin)
private BufferedImage loadImage(BufferedImage mobSkin, int x, int y, int w, int h, int imageWidth, int imageHeight) {
// make sure format is OK
if (!(mobSkin.getType() == BufferedImage.TYPE_4BYTE_ABGR)) {
BufferedImage temp = new BufferedImage(mobSkin.getWidth(), mobSkin.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2 = temp.createGraphics();
g2.drawImage(mobSkin, 0, 0, mobSkin.getWidth(), mobSkin.getHeight(), null);
g2.dispose();
mobSkin = temp;
}
float scale = mobSkin.getWidth(null) / imageWidth; // is float for dealing with lower res texture packs
BufferedImage base = mobSkin.getSubimage((int)(x*scale), (int)(y*scale), (int)(w*scale), (int)(h*scale));
// if (scale != 1) // scale down hidef (or up lodef? haha) // scale at the end, after it's all added together
// base = scaleImage (base, 1/scale);
return base;
}
private BufferedImage addImages(BufferedImage base, BufferedImage overlay, float x, int y, int baseWidth, int baseHeight) {
int scale = base.getWidth()/baseWidth;
Graphics gfx = base.getGraphics();
gfx.drawImage(overlay, (int)(x*scale), y*scale, null); // float for x here simply allows us to center the wolf nose in double and higher resolution packs (witch hat too)
gfx.dispose();
return base;
}
private BufferedImage scaleImage(BufferedImage image, float scaleBy) {
BufferedImage tmp = new BufferedImage((int)(image.getWidth()*scaleBy), (int)(image.getHeight()*scaleBy), image.getType());
Graphics2D g2 = tmp.createGraphics();
//g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2.drawImage(image, 0, 0, (int)(image.getWidth()*scaleBy), (int)(image.getHeight()*scaleBy), null);
g2.dispose();
image = tmp;
return image;
}
private BufferedImage flipHorizontal(BufferedImage image) {
AffineTransform tx = AffineTransform.getScaleInstance(-1, 1);
tx.translate(-image.getWidth(null), 0);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
return op.filter(image, null);
}
private BufferedImage into128(BufferedImage base) {
BufferedImage frame = new BufferedImage(128, 128, base.getType());
Graphics gfx = frame.getGraphics();
gfx.drawImage(base, 64-base.getWidth()/2, 64-base.getHeight()/2, base.getWidth(), base.getHeight(), null);
gfx.dispose();
return frame;
}
private BufferedImage intoSquare(BufferedImage base) {
int dim = Math.max(base.getWidth(), base.getHeight());
int t = 0;
while (Math.pow(2, t) <= dim)
t++;
int size = (int)Math.pow(2, t);
BufferedImage frame = new BufferedImage(size, size, base.getType());
Graphics gfx = frame.getGraphics();
gfx.drawImage(base, (size-base.getWidth())/2, (size-base.getHeight())/2, base.getWidth(), base.getHeight(), null);
gfx.dispose();
return frame;
}
private BufferedImage fillOutline(BufferedImage image) {
return fillOutline(image, false, 0);
}
private BufferedImage fillOutline(BufferedImage image, boolean armor, int entry) {
if (this.outlines && entry != CLOTH+2 && entry != CLOTH+3)
image = fillOutline(image, true, armor);
image = fillOutline(image, false, armor);
return image;
}
private BufferedImage fillOutline(BufferedImage image, boolean solid, boolean armor) {
BufferedImage temp = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
java.awt.Graphics gfx = temp.getGraphics();
gfx.drawImage(image, 0, 0, null);
gfx.dispose();
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
for (int t = 0; t < image.getWidth(); t++) {
for (int s = 0; s < image.getHeight(); s++) {
int color = image.getRGB(s, t);
if ((color >> 24 & 255) == 0) { // clear pixel
int newColor = getNonTransparentPixel(s, t, image);
if (newColor != -420) {
if (solid) {
if (!armor || t <= imageWidth/4 || t >= imageWidth-1-imageWidth/4 || s <= imageHeight/4 || s >= imageHeight-1-imageHeight/4)
newColor = 255 << 24;
else
newColor = 0 << 24;
}
else {
int alpha = (newColor >> 24 & 255);
int red = (newColor >> 16 & 255);
int green = (newColor >> 8 & 255);
int blue = (newColor >> 0 & 255);
newColor = (0) << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255;
}
temp.setRGB(s, t, newColor);
}
}
}
}
return temp;
}
/*// optional version to get more than one pixel out. not needed if we run it after scaling
private BufferedImage fillOutline(BufferedImage image) {
BufferedImage orig = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
Graphics gfx = orig.getGraphics();
gfx.drawImage(image, 0, 0, null);
gfx.dispose();
for (int iter = 0; iter < 6; iter++) {
BufferedImage temp = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
gfx = temp.getGraphics();
gfx.drawImage(image, 0, 0, null);
gfx.dispose();
for (int t = 0; t < image.getWidth(); t++) {
for (int s = 0; s < image.getHeight(); s++) {
int color = image.getRGB(s, t);
if ((color >> 24 & 255) == 0) { // clear pixel
int newColor = getNonTransparentPixel(s, t, temp);
if (newColor != -1) {
// int alpha = (newColor >> 24 & 255);
// int red = (newColor >> 16 & 255);
// int green = (newColor >> 8 & 255);
// int blue = (newColor >> 0 & 255);
// newColor = (255) << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255;
image.setRGB(s, t, newColor);
}
}
}
}
}
for (int t = 0; t < image.getWidth(); t++) {
for (int s = 0; s < image.getHeight(); s++) {
int color = image.getRGB(s, t);
int origColor = orig.getRGB(s, t);
int alpha = (origColor >> 24 & 255);
int red = (color >> 16 & 255);
int green = (color >> 8 & 255);
int blue = (color >> 0 & 255);
color = (alpha & 255) << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255;
image.setRGB(s, t, color);
}
}
return image;
}*/
private int getNonTransparentPixel(int x, int y, BufferedImage image) {
int color;
if (x > 0) {
color = image.getRGB(x-1, y);
if ((color >> 24 & 255) > 50)
return color;
}
if (x < image.getWidth()-1) {
color = image.getRGB(x+1, y);
if ((color >> 24 & 255) > 50)
return color;
}
if (y > 0) {
color = image.getRGB(x, y-1);
if ((color >> 24 & 255) > 50)
return color;
}
if (y < image.getHeight()-1) {
color = image.getRGB(x, y+1);
if ((color >> 24 & 255) > 50)
return color;
}
if (x > 0 && y > 0) {
color = image.getRGB(x-1, y-1);
if ((color >> 24 & 255) > 50)
return color;
}
if (x > 0 && y < image.getHeight()-1) {
color = image.getRGB(x-1, y+1);
if ((color >> 24 & 255) > 50)
return color;
}
if (x < image.getWidth()-1 && y > 0) {
color = image.getRGB(x+1, y-1);
if ((color >> 24 & 255) > 50)
return color;
}
if (x < image.getWidth()-1 && y < image.getHeight()-1) {
color = image.getRGB(x+1, y+1);
if ((color >> 24 & 255) > 50)
return color;
}
return -420;
}
private void replaceGenericPlayerRefs(int oldRef, int newRef) {
for(Map.Entry<String,Integer> entry : mpContacts.entrySet()) {
if (entry.getValue().equals(oldRef))
entry.setValue(newRef);
}
}
public void setTexturePack(ITexturePack pack) {
this.pack = pack;
}
public void drawPre()
{
tesselator.startDrawingQuads();
}
public void drawPost()
{
tesselator.draw();
}
public void glah(int g)
{
renderEngine.deleteTexture(g);
}
public void ldrawthree(double a, double b, double c, double d, double e)
{
tesselator.addVertexWithUV(a, b, c, d, e);
}
private void setMap(int x, int y) {
// ldrawthree(paramInt1 - 64.0D, 64.0D + 5.0D, 1.0D, 0.0D, 1.0D);
// ldrawthree(paramInt1, 64.0D + 5.0D, 1.0D, 1.0D, 1.0D);
// ldrawthree(paramInt1, 5.0D, 1.0D, 1.0D, 0.0D);
// ldrawthree(paramInt1 - 64.0D, 5.0D, 1.0D, 0.0D, 0.0D);
setMap(x, y, 128); // do this with default image size of 128 (that everything was before I decided to stop padding 16px and 8px images out to 128)
}
private void setMap(int x, int y, int imageSize) {
float scale = imageSize/4f; // 128 image is drawn from center - 32 to center + 32, as in the old setMap
// 16 image is drawn from center - 4 to center + 4, quarter the size
ldrawthree(minimap.scScale*(x-scale), minimap.scScale*(y+scale), 1.0D, 0.0D, 1.0D);
ldrawthree(minimap.scScale*(x+scale), minimap.scScale*(y+scale), 1.0D, 1.0D, 1.0D);
ldrawthree(minimap.scScale*(x+scale), minimap.scScale*(y-scale), 1.0D, 1.0D, 0.0D);
ldrawthree(minimap.scScale*(x-scale), minimap.scScale*(y-scale), 1.0D, 0.0D, 0.0D);
}
private int tex(BufferedImage paramImg) {
return this.renderEngine.allocateAndSetupTexture(paramImg);
}
private int img(String paramStr) { // returns index of texturemap(name) aka glBoundTexture. If there isn't one, it glBindTexture's it in setupTexture
return this.renderEngine.getTexture(paramStr);
}
private void disp(int paramInt) {
this.renderEngine.bindTexture(paramInt); // this func glBindTexture's GL_TEXTURE_2D, int paramInt
}
public void OnTickInGame(Minecraft mc) {
if(game==null) game = mc;
if(fontRenderer==null) fontRenderer = this.game.fontRenderer;
if(renderEngine==null && completedLoading) {
renderEngine = this.game.renderEngine;
if (renderEngine!=null) { // once we get a render engine (and only once) allocate the images
for (int t = 0; t < icons.length; t++) {
imageRef[t][0]=this.tex(icons[t][0]);
imageRef[t][1]=this.tex(icons[t][1]);
}
for (int t = 0; t < armorIcons.length; t++) {
armorImageRef[t][0]=this.tex(armorIcons[t][0]);
armorImageRef[t][1]=this.tex(armorIcons[t][1]);
}
}
}
if ((this.game.currentScreen instanceof GuiIngameMenu) || (Keyboard.isKeyDown(61)) /*|| (this.game.thePlayer.dimension==-1)*/)
this.enabled=false;
else this.enabled=true;
//ScaledResolution scSize = new ScaledResolution(game.gameSettings, game.displayWidth, game.displayHeight);
//int scWidth = scSize.getScaledWidth();
//int scHeight = scSize.getScaledHeight();
//int guiScale = scSize.getScaleFactor();
int guiScale = 1;
while (game.displayWidth / (guiScale + 1) >= 320 && game.displayHeight / (guiScale + 1) >= 240)
{
++guiScale;
}
/*// needed if this is standalone
double scaledWidthD = (double)game.displayWidth / (double)guiScale;
double scaledHeightD = (double)game.displayHeight / (double)guiScale;
int scWidth = MathHelper.ceiling_double_int(scaledWidthD);
int scHeight = MathHelper.ceiling_double_int(scaledHeightD);
int xMap = 0;
int yMap = 0;
if (this.minimap.mapCorner == 0 || this.minimap.mapCorner == 3)
xMap = 37;
else
xMap = scWidth - 37;
if (this.minimap.mapCorner == 0 || this.minimap.mapCorner == 1) {
yMap = 37;
}
else {
yMap = scHeight - 37;
} */
guiScale = (guiScale>=4)?1:0;
this.direction = this.game.thePlayer.rotationYaw + 180;
if (this.direction >= 360.0f)
while (this.direction >= 360.0f)
this.direction -= 360.0f;
if (this.direction < 0.0f) {
while (this.direction < 0.0f)
this.direction += 360.0f;
}
if ((!this.error.equals("")) && (this.ztimer == 0)) this.ztimer = 500;
if (this.ztimer > 0) this.ztimer -= 1;
if ((this.ztimer == 0) && (!this.error.equals(""))) this.error = "";
if (this.enabled && !this.hide) {
// don't recalculate mobs all the time. doesn't seem to affect FPS, whatev
if (this.timer>95) { // not multiple of 100 so doesn't happen at same time as map render
calculateMobs();
timer = 0;
}
timer++;
if (completedLoading) {
double scaledWidthD = (double)game.displayWidth;// / (double)minimap.scScale;
double scaledHeightD = (double)game.displayHeight;// / (double)minimap.scScale;
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glOrtho(0.0D, scaledWidthD, scaledHeightD, 0.0D, 1000.0D, 3000.0D);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDepthMask(false);
renderMapMobs(this.minimap.mapX, this.minimap.mapY, guiScale);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPopMatrix();
}
if (ztimer > 0)
this.write(this.error, 20, 20, 0xffffff);
// if (ztimer > 0)
// this.write(this.error, 20, 20, 0xffffff);
// if (this.iMenu>0) showMenu(scWidth, scHeight);
/*GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_DEPTH_TEST);*/
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
} // end method OnTickInGame
private void write(String paramStr, int paramInt1, int paramInt2, int paramInt3) {
this.fontRenderer.drawStringWithShadow(paramStr, paramInt1, paramInt2, paramInt3);
}
private int xCoord() {
return (int)(this.game.thePlayer.posX < 0.0D ? this.game.thePlayer.posX - 1 : this.game.thePlayer.posX);
}
private int zCoord() {
return (int)(this.game.thePlayer.posZ < 0.0D ? this.game.thePlayer.posZ - 1 : this.game.thePlayer.posZ);
}
private int yCoord() {
return (int)this.game.thePlayer.posY - 1; // player is one higher than other entities, even other players (WTF)
}
public double xCoordDouble() {
return (this.game.thePlayer.posX < 0.0D ? this.game.thePlayer.posX - 1 : this.game.thePlayer.posX);
}
public double zCoordDouble() {
return (this.game.thePlayer.posZ < 0.0D ? this.game.thePlayer.posZ - 1 : this.game.thePlayer.posZ);
}
public void calculateMobs () {
contacts.clear();
double max = (Math.pow(2,minimap.lZoom) * 16 - 0);
java.util.List entities = this.game.theWorld.getLoadedEntityList();
for(int j = 0; j < entities.size(); j++) {
Entity entity = (Entity)entities.get(j);
try {
if( (showHostiles && isHostile(entity)) || (showPlayers && isPlayer(entity)) || (showNeutrals && isNeutral(entity)) ) {
int wayX = this.xCoord() - (int)(entity.posX);
int wayZ = this.zCoord() - (int)(entity.posZ);
int wayY = this.yCoord() - (int)(entity.posY);
// sqrt version
//double hypot = Math.sqrt((wayX*wayX)+(wayZ*wayZ)+(wayY*wayY));
//hypot = hypot/(Math.pow(2,minimap.lZoom)/2);
//if (hypot < 31.0D) {
// no sqrt version
double hypot = ((wayX*wayX)+(wayZ*wayZ)+(wayY*wayY));
hypot = hypot/((Math.pow(2,minimap.lZoom)/2)*(Math.pow(2,minimap.lZoom)/2));
if (hypot < 961.0D /*31.0D squared - saves on sqrt ops*/) {
//System.out.println("player: " + (int)this.game.thePlayer.posY + " mob: " + (int)(entity.posY));
Contact contact;
if (isPlayer(entity))
contact = handleMPplayer(entity);
else
contact = new Contact(entity, /*(int)*/(entity.posX), /*(int)*/(entity.posZ), (int)(entity.posY), getContactType(entity));
contact.angle = (float)Math.toDegrees(Math.atan2(wayX, wayZ));
// pow2,0 is 1. /2 is 1/2. so if hypot max 16/.5 < 31. pow2,1 is 2. /2 is 1. hypot max 32/1 < 31. pow2,2 is 4. /2 is 2. hypot max 64/2 < 31
contact.distance = Math.sqrt((wayX*wayX)+(wayZ*wayZ))/(Math.pow(2,minimap.lZoom)/2);
double adjustedDiff = max - Math.max((Math.abs(wayY) - 0), 0);
contact.brightness = (float)Math.max(adjustedDiff / max, 0);
contact.brightness *= contact.brightness;
contacts.add(contact);
//contacts.add(new Contact((int)(entity.posX), (int)(entity.posZ), (int)(entity.posY), getContactType(entity)));
} // end if valid contact
} // end if should be displayed
} catch (Exception classNotFoundException) {
this.error = "class not found";
}
} // end for loop contacts
Collections.sort(contacts, new java.util.Comparator<Contact>() {
public int compare(Contact contact1, Contact contact2) {
return contact1.y - contact2.y;
}
});
this.lastX = this.xCoordDouble();
this.lastZ = this.zCoordDouble();
this.lastY = this.yCoord();
this.lastZoom = this.minimap.lZoom;
}
private Contact handleMPplayer(Entity entity) {
String playerName = scrubCodes(((EntityOtherPlayerMP)entity).username);
String skinURL = ((EntityOtherPlayerMP)entity).skinUrl;
Contact mpContact = new Contact(entity, /*(int)*/(entity.posX), /*(int)*/(entity.posZ), (int)(entity.posY), getContactType(entity));
mpContact.setName(playerName);
Integer ref = mpContacts.get(playerName+0); // don't load if already done
//System.out.println("***********CHECKING " + ref);
if (ref == null) { // if we haven't encountered player yet, try to get MP skin
ThreadDownloadImageData imageData = this.renderEngine.obtainImageData(skinURL, new ImageBufferDownload());
if (imageData == null || imageData.image == null) { // failed to get
BufferedImage skinImage = loadSkin(playerName); // try to load icon saved to disk
if (skinImage != null) { // if there is one, 128it and use
//skinImage = intoSquare(skinImage); // actally square it. actually don't bother should all be 8x8
BufferedImage skinImageSmall = fillOutline(intoSquare(skinImage)); // add space around edge and make ready for filtering
BufferedImage skinImageLarge = fillOutline(intoSquare(scaleImage(skinImage, 2)));
int imageRef = this.tex(skinImageSmall);
mpContacts.put(playerName+0, imageRef);
//System.out.println("Loading " + playerName + " from disk: NEW REF " + imageRef);
imageRef = this.tex(skinImageLarge);
mpContacts.put(playerName+1, imageRef);
}
else { // else default
mpContacts.put(playerName, -1); // so make image ref for this player the standard player icon. Try for hidef (if it's the same as lodef, well, lodef will show)
//System.out.println("***********DEFAULTING " + imageRef[PLAYER][1]);
}
}
else { // we got a downloaded image
BufferedImage skinImage = imageData.image;
//skinImage = into128(addImages(loadImage(skinImage, 8, 8, 8, 8), loadImage(skinImage, 40, 8, 8, 8), 0, 0));
skinImage = addImages(loadImage(skinImage, 8, 8, 8, 8), loadImage(skinImage, 40, 8, 8, 8), 0, 0, 8, 8);
saveSkin(skinImage, playerName); // save for future use when skin server is down
BufferedImage skinImageSmall = fillOutline(intoSquare(skinImage)); // add space around edge and make ready for filtering
BufferedImage skinImageLarge = fillOutline(intoSquare(scaleImage(skinImage, 2)));
int imageRef = this.tex(skinImageSmall);
mpContacts.put(playerName+0, imageRef);
//System.out.println("***********NEW REF " + imageRef);
imageRef = this.tex(skinImageLarge);
mpContacts.put(playerName+1, imageRef);
}
if (imageData != null)
this.renderEngine.releaseImageData(skinURL); // if it was not null, the reference was incremented. Decrement it!
}
if (showHelmets) {
ItemStack stack = ((EntityOtherPlayerMP)entity).getCurrentArmor(3);
Item helmet = null;
if (stack != null && stack.stackSize > 0)
helmet = stack.getItem();
if (helmet != null && helmet instanceof ItemArmor) {
ItemArmor helmetArmor = (ItemArmor)helmet;
EnumArmorMaterial material = helmetArmor.getArmorMaterial();
mpContact.setArmor(this.getArmorType(material));
if (mpContact.armorValue == CLOTH)
mpContact.setArmorColor(helmetArmor.getColorFromItemStack(((EntityOtherPlayerMP)entity).getCurrentArmor(3), 0));
}
}
return mpContact;
}
private String scrubCodes(String string) {
string = string.replaceAll("(§.)", "");
return string;
}
private void saveSkin(BufferedImage skinImage, String playerName) {
try {
String path = "minecraft/mods/zan/" + minimap.getServerName();
File outFile = new File(Minecraft.getAppDir(path), playerName + ".png");
outFile.createNewFile();
ImageIO.write(skinImage, "png", outFile);
}
catch (Exception e) {
System.out.println("playername: " + playerName + " - error saving skin image: " + e.getLocalizedMessage());
}
}
private BufferedImage loadSkin(String playerName) {
try {
String path = "minecraft/mods/zan/" + minimap.getServerName();
File inFile = new File(Minecraft.getAppDir(path), playerName + ".png");
java.awt.Image icon = ImageIO.read(inFile);
BufferedImage iconBuffered = new BufferedImage(icon.getWidth(null), icon.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics gfx = iconBuffered.createGraphics();
// Paint the image onto the buffered image
gfx.drawImage(icon, 0, 0, null);
gfx.dispose();
return iconBuffered;
}
catch (Exception e) {
System.out.println("playername: " + playerName + " - error loading skin image: " + e.getLocalizedMessage());
return null;
}
}
private int getContactType(Entity entity) {
if (entity instanceof EntityBat)
return BAT;
else if (entity instanceof EntityBlaze)
return BLAZE;
else if (entity instanceof EntityCaveSpider)
return CAVESPIDER;
else if (entity instanceof EntityChicken)
return CHICKEN;
else if (entity instanceof EntityMooshroom) // out of order, so we don't get cow for mooshroom (it's a subcow apparently)
return MOOSHROOM;
else if (entity instanceof EntityCow)
return COW;
else if (entity instanceof EntityCreeper)