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
|
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
// CraftBukkit end
public class EntityEnderPearl extends EntityProjectile {
public EntityEnderPearl(World world) {
super(world);
}
public EntityEnderPearl(World world, EntityLiving entityliving) {
super(world, entityliving);
}
protected void a(MovingObjectPosition movingobjectposition) {
if (movingobjectposition.entity != null) {
movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F);
}
for (int i = 0; i < 32; ++i) {
this.world.addParticle("portal", this.locX, this.locY + this.random.nextDouble() * 2.0D, this.locZ, this.random.nextGaussian(), 0.0D, this.random.nextGaussian());
}
if (!this.world.isStatic) {
if (this.getShooter() != null && this.getShooter() instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) this.getShooter();
if (entityplayer.playerConnection.b().d() && entityplayer.world == this.world) {
// CraftBukkit start
org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity();
org.bukkit.Location location = getBukkitEntity().getLocation();
location.setPitch(player.getLocation().getPitch());
location.setYaw(player.getLocation().getYaw());
PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(teleEvent);
if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) {
entityplayer.playerConnection.teleport(teleEvent.getTo());
this.getShooter().fallDistance = 0.0F;
EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(this.getBukkitEntity(), player, EntityDamageByEntityEvent.DamageCause.FALL, 5.0D);
Bukkit.getPluginManager().callEvent(damageEvent);
if (!damageEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) {
entityplayer.invulnerableTicks = -1; // Remove spawning invulnerability
player.setLastDamageCause(damageEvent);
entityplayer.damageEntity(DamageSource.FALL, (float) damageEvent.getDamage());
}
}
// CraftBukkit end
}
}
this.die();
}
}
}
|