From fca41573a3481c1d84b0b892970e8d15dd9d778a Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 5 Jul 2019 10:09:11 +1000 Subject: [PATCH] SPIGOT-5136: EntityPortalEvent getting called on interdimensional entity teleports --- nms-patches/Entity.patch | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 873646881b..c1cd7c0fcd 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -573,9 +573,8 @@ + this.setOnFire(entityCombustEvent.getDuration(), false); + } + // CraftBukkit end - } - -- this.damageEntity(DamageSource.LIGHTNING, 5.0F); ++ } ++ + // CraftBukkit start + if (thisBukkitEntity instanceof Hanging) { + HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity); @@ -584,8 +583,9 @@ + if (hangingEvent.isCancelled()) { + return; + } -+ } -+ + } + +- this.damageEntity(DamageSource.LIGHTNING, 5.0F); + if (this.isFireProof()) { + return; + } @@ -652,33 +652,36 @@ d0 *= 8.0D; d1 *= 8.0D; } -@@ -2088,6 +2442,25 @@ +@@ -2088,6 +2442,28 @@ vec3d = shapedetector_shape.velocity; f = (float) shapedetector_shape.yaw; } + } // CraftBukkit + + // CraftBukkit start -+ Location enter = this.getBukkitEntity().getLocation(); -+ Location exit = new Location(worldserver1.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ // SPIGOT-5136 - don't fire event for CraftEntity.teleport ++ if (location == null) { ++ Location enter = this.getBukkitEntity().getLocation(); ++ Location exit = new Location(worldserver1.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); + -+ EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit); -+ event.getEntity().getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) { -+ return null; ++ EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit); ++ event.getEntity().getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) { ++ return null; ++ } ++ ++ exit = event.getTo(); ++ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); ++ blockposition = new BlockPosition(exit.getX(), exit.getY(), exit.getZ()); + } + -+ exit = event.getTo(); -+ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); -+ blockposition = new BlockPosition(exit.getX(), exit.getY(), exit.getZ()); -+ + this.dimension = dimensionmanager; + this.decouple(); + // CraftBukkit end this.world.getMethodProfiler().exitEnter("reloading"); Entity entity = this.getEntityType().a((World) worldserver1); -@@ -2097,6 +2470,14 @@ +@@ -2097,6 +2473,14 @@ entity.setPositionRotation(blockposition, entity.yaw + f, entity.pitch); entity.setMot(vec3d); worldserver1.addEntityTeleport(entity); @@ -693,7 +696,7 @@ } this.dead = true; -@@ -2298,7 +2679,26 @@ +@@ -2298,7 +2682,26 @@ } public void a(AxisAlignedBB axisalignedbb) {