Commits
md_5 authored fafcfd7529e
191 191 | } catch (Throwable throwable) { |
192 192 | |
193 193 | this.appendEntityCrashDetails(crashreportsystemdetails); |
194 194 | throw new ReportedException(crashreport); |
195 195 | } |
196 196 | + */ |
197 197 | + // CraftBukkit end |
198 198 | |
199 199 | boolean flag2 = this.ai(); |
200 200 | |
201 - | |
202 - | this.burn(1); |
201 + | |
203 202 | if (!flag2) { |
204 203 | ++this.fireTicks; |
205 - | - if (this.fireTicks == 0) { |
206 - | + // CraftBukkit start - Not on fire yet |
207 - | + if (this.fireTicks <= 0) { // Only throw events on the first combust, otherwise it spams |
204 + | if (this.fireTicks == 0) { |
205 + | - this.setOnFire(8); |
206 + | + // CraftBukkit start |
208 207 | + EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(null, getBukkitEntity(), 8); |
209 208 | + world.getServer().getPluginManager().callEvent(event); |
210 209 | + |
211 210 | + if (!event.isCancelled()) { |
212 - | + setOnFire(event.getDuration()); |
211 + | + this.setOnFire(event.getDuration()); |
213 212 | + } |
214 - | + } else { |
215 213 | + // CraftBukkit end |
216 - | this.setOnFire(8); |
217 214 | } |
218 215 | } |
219 - | |
216 + | } else if (this.fireTicks <= 0) { |
217 + | |
220 218 | return null; |
221 219 | } |
222 220 | |
223 221 | - protected void burn(int i) { |
224 222 | + protected void burn(float i) { // CraftBukkit - int -> float |
225 223 | if (!this.fireProof) { |
226 224 | this.damageEntity(DamageSource.FIRE, (float) i); |
227 225 | } |
228 - | |
226 + | |
229 227 | } |
230 228 | |
231 229 | public void spawnIn(World world) { |
232 230 | + // CraftBukkit start |
233 231 | + if (world == null) { |
234 232 | + die(); |
235 233 | + this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); |
236 234 | + return; |
237 235 | + } |
238 236 | + // CraftBukkit end |
239 237 | this.world = world; |
240 238 | } |
241 239 | |
242 - | |
240 + | |
243 241 | try { |
244 242 | nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ})); |
245 243 | nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ})); |
246 244 | + |
247 245 | + // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero |
248 246 | + // TODO: make sure this is the best way to address this. |
249 247 | + if (Float.isNaN(this.yaw)) { |
250 248 | + this.yaw = 0; |
251 249 | + } |
252 250 | + |
253 251 | + if (Float.isNaN(this.pitch)) { |
254 252 | + this.pitch = 0; |
255 253 | + } |
256 254 | + // CraftBukkit end |
257 255 | + |
258 256 | nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch})); |
259 257 | nbttagcompound.setFloat("FallDistance", this.fallDistance); |
260 258 | nbttagcompound.setShort("Fire", (short) this.fireTicks); |
261 - | |
259 + | |
262 260 | nbttagcompound.setBoolean("Invulnerable", this.invulnerable); |
263 261 | nbttagcompound.setInt("PortalCooldown", this.portalCooldown); |
264 262 | nbttagcompound.a("UUID", this.getUniqueID()); |
265 263 | + // CraftBukkit start |
266 264 | + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast |
267 265 | + nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits()); |
268 266 | + nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits()); |
269 267 | + nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); |
270 268 | + // CraftBukkit end |
271 269 | if (this.getCustomName() != null && !this.getCustomName().isEmpty()) { |
272 270 | nbttagcompound.setString("CustomName", this.getCustomName()); |
273 271 | } |
274 - | |
272 + | |
275 273 | this.motX = nbttaglist1.e(0); |
276 274 | this.motY = nbttaglist1.e(1); |
277 275 | this.motZ = nbttaglist1.e(2); |
278 276 | + |
279 277 | + /* CraftBukkit start - Moved section down |
280 278 | if (Math.abs(this.motX) > 10.0D) { |
281 279 | this.motX = 0.0D; |
282 280 | } |
283 - | |
281 + | |
284 282 | if (Math.abs(this.motZ) > 10.0D) { |
285 283 | this.motZ = 0.0D; |
286 284 | } |
287 285 | + // CraftBukkit end */ |
288 286 | |
289 287 | this.locX = nbttaglist.e(0); |
290 288 | this.locY = nbttaglist.e(1); |
291 - | |
289 + | |
292 290 | this.setPosition(this.locX, this.locY, this.locZ); |
293 291 | } |
294 292 | |
295 293 | + // CraftBukkit start |
296 294 | + if (this instanceof EntityLiving) { |
297 295 | + EntityLiving entity = (EntityLiving) this; |
298 296 | + |
299 297 | + // Reset the persistence for tamed animals |
300 298 | + if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { |
301 299 | + EntityInsentient entityinsentient = (EntityInsentient) entity; |
340 338 | + bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld(); |
341 339 | + } |
342 340 | + |
343 341 | + spawnIn(bworld == null? null : ((CraftWorld) bworld).getHandle()); |
344 342 | + } |
345 343 | + // CraftBukkit end |
346 344 | + |
347 345 | } catch (Throwable throwable) { |
348 346 | CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); |
349 347 | CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); |
350 - | |
348 + | |
351 349 | |
352 350 | public EntityItem a(ItemStack itemstack, float f) { |
353 351 | if (itemstack.count != 0 && itemstack.getItem() != null) { |
354 352 | + // CraftBukkit start - Capture drops for death event |
355 353 | + if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) { |
356 354 | + ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); |
357 355 | + return null; |
358 356 | + } |
359 357 | + // CraftBukkit end |
360 358 | EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); |
361 359 | |
362 360 | entityitem.q(); |
363 - | |
361 + | |
364 362 | if (entity.bB() != this) { |
365 363 | throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); |
366 364 | } else { |
367 365 | + // CraftBukkit start |
368 366 | + com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity); |
369 367 | + |
370 368 | + CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); |
371 369 | + Entity orig = craft == null ? null : craft.getHandle(); |
372 370 | + if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, false)) { // Boolean not used |
373 371 | + VehicleEnterEvent event = new VehicleEnterEvent( |
378 376 | + CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle(); |
379 377 | + Entity n = craftn == null ? null : craftn.getHandle(); |
380 378 | + if (event.isCancelled() || n != orig) { |
381 379 | + return; |
382 380 | + } |
383 381 | + } |
384 382 | + // CraftBukkit end |
385 383 | if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bw() instanceof EntityHuman)) { |
386 384 | this.passengers.add(0, entity); |
387 385 | } else { |
388 - | |
386 + | |
389 387 | if (entity.bB() == this) { |
390 388 | throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); |
391 389 | } else { |
392 390 | + // CraftBukkit start |
393 391 | + CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); |
394 392 | + Entity orig = craft == null ? null : craft.getHandle(); |
395 393 | + if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { |
396 394 | + VehicleExitEvent event = new VehicleExitEvent( |
397 395 | + (Vehicle) getBukkitEntity(), |
398 396 | + (LivingEntity) entity.getBukkitEntity() |
401 399 | + CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle(); |
402 400 | + Entity n = craftn == null ? null : craftn.getHandle(); |
403 401 | + if (event.isCancelled() || n != orig) { |
404 402 | + return; |
405 403 | + } |
406 404 | + } |
407 405 | + // CraftBukkit end |
408 406 | this.passengers.remove(entity); |
409 407 | entity.j = 60; |
410 408 | } |
411 - | |
409 + | |
412 410 | } |
413 411 | |
414 412 | public void setAirTicks(int i) { |
415 413 | - this.datawatcher.set(Entity.az, Integer.valueOf(i)); |
416 414 | + // CraftBukkit start |
417 415 | + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); |
418 416 | + if (event.isCancelled()) { |
419 417 | + return; |
420 418 | + } |
421 419 | + this.datawatcher.set(Entity.az, Integer.valueOf(event.getAmount())); |
453 451 | + // CraftBukkit start - Call a combust event when lightning strikes |
454 452 | + EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); |
455 453 | + pluginManager.callEvent(entityCombustEvent); |
456 454 | + if (!entityCombustEvent.isCancelled()) { |
457 455 | + this.setOnFire(entityCombustEvent.getDuration()); |
458 456 | + } |
459 457 | + // CraftBukkit end |
460 458 | } |
461 459 | |
462 460 | } |
463 - | |
461 + | |
464 462 | if (!this.world.isClientSide && !this.dead) { |
465 463 | this.world.methodProfiler.a("changeDimension"); |
466 464 | MinecraftServer minecraftserver = this.h(); |
467 465 | - int j = this.dimension; |
468 466 | - WorldServer worldserver = minecraftserver.getWorldServer(j); |
469 467 | - WorldServer worldserver1 = minecraftserver.getWorldServer(i); |
470 468 | + // CraftBukkit start - Move logic into new function "teleportTo(Location,boolean)" |
471 469 | + // int j = this.dimension; |
472 470 | + // WorldServer worldserver = minecraftserver.getWorldServer(j); |
473 471 | + // WorldServer worldserver1 = minecraftserver.getWorldServer(i); |
524 522 | } |
525 523 | + // CraftBukkit end */ |
526 524 | |
527 525 | this.world.kill(this); |
528 526 | this.dead = false; |
529 527 | this.world.methodProfiler.a("reposition"); |
530 528 | + /* CraftBukkit start - Handled in calculateTarget |
531 529 | BlockPosition blockposition; |
532 530 | |
533 531 | if (i == 1) { |
534 - | |
532 + | |
535 533 | blockposition = new BlockPosition(this); |
536 534 | } |
537 535 | |
538 536 | - worldserver.entityJoinedWorld(this, false); |
539 537 | + // CraftBukkit end */ |
540 538 | + // CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create |
541 539 | + // minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1); |
542 540 | + worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal); |
543 541 | + // worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity |
544 542 | + // CraftBukkit end |
545 543 | this.world.methodProfiler.c("reloading"); |
546 544 | Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1); |
547 545 | |
548 546 | if (entity != null) { |
549 547 | entity.a(this); |
550 548 | + /* CraftBukkit start - We need to do this... |
551 549 | if (j == 1 && i == 1) { |
552 550 | BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn()); |
553 551 | |
554 - | |
552 + | |
555 553 | } else { |
556 554 | entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); |
557 555 | } |
558 556 | + // CraftBukkit end */ |
559 557 | |
560 558 | boolean flag = entity.attachedToPlayer; |
561 559 | |
562 - | |
560 + | |
563 561 | worldserver1.addEntity(entity); |
564 562 | entity.attachedToPlayer = flag; |
565 563 | worldserver1.entityJoinedWorld(entity, false); |
566 564 | + // CraftBukkit start - Forward the CraftEntity to the new entity |
567 565 | + this.getBukkitEntity().setHandle(entity); |
568 566 | + entity.bukkitEntity = this.getBukkitEntity(); |
569 567 | + |
570 568 | + if (this instanceof EntityInsentient) { |
571 569 | + ((EntityInsentient)this).unleash(true, false); // Unleash to prevent duping of leads. |
572 570 | + } |
573 571 | + // CraftBukkit end |
574 572 | } |
575 573 | |
576 574 | this.dead = true; |
577 - | |
575 + | |
578 576 | } |
579 577 | |
580 578 | public void setCustomName(String s) { |
581 579 | + // CraftBukkit start - Add a sane limit for name length |
582 580 | + if (s.length() > 256) { |
583 581 | + s = s.substring(0, 256); |
584 582 | + } |
585 583 | + // CraftBukkit end |
586 584 | this.datawatcher.set(Entity.aA, s); |
587 585 | } |
588 586 | |
589 - | |
587 + | |
590 588 | } |
591 589 | |
592 590 | public void a(AxisAlignedBB axisalignedbb) { |
593 591 | - this.boundingBox = axisalignedbb; |
594 592 | + // CraftBukkit start - block invalid bounding boxes |
595 593 | + double a = axisalignedbb.a, |
596 594 | + b = axisalignedbb.b, |
597 595 | + c = axisalignedbb.c, |
598 596 | + d = axisalignedbb.d, |
599 597 | + e = axisalignedbb.e, |
607 605 | + if (len > 64) e = b + 64.0; |
608 606 | + |
609 607 | + len = axisalignedbb.f - axisalignedbb.c; |
610 608 | + if (len < 0) f = c; |
611 609 | + if (len > 64) f = c + 64.0; |
612 610 | + this.boundingBox = new AxisAlignedBB(a, b, c, d, e, f); |
613 611 | + // CraftBukkit end |
614 612 | } |
615 613 | |
616 614 | public float getHeadHeight() { |
617 - | |
615 + | |
618 616 | for (Iterator iterator = this.bx().iterator(); iterator.hasNext(); entity.a(oclass, set)) { |
619 617 | entity = (Entity) iterator.next(); |
620 618 | if (oclass.isAssignableFrom(entity.getClass())) { |
621 619 | - set.add(entity); |
622 620 | + set.add((T) entity); // CraftBukkit - decompile error |
623 621 | } |
624 622 | } |
625 623 |