Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3// CraftBukkit start
4
5import org.bukkit.craftbukkit.entity.CraftPlayer;
6import org.bukkit.craftbukkit.map.RenderData;
7import org.bukkit.map.MapCursor;
8// CraftBukkit end
9
10public class WorldMapHumanTracker {
11
12 public final EntityHuman trackee;
13 public int[] b;
14 public int[] c;
15 private int e;
16 private int f;
17 private byte[] g;
18
19 final WorldMap d;
20
21 public WorldMapHumanTracker(WorldMap worldmap, EntityHuman entityhuman) {
22 this.d = worldmap;
23 this.b = new int[128];
24 this.c = new int[128];
25 this.e = 0;
26 this.f = 0;
27 this.trackee = entityhuman;
28
29 for (int i = 0; i < this.b.length; ++i) {
30 this.b[i] = 0;
31 this.c[i] = 127;
32 }
33 }
34
35 public byte[] a(ItemStack itemstack) {
36 int i;
37 int j;
38
39 RenderData render = this.d.mapView.render((CraftPlayer) trackee.getBukkitEntity()); // CraftBukkit
40
41 if (--this.f < 0) {
42 this.f = 4;
43 byte[] abyte = new byte[render.cursors.size() * 3 + 1]; // CraftBukkit
44
45 abyte[0] = 1;
46
47 // CraftBukkit start
48 for (i = 0; i < render.cursors.size(); ++i) {
49 MapCursor cursor = render.cursors.get(i);
50 if (!cursor.isVisible()) continue;
51
52 byte value = (byte) (((cursor.getRawType() == 0 || cursor.getDirection() < 8 ? cursor.getDirection() : cursor.getDirection() - 1) & 15) * 16);
53 abyte[i * 3 + 1] = (byte) (value | (cursor.getRawType() != 0 && value < 0 ? 16 - cursor.getRawType() : cursor.getRawType()));
54 abyte[i * 3 + 2] = (byte) cursor.getX();
55 abyte[i * 3 + 3] = (byte) cursor.getY();
56 }
57 // CraftBukkit end
58
59 boolean flag = true;
60
61 if (this.g != null && this.g.length == abyte.length) {
62 for (j = 0; j < abyte.length; ++j) {
63 if (abyte[j] != this.g[j]) {
64 flag = false;
65 break;
66 }
67 }
68 } else {
69 flag = false;
70 }
71
72 if (!flag) {
73 this.g = abyte;
74 return abyte;
75 }
76 }
77
78 for (int k = 0; k < 10; ++k) {
79 i = this.e * 11 % 128;
80 ++this.e;
81 if (this.b[i] >= 0) {
82 j = this.c[i] - this.b[i] + 1;
83 int l = this.b[i];
84 byte[] abyte1 = new byte[j + 3];
85
86 abyte1[0] = 0;
87 abyte1[1] = (byte) i;
88 abyte1[2] = (byte) l;
89
90 for (int i1 = 0; i1 < abyte1.length - 3; ++i1) {
91 abyte1[i1 + 3] = render.buffer[(i1 + l) * 128 + i]; // CraftBukkit
92 }
93
94 this.c[i] = -1;
95 this.b[i] = -1;
96 return abyte1;
97 }
98 }
99
100 return null;
101 }
102}