Paper/src/main/java/net/minecraft/server/EntityEnderPearl.java

63 Zeilen
2.8 KiB
Java

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 {
2012-01-12 23:10:13 +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) {
2012-11-06 13:05:28 +01:00
movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0);
}
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) {
2012-11-06 13:05:28 +01:00
if (this.getShooter() != null && this.getShooter() instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) this.getShooter();
2012-12-20 05:03:52 +01:00
if (!entityplayer.playerConnection.disconnected && entityplayer.world == this.world) {
2012-07-29 09:33:13 +02:00
// CraftBukkit start
2012-09-14 07:03:47 +02:00
org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity();
org.bukkit.Location location = getBukkitEntity().getLocation();
location.setPitch(player.getLocation().getPitch());
location.setYaw(player.getLocation().getYaw());
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-12-20 05:03:52 +01:00
if (!teleEvent.isCancelled() && !entityplayer.playerConnection.disconnected) {
entityplayer.playerConnection.teleport(teleEvent.getTo());
2012-11-06 13:05:28 +01:00
this.getShooter().fallDistance = 0.0F;
2012-07-29 09:33:13 +02:00
2013-07-01 13:03:00 +02:00
EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(this.getBukkitEntity(), player, EntityDamageByEntityEvent.DamageCause.FALL, 5.0D);
2012-07-29 09:33:13 +02:00
Bukkit.getPluginManager().callEvent(damageEvent);
2012-12-20 05:03:52 +01:00
if (!damageEvent.isCancelled() && !entityplayer.playerConnection.disconnected) {
entityplayer.invulnerableTicks = -1; // Remove spawning invulnerability
player.setLastDamageCause(damageEvent);
2013-07-01 13:03:00 +02:00
entityplayer.damageEntity(DamageSource.FALL, (float) damageEvent.getDamage());
2012-07-29 09:33:13 +02:00
}
}
2012-07-29 09:33:13 +02:00
// CraftBukkit end
}
}
this.die();
}
}
}