Made ender pearls use the player's yaw and pitch. Fixes BUKKIT-1056

This commit is contained in:
EvilSeph 2012-03-11 00:10:01 -05:00
parent 49ff166d15
commit 2aad49eecc

View File

@ -1,9 +1,12 @@
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.Location;
// CraftBukkit end
public class EntityEnderPearl extends EntityProjectile {
@ -37,9 +40,12 @@ public class EntityEnderPearl extends EntityProjectile {
if (this.shooter instanceof EntityPlayer) {
CraftPlayer player = (CraftPlayer) this.shooter.bukkitEntity;
teleport = player.isOnline() && player.getWorld() == getBukkitEntity().getWorld();
Location location = getBukkitEntity().getLocation();
location.setPitch(player.getLocation().getPitch());
location.setYaw(player.getLocation().getYaw());
if (teleport) {
teleEvent = new PlayerTeleportEvent(player, player.getLocation(), getBukkitEntity().getLocation(), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(teleEvent);
teleport = !teleEvent.isCancelled();
}