1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraft/entity/item/EntityEnderPearl.java.patch

57 lines
3.0 KiB
Diff
Raw Normal View History

2015-03-22 17:38:04 +00:00
--- ../src-base/minecraft/net/minecraft/entity/item/EntityEnderPearl.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityEnderPearl.java
@@ -12,6 +12,12 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
+
public class EntityEnderPearl extends EntityThrowable
{
private static final String __OBFID = "CL_00001725";
@@ -52,18 +58,31 @@
if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && entityplayermp.worldObj == this.worldObj)
{
- EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5.0F);
- if (!MinecraftForge.EVENT_BUS.post(event))
- { // Don't indent to lower patch size
- if (this.getThrower().isRiding())
- {
- this.getThrower().mountEntity((Entity)null);
+ EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5);
+ // Cauldron start - invert condition; return if cancelled otherwise fall through to CB event
+ if (MinecraftForge.EVENT_BUS.post(event)){
+ this.setDead();
+ return;
}
+ // Cauldron end
+ // CraftBukkit start
+ org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayermp.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);
- this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ);
- this.getThrower().fallDistance = 0.0F;
- this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage);
+ if (!teleEvent.isCancelled() && !entityplayermp.playerNetServerHandler.isDisconnected())
+ {
+ entityplayermp.playerNetServerHandler.teleport(teleEvent.getTo());
+ this.getThrower().fallDistance = 0.0F;
+ CraftEventFactory.entityDamage = this;
+ this.getThrower().attackEntityFrom(DamageSource.fall, 5.0F);
+ CraftEventFactory.entityDamage = null;
}
+
+ // CraftBukkit end
}
}