2011-12-02 00:34:14 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-03-11 06:10:01 +01:00
|
|
|
// CraftBukkit start
|
2011-12-02 00:34:14 +01:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
2011-12-11 06:52:55 +01:00
|
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
2011-12-04 12:04:14 +01:00
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
2012-03-11 06:10:01 +01:00
|
|
|
import org.bukkit.Location;
|
|
|
|
// CraftBukkit end
|
2011-12-02 00:34:14 +01:00
|
|
|
|
|
|
|
public class EntityEnderPearl extends EntityProjectile {
|
2012-01-12 23:10:13 +01:00
|
|
|
|
2011-12-02 00:34:14 +01:00
|
|
|
public EntityEnderPearl(World world) {
|
|
|
|
super(world);
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityEnderPearl(World world, EntityLiving entityliving) {
|
|
|
|
super(world, entityliving);
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityEnderPearl(World world, double d0, double d1, double d2) {
|
|
|
|
super(world, d0, d1, d2);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(MovingObjectPosition movingobjectposition) {
|
|
|
|
if (movingobjectposition.entity != null && movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), 0)) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 32; ++i) {
|
|
|
|
this.world.a("portal", this.locX, this.locY + this.random.nextDouble() * 2.0D, this.locZ, this.random.nextGaussian(), 0.0D, this.random.nextGaussian());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.world.isStatic) {
|
|
|
|
// CraftBukkit start - dupe fix + damage event
|
2011-12-04 12:04:14 +01:00
|
|
|
boolean teleport = false;
|
|
|
|
PlayerTeleportEvent teleEvent = null;
|
|
|
|
|
2011-12-02 00:34:14 +01:00
|
|
|
if (this.shooter != null) {
|
|
|
|
if (this.shooter instanceof EntityPlayer) {
|
2012-01-14 23:02:10 +01:00
|
|
|
CraftPlayer player = (CraftPlayer) this.shooter.bukkitEntity;
|
2012-03-09 01:24:43 +01:00
|
|
|
teleport = player.isOnline() && player.getWorld() == getBukkitEntity().getWorld();
|
2012-03-11 06:10:01 +01:00
|
|
|
Location location = getBukkitEntity().getLocation();
|
|
|
|
location.setPitch(player.getLocation().getPitch());
|
|
|
|
location.setYaw(player.getLocation().getYaw());
|
2011-12-11 06:52:55 +01:00
|
|
|
|
2011-12-04 12:04:14 +01:00
|
|
|
if (teleport) {
|
2012-03-11 06:10:01 +01:00
|
|
|
teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
|
2011-12-04 12:04:14 +01:00
|
|
|
Bukkit.getPluginManager().callEvent(teleEvent);
|
|
|
|
teleport = !teleEvent.isCancelled();
|
|
|
|
}
|
2011-12-02 00:34:14 +01:00
|
|
|
} else {
|
2011-12-04 12:04:14 +01:00
|
|
|
teleport = true;
|
2011-12-02 00:34:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-04 12:04:14 +01:00
|
|
|
if (teleport) {
|
|
|
|
if (this.shooter instanceof EntityPlayer) {
|
2012-01-14 23:02:10 +01:00
|
|
|
((EntityPlayer) this.shooter).netServerHandler.teleport(teleEvent.getTo());
|
2011-12-04 12:04:14 +01:00
|
|
|
} else {
|
2012-01-14 21:03:48 +01:00
|
|
|
this.shooter.enderTeleportTo(this.locX, this.locY, this.locZ);
|
2011-12-04 12:04:14 +01:00
|
|
|
}
|
2011-12-02 00:34:14 +01:00
|
|
|
this.shooter.fallDistance = 0.0F;
|
2011-12-11 06:52:55 +01:00
|
|
|
EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(this.getBukkitEntity(), this.shooter.getBukkitEntity(), EntityDamageByEntityEvent.DamageCause.FALL, 5);
|
2011-12-04 12:04:14 +01:00
|
|
|
Bukkit.getPluginManager().callEvent(damageEvent);
|
2011-12-02 01:06:27 +01:00
|
|
|
|
2011-12-04 12:04:14 +01:00
|
|
|
if (!damageEvent.isCancelled()) {
|
2011-12-11 06:52:55 +01:00
|
|
|
org.bukkit.entity.Player bPlayer = Bukkit.getPlayerExact(((EntityPlayer) this.shooter).name);
|
2012-01-14 21:03:48 +01:00
|
|
|
((CraftPlayer) bPlayer).getHandle().invulnerableTicks = -1; // Remove spawning invulnerability.
|
2012-07-14 06:14:56 +02:00
|
|
|
bPlayer.setLastDamageCause(damageEvent);
|
2012-02-10 00:18:50 +01:00
|
|
|
((CraftPlayer) bPlayer).getHandle().damageEntity(DamageSource.FALL, damageEvent.getDamage()); // Damage the new player instead of the old
|
2011-12-02 01:06:27 +01:00
|
|
|
}
|
2011-12-02 00:34:14 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
this.die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|