Commits
Dinnerbone authored b3c6a7953d3 Merge
1 + | package net.minecraft.server; |
2 + | |
3 + | |
4 + | import java.util.*; |
5 + | |
6 + | import org.bukkit.Location; |
7 + | import org.bukkit.craftbukkit.CraftServer; |
8 + | import org.bukkit.event.Event; |
9 + | import org.bukkit.event.player.PlayerMoveEvent; |
10 + | |
11 + | |
12 + | public class EntityPlayerMP extends EntityPlayer |
13 + | implements ICrafting { |
14 + | |
15 + | public NetServerHandler a; |
16 + | public MinecraftServer b; |
17 + | public ItemInWorldManager c; |
18 + | public double d; |
19 + | public double e; |
20 + | public List f; |
21 + | public Set aj; |
22 + | public double ak; |
23 + | public boolean al; |
24 + | private int bE; |
25 + | private int bF; |
26 + | private int bG[] = { |
27 + | -1, -1, -1, -1, -1 |
28 + | }; |
29 + | private int bH; |
30 + | public boolean am; |
31 + | private CraftServer server; // Craftbukkit |
32 + | private Location oldLocation = null; // Craftbukkit |
33 + | |
34 + | public EntityPlayerMP(MinecraftServer minecraftserver, World world, String s1, ItemInWorldManager iteminworldmanager) { |
35 + | super(world); |
36 + | f = new LinkedList(); |
37 + | aj = new HashSet(); |
38 + | al = false; |
39 + | bE = 0xfa0a1f01; |
40 + | bF = 60; |
41 + | bH = 0; |
42 + | int i = world.m; |
43 + | int j = world.o; |
44 + | int l = world.n; |
45 + | |
46 + | |
47 + | if (!world.q.e) { |
48 + | i += W.nextInt(20) - 10; |
49 + | l = world.e(i, j); |
50 + | j += W.nextInt(20) - 10; |
51 + | } |
52 + | c((double) i + 0.5D, l, (double) j + 0.5D, 0.0F, 0.0F); |
53 + | b = minecraftserver; |
54 + | S = 0.0F; |
55 + | iteminworldmanager.a = this; |
56 + | aw = s1; |
57 + | c = iteminworldmanager; |
58 + | H = 0.0F; |
59 + | |
60 + | server = minecraftserver.server; // Craftbukkit |
61 + | oldLocation = new Location(server.getWorld(b.e), 0,0,-1); // Craftbukkit |
62 + | } |
63 + | |
64 + | /** |
65 + | * Craftbukkit: Overloaded version of b(double,double,double,float) |
66 + | * |
67 + | * Enables monitoring of PLAYER_MOVE events. |
68 + | */ |
69 + | public void b(double x, double y, double z, float rotation, float pitch) { |
70 + | super.b(x,y,z,pitch,rotation); |
71 + | |
72 + | // Only send an event if player position has changed. |
73 + | if (x == oldLocation.getX() && y == oldLocation.getY() && z == oldLocation.getZ()) |
74 + | return; |
75 + | |
76 + | Location newLocation = new Location(server.getWorld(b.e),x,y,z); |
77 + | PlayerMoveEvent pm = new PlayerMoveEvent(Event.Type.PLAYER_MOVE, server.getPlayer(this), |
78 + | oldLocation, newLocation); |
79 + | |
80 + | server.getPluginManager().callEvent(pm); |
81 + | oldLocation = newLocation; |
82 + | } |
83 + | |
84 + | public void k() { |
85 + | ap.a((ICrafting)this); |
86 + | } |
87 + | |
88 + | public int[] E() { |
89 + | return bG; |
90 + | } |
91 + | |
92 + | public void b_() { |
93 + | bF--; |
94 + | ap.a(); |
95 + | for (int i = 0; i < 5; i++) { |
96 + | int j = a(i); |
97 + | |
98 + | if (j != bG[i]) { |
99 + | b.k.a(this, new Packet5PlayerInventory(g, i, j)); |
100 + | bG[i] = j; |
101 + | } |
102 + | } |
103 + | |
104 + | } |
105 + | |
106 + | public int a(int i) { |
107 + | if (i == 0) { |
108 + | return c(an.e()); |
109 + | } else { |
110 + | return c(an.b[i - 1]); |
111 + | } |
112 + | } |
113 + | |
114 + | private int c(ItemStack itemstack) { |
115 + | if (itemstack == null) { |
116 + | return -1; |
117 + | } else { |
118 + | return itemstack.c; |
119 + | } |
120 + | } |
121 + | |
122 + | public void f(Entity entity) { |
123 + | an.h(); |
124 + | } |
125 + | |
126 + | public boolean a(Entity entity, int i) { |
127 + | if (bF > 0) { |
128 + | return false; |
129 + | } |
130 + | if (!b.n) { |
131 + | if (entity instanceof EntityPlayer) { |
132 + | return false; |
133 + | } |
134 + | if (entity instanceof EntityArrow) { |
135 + | EntityArrow entityarrow = (EntityArrow) entity; |
136 + | |
137 + | if (entityarrow.b instanceof EntityPlayer) { |
138 + | return false; |
139 + | } |
140 + | } |
141 + | } |
142 + | return super.a(entity, i); |
143 + | } |
144 + | |
145 + | public void c(int i) { |
146 + | super.c(i); |
147 + | } |
148 + | |
149 + | public void F() { |
150 + | super.b_(); |
151 + | ChunkCoordIntPair chunkcoordintpair = null; |
152 + | double d1 = 0.0D; |
153 + | |
154 + | for (int i = 0; i < f.size(); i++) { |
155 + | ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) f.get(i); |
156 + | double d2 = chunkcoordintpair1.a(this); |
157 + | |
158 + | if (i == 0 || d2 < d1) { |
159 + | chunkcoordintpair = chunkcoordintpair1; |
160 + | d1 = chunkcoordintpair1.a(this); |
161 + | } |
162 + | } |
163 + | |
164 + | if (chunkcoordintpair != null) { |
165 + | boolean flag = false; |
166 + | |
167 + | if (d1 < 1024D) { |
168 + | flag = true; |
169 + | } |
170 + | if (a.b() < 2) { |
171 + | flag = true; |
172 + | } |
173 + | if (flag) { |
174 + | f.remove(chunkcoordintpair); |
175 + | a.b(new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, b.e)); |
176 + | List list = b.e.d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16); |
177 + | |
178 + | for (int j = 0; j < list.size(); j++) { |
179 + | a((TileEntity) list.get(j)); |
180 + | } |
181 + | |
182 + | } |
183 + | } |
184 + | if (ba != bE) { |
185 + | a.b(new Packet8(ba)); |
186 + | bE = ba; |
187 + | } |
188 + | } |
189 + | |
190 + | private void a(TileEntity tileentity) { |
191 + | if (tileentity != null) { |
192 + | Packet packet = tileentity.f(); |
193 + | |
194 + | if (packet != null) { |
195 + | a.b(packet); |
196 + | } |
197 + | } |
198 + | } |
199 + | |
200 + | public void G() { |
201 + | s = t = u = 0.0D; |
202 + | bB = false; |
203 + | super.G(); |
204 + | } |
205 + | |
206 + | public void c(Entity entity, int i) { |
207 + | if (!entity.G) { |
208 + | if (entity instanceof EntityItem) { |
209 + | b.k.a(entity, new Packet22Collect(entity.g, g)); |
210 + | } |
211 + | if (entity instanceof EntityArrow) { |
212 + | b.k.a(entity, new Packet22Collect(entity.g, g)); |
213 + | } |
214 + | } |
215 + | super.c(entity, i); |
216 + | ap.a(); |
217 + | } |
218 + | |
219 + | public void H() { |
220 + | if (!au) { |
221 + | av = -1; |
222 + | au = true; |
223 + | b.k.a(this, new Packet18ArmAnimation(this, 1)); |
224 + | } |
225 + | } |
226 + | |
227 + | public float s() { |
228 + | return 1.62F; |
229 + | } |
230 + | |
231 + | public void e(Entity entity) { |
232 + | super.e(entity); |
233 + | a.b(new Packet39(this, k)); |
234 + | a.a(p, q, r, v, w); |
235 + | } |
236 + | |
237 + | protected void a(double d1, boolean flag) {} |
238 + | |
239 + | public void b(double d1, boolean flag) { |
240 + | super.a(d1, flag); |
241 + | } |
242 + | |
243 + | public boolean p() { |
244 + | return al; |
245 + | } |
246 + | |
247 + | private void R() { |
248 + | bH = bH % 100 + 1; |
249 + | } |
250 + | |
251 + | public void a(int i, int j, int l) { |
252 + | R(); |
253 + | a.b(new Packet100(bH, 1, "Crafting", 9)); |
254 + | ap = new CraftingInventoryWorkbenchCB(an, this.l, i, j, l); |
255 + | ap.f = bH; |
256 + | ap.a((ICrafting)this); |
257 + | } |
258 + | |
259 + | public void a(IInventory iinventory) { |
260 + | R(); |
261 + | a.b(new Packet100(bH, 0, iinventory.b(), iinventory.a())); |
262 + | ap = new CraftingInventoryChestCB(an, iinventory); |
263 + | ap.f = bH; |
264 + | ap.a((ICrafting)this); |
265 + | } |
266 + | |
267 + | public void a(TileEntityFurnace tileentityfurnace) { |
268 + | R(); |
269 + | a.b(new Packet100(bH, 2, tileentityfurnace.b(), tileentityfurnace.a())); |
270 + | ap = new CraftingInventoryFurnaceCB(an, tileentityfurnace); |
271 + | ap.f = bH; |
272 + | ap.a((ICrafting)this); |
273 + | } |
274 + | |
275 + | public void a(CraftingInventoryCB craftinginventorycb, int i, ItemStack itemstack) { |
276 + | if (craftinginventorycb.a(i) instanceof SlotCrafting) { |
277 + | return; |
278 + | } |
279 + | if (am) { |
280 + | return; |
281 + | } else { |
282 + | a.b(new Packet103(craftinginventorycb.f, i, itemstack)); |
283 + | return; |
284 + | } |
285 + | } |
286 + | |
287 + | public void a(CraftingInventoryCB craftinginventorycb, List list) { |
288 + | a.b(new Packet104(craftinginventorycb.f, list)); |
289 + | a.b(new Packet103(-1, -1, an.i())); |
290 + | } |
291 + | |
292 + | public void a(CraftingInventoryCB craftinginventorycb, int i, int j) { |
293 + | a.b(new Packet105(craftinginventorycb.f, i, j)); |
294 + | } |
295 + | |
296 + | public void a(ItemStack itemstack) {} |
297 + | |
298 + | public void I() { |
299 + | a.b(new Packet101(ap.f)); |
300 + | K(); |
301 + | } |
302 + | |
303 + | public void J() { |
304 + | if (am) { |
305 + | return; |
306 + | } else { |
307 + | a.b(new Packet103(-1, -1, an.i())); |
308 + | return; |
309 + | } |
310 + | } |
311 + | |
312 + | public void K() { |
313 + | ap.a((ICrafting)this); |
314 + | ap = ao; |
315 + | } |
316 + | } |