Commits
md_5 authored 4470462a549
1 - | --- ../work/decompile-8eb82bde//net/minecraft/server/Entity.java 2015-01-04 20:00:32.717671452 +0000 |
2 - | +++ src/main/java/net/minecraft/server/Entity.java 2015-01-04 20:00:32.721671452 +0000 |
1 + | --- ../work/decompile-8eb82bde/net/minecraft/server/Entity.java 2015-01-09 16:56:08.177542854 +1100 |
2 + | +++ src/main/java/net/minecraft/server/Entity.java 2015-01-09 16:56:08.181542844 +1100 |
3 3 | |
4 4 | import java.util.UUID; |
5 5 | import java.util.concurrent.Callable; |
6 6 | |
7 7 | +// CraftBukkit start |
8 8 | +import org.bukkit.Bukkit; |
9 9 | +import org.bukkit.Location; |
10 10 | +import org.bukkit.Server; |
11 11 | +import org.bukkit.TravelAgent; |
12 12 | +import org.bukkit.block.BlockFace; |
308 308 | + if (this instanceof EntityLiving) { |
309 309 | + EntityLiving entity = (EntityLiving) this; |
310 310 | + |
311 311 | + // Reset the persistence for tamed animals |
312 312 | + if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { |
313 313 | + EntityInsentient entityinsentient = (EntityInsentient) entity; |
314 314 | + entityinsentient.persistent = !entityinsentient.isTypeNotPersistent(); |
315 315 | + } |
316 316 | + } |
317 317 | + // CraftBukkit end |
318 - | + |
318 + | |
319 319 | + // CraftBukkit start - Exempt Vehicles from notch's sanity check |
320 320 | + if (!(getBukkitEntity() instanceof Vehicle)) { |
321 321 | + if (Math.abs(this.motX) > 10.0D) { |
322 322 | + this.motX = 0.0D; |
323 323 | + } |
324 324 | + |
325 325 | + if (Math.abs(this.motY) > 10.0D) { |
326 326 | + this.motY = 0.0D; |
327 327 | + } |
328 328 | + |
329 329 | + if (Math.abs(this.motZ) > 10.0D) { |
330 330 | + this.motZ = 0.0D; |
331 331 | + } |
332 332 | + } |
333 333 | + // CraftBukkit end |
334 - | |
334 + | + |
335 335 | + // CraftBukkit start - Reset world |
336 336 | + if (this instanceof EntityPlayer) { |
337 337 | + Server server = Bukkit.getServer(); |
338 338 | + org.bukkit.World bworld = null; |
339 339 | + |
340 340 | + // TODO: Remove World related checks, replaced with WorldUID |
341 341 | + String worldName = nbttagcompound.getString("world"); |
342 342 | + |
343 343 | + if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) { |
344 344 | + UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); |
364 364 | if (itemstack.count != 0 && itemstack.getItem() != null) { |
365 365 | + // CraftBukkit start - Capture drops for death event |
366 366 | + if (this instanceof EntityLiving && ((EntityLiving) this).drops != null) { |
367 367 | + ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); |
368 368 | + return null; |
369 369 | + } |
370 370 | + // CraftBukkit end |
371 371 | EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); |
372 372 | |
373 373 | entityitem.p(); |
374 - | |
374 + | |
375 + | return (double) this.length * 0.75D; |
375 376 | } |
376 377 | |
377 - | public void mount(Entity entity) { |
378 - | + // CraftBukkit start |
379 - | + setPassengerOf(entity); |
380 - | + } |
381 - | + |
378 + | + // CraftBukkit start |
382 379 | + protected CraftEntity bukkitEntity; |
383 380 | + |
384 381 | + public CraftEntity getBukkitEntity() { |
385 382 | + if (bukkitEntity == null) { |
386 383 | + bukkitEntity = CraftEntity.getEntity(world.getServer(), this); |
387 384 | + } |
388 385 | + return bukkitEntity; |
389 386 | + } |
390 387 | + |
391 - | + public void setPassengerOf(Entity entity) { |
392 - | + // b(null) doesn't really fly for overloaded methods, |
393 - | + // so this method is needed |
394 - | + |
388 + | public void mount(Entity entity) { |
395 389 | + Entity originalVehicle = this.vehicle; |
396 390 | + Entity originalPassenger = this.vehicle == null ? null : this.vehicle.passenger; |
397 391 | + PluginManager pluginManager = Bukkit.getPluginManager(); |
398 392 | + getBukkitEntity(); // make sure bukkitEntity is initialised |
399 393 | + // CraftBukkit end |
400 394 | this.ap = 0.0D; |
401 395 | this.aq = 0.0D; |
402 396 | if (entity == null) { |
403 397 | if (this.vehicle != null) { |
404 398 | + // CraftBukkit start |
430 424 | + } |
431 425 | + } |
432 426 | + |
433 427 | + VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity); |
434 428 | + pluginManager.callEvent(event); |
435 429 | + |
436 430 | + // If a plugin messes with the vehicle or the vehicle's passenger |
437 431 | + if (event.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) { |
438 432 | + // If we only cancelled the enterevent then we need to put the player in a decent position. |
439 433 | + if (exitEvent != null && this.vehicle == originalVehicle && this.vehicle != null && this.vehicle.passenger == originalPassenger) { |
440 - | + this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch); |
434 + | + this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch); |
441 435 | + this.vehicle.passenger = null; |
442 436 | + this.vehicle = null; |
443 437 | + } |
444 438 | + return; |
445 439 | + } |
446 440 | + } |
447 441 | + // CraftBukkit end |
448 442 | if (this.vehicle != null) { |
449 443 | this.vehicle.passenger = null; |
450 444 | } |
451 - | |
445 + | |
452 446 | } |
453 447 | |
454 448 | public void onLightningStrike(EntityLightning entitylightning) { |
455 449 | - this.damageEntity(DamageSource.LIGHTNING, 5.0F); |
456 450 | + // CraftBukkit start |
457 451 | + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); |
458 452 | + final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity(); |
459 453 | + final PluginManager pluginManager = Bukkit.getPluginManager(); |
460 454 | + |
461 455 | + if (thisBukkitEntity instanceof Hanging) { |
493 487 | + // CraftBukkit start - Call a combust event when lightning strikes |
494 488 | + EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); |
495 489 | + pluginManager.callEvent(entityCombustEvent); |
496 490 | + if (!entityCombustEvent.isCancelled()) { |
497 491 | + this.setOnFire(entityCombustEvent.getDuration()); |
498 492 | + } |
499 493 | + // CraftBukkit end |
500 494 | } |
501 495 | |
502 496 | } |
503 - | |
497 + | |
504 498 | if (!this.world.isStatic && !this.dead) { |
505 499 | this.world.methodProfiler.a("changeDimension"); |
506 500 | MinecraftServer minecraftserver = MinecraftServer.getServer(); |
507 501 | - int j = this.dimension; |
508 502 | - WorldServer worldserver = minecraftserver.getWorldServer(j); |
509 503 | - WorldServer worldserver1 = minecraftserver.getWorldServer(i); |
510 504 | + // CraftBukkit start - Move logic into new function "teleportToLocation" |
511 505 | + // int j = this.dimension; |
512 506 | + // WorldServer worldserver = minecraftserver.getWorldServer(j); |
513 507 | + // WorldServer worldserver1 = minecraftserver.getWorldServer(i); |
581 575 | + this.getBukkitEntity().setHandle(entity); |
582 576 | + entity.bukkitEntity = this.getBukkitEntity(); |
583 577 | + |
584 578 | + if (this instanceof EntityInsentient) { |
585 579 | + ((EntityInsentient)this).unleash(true, false); // Unleash to prevent duping of leads. |
586 580 | + } |
587 581 | + // CraftBukkit end |
588 582 | } |
589 583 | |
590 584 | this.dead = true; |
591 - | |
585 + | |
592 586 | return this.boundingBox; |
593 587 | } |
594 588 | |
595 589 | - public void a(AxisAlignedBB axisalignedbb) { |
596 590 | - this.boundingBox = axisalignedbb; |
597 591 | + public void a(AxisAlignedBB axisalignedbb) { |
598 592 | + // CraftBukkit start - block invalid bounding boxes |
599 593 | + double a = axisalignedbb.a, |
600 594 | + b = axisalignedbb.b, |
601 595 | + c = axisalignedbb.c, |