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
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void a(MovingObjectPosition movingobjectposition) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (movingobjectposition.entity != null) {
|
|
|
|
movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), 0);
|
2011-12-02 00:34:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.shooter != null && this.shooter instanceof EntityPlayer) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) this.shooter;
|
2011-12-04 12:04:14 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!entityplayer.netServerHandler.disconnected && entityplayer.world == this.world) {
|
|
|
|
// CraftBukkit start
|
2012-08-22 21:17:36 +02:00
|
|
|
CraftPlayer player = entityplayer.getBukkitEntity();
|
2012-07-22 08:18:00 +02:00
|
|
|
org.bukkit.Location location = getBukkitEntity().getLocation();
|
2012-03-11 06:10:01 +01:00
|
|
|
location.setPitch(player.getLocation().getPitch());
|
|
|
|
location.setYaw(player.getLocation().getYaw());
|
2011-12-11 06:52:55 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
|
|
|
|
Bukkit.getPluginManager().callEvent(teleEvent);
|
2012-08-22 21:17:36 +02:00
|
|
|
|
|
|
|
if (!teleEvent.isCancelled() && !entityplayer.netServerHandler.disconnected) {
|
|
|
|
entityplayer.netServerHandler.teleport(teleEvent.getTo());
|
2012-07-29 09:33:13 +02:00
|
|
|
this.shooter.fallDistance = 0.0F;
|
|
|
|
|
2012-08-22 21:17:36 +02:00
|
|
|
EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(this.getBukkitEntity(), player, EntityDamageByEntityEvent.DamageCause.FALL, 5);
|
2012-07-29 09:33:13 +02:00
|
|
|
Bukkit.getPluginManager().callEvent(damageEvent);
|
|
|
|
|
2012-08-22 21:17:36 +02:00
|
|
|
if (!damageEvent.isCancelled() && !entityplayer.netServerHandler.disconnected) {
|
|
|
|
entityplayer.invulnerableTicks = -1; // Remove spawning invulnerability
|
|
|
|
player.setLastDamageCause(damageEvent);
|
|
|
|
entityplayer.damageEntity(DamageSource.FALL, damageEvent.getDamage());
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2011-12-04 12:04:14 +01:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit end
|
2011-12-02 01:06:27 +01:00
|
|
|
}
|
2011-12-02 00:34:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|