Commits

md_5 authored 56813c7ffff
SPIGOT-1468: ENDER_PEARL SpawnReason
No tags

nms-patches/EntityEnderPearl.patch

Modified
1 1 --- a/net/minecraft/server/EntityEnderPearl.java
2 2 +++ b/net/minecraft/server/EntityEnderPearl.java
3 -@@ -1,5 +1,11 @@
3 +@@ -1,5 +1,12 @@
4 4 package net.minecraft.server;
5 5
6 6 +// CraftBukkit start
7 7 +import org.bukkit.Bukkit;
8 8 +import org.bukkit.craftbukkit.event.CraftEventFactory;
9 ++import org.bukkit.event.entity.CreatureSpawnEvent;
9 10 +import org.bukkit.event.player.PlayerTeleportEvent;
10 11 +// CraftBukkit end
11 12 +
12 13 public class EntityEnderPearl extends EntityProjectile {
13 14
14 15 private EntityLiving d;
15 -@@ -55,21 +61,35 @@
16 +@@ -55,21 +62,35 @@
16 17 EntityPlayer entityplayer = (EntityPlayer) entityliving;
17 18
18 19 if (entityplayer.playerConnection.a().isConnected() && entityplayer.world == this.world && !entityplayer.isSleeping()) {
19 20 - if (this.random.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning")) {
20 21 - EntityEndermite entityendermite = new EntityEndermite(this.world);
21 22 -
22 23 - entityendermite.a(true);
23 24 - entityendermite.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch);
24 25 - this.world.addEntity(entityendermite);
25 26 + // CraftBukkit start - Fire PlayerTeleportEvent
30 31 +
31 32 + PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
32 33 + Bukkit.getPluginManager().callEvent(teleEvent);
33 34 +
34 35 + if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) {
35 36 + if (this.random.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning")) {
36 37 + EntityEndermite entityendermite = new EntityEndermite(this.world);
37 38 +
38 39 + entityendermite.a(true);
39 40 + entityendermite.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch);
40 -+ this.world.addEntity(entityendermite);
41 ++ this.world.addEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
41 42 + }
42 43 +
43 44 + if (entityliving.isPassenger()) {
44 45 + entityliving.stopRiding();
45 46 + }
46 47 +
47 48 + entityplayer.playerConnection.teleport(teleEvent.getTo());
48 49 + entityliving.fallDistance = 0.0F;
49 50 + CraftEventFactory.entityDamage = this;
50 51 + entityliving.damageEntity(DamageSource.FALL, 5.0F);

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut