From 7656a539b691b65a9ebfb5e88a3fd1124819baa0 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Fri, 8 Dec 2023 19:35:57 +1100 Subject: [PATCH] SPIGOT-7440, #1292: Fire EntityTeleportEvent for end gateways By: Jishuna --- .../block/entity/TileEntityEndGateway.patch | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch index ee2a1c6362..6020597ac4 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/entity/TileEntityEndGateway.patch @@ -24,11 +24,11 @@ blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition); blockposition1 = blockposition1.above(10); TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1); -@@ -198,6 +206,27 @@ +@@ -198,8 +206,34 @@ entity1 = entity.getRootVehicle(); } -+ // CraftBukkit start - Fire PlayerTeleportEvent ++ // CraftBukkit start - Fire PlayerTeleportEvent/EntityTeleportEvent + if (entity1 instanceof EntityPlayer) { + org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity(); + org.bukkit.Location location = CraftLocation.toBukkit(blockposition1, world.getWorld()).add(0.5D, 0.5D, 0.5D); @@ -47,8 +47,16 @@ + return; + + } -+ // CraftBukkit end ++ ++ org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); ++ if (teleEvent.isCancelled()) { ++ return; ++ } + entity1.setPortalCooldown(); - entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); +- entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); ++ entity1.teleportToWithTicket(teleEvent.getTo().getX(), teleEvent.getTo().getY(), teleEvent.getTo().getZ()); ++ // CraftBukkit end } + + triggerCooldown(world, blockposition, iblockdata, tileentityendgateway);