aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0727-Add-EntityPortalReadyEvent.patch
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-06-16 15:48:38 -0700
committerJake Potrebic <[email protected]>2024-06-16 15:48:38 -0700
commita7f66333625febf891e5126bbd432707d38d1b1c (patch)
tree51e464ca2ab7e58178bf081c62a06fdc3b3d8bc8 /patches/server/0727-Add-EntityPortalReadyEvent.patch
parentfb762cf368a77d183b9f2f04b1cd606e47e53256 (diff)
downloadPaper-a7f66333625febf891e5126bbd432707d38d1b1c.tar.gz
Paper-a7f66333625febf891e5126bbd432707d38d1b1c.zip
make EntityPortalReadyEvent#setTargetWorld work again
Diffstat (limited to 'patches/server/0727-Add-EntityPortalReadyEvent.patch')
-rw-r--r--patches/server/0727-Add-EntityPortalReadyEvent.patch39
1 files changed, 18 insertions, 21 deletions
diff --git a/patches/server/0727-Add-EntityPortalReadyEvent.patch b/patches/server/0727-Add-EntityPortalReadyEvent.patch
index 72e8f57726..3b5704098f 100644
--- a/patches/server/0727-Add-EntityPortalReadyEvent.patch
+++ b/patches/server/0727-Add-EntityPortalReadyEvent.patch
@@ -4,25 +4,22 @@ Date: Wed, 12 May 2021 04:30:42 -0700
Subject: [PATCH] Add EntityPortalReadyEvent
-diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
-index d328393e62e4e49ddd56c10a9f4f5fcf0b218ddf..6be5d68567ba7b598644a3feeaa34ae5171c3b97 100644
---- a/src/main/java/net/minecraft/world/entity/Entity.java
-+++ b/src/main/java/net/minecraft/world/entity/Entity.java
-@@ -2943,6 +2943,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
- if (this.portalProcess != null) {
- if (this.portalProcess.processPortalTeleportation(worldserver, this, this.canUsePortal(false))) {
- worldserver.getProfiler().push("portal");
-+ // Paper start - Add EntityPortalReadyEvent
-+ ServerLevel changedTarget = worldserver.getServer().getLevel(worldserver.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER ? Level.OVERWORLD : Level.NETHER);
-+ if (this.portalProcess.isSamePortal(((net.minecraft.world.level.block.NetherPortalBlock) net.minecraft.world.level.block.Blocks.NETHER_PORTAL))) {
-+ io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), changedTarget == null ? null : changedTarget.getWorld(), org.bukkit.PortalType.NETHER);
-+ if (!event.callEvent()) {
-+ this.portalProcess = null;
-+ worldserver.getProfiler().pop();
-+ return;
-+ }
-+ }
-+ // Paper end - Add EntityPortalReadyEvent
- this.setPortalCooldown();
- DimensionTransition dimensiontransition = this.portalProcess.getPortalDestination(worldserver, this);
+diff --git a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
+index caa22afb0781671b901c23ebcc89e5bb0d2bd615..a530276b0123dee5680d7e09ad3d2f0414909c91 100644
+--- a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
++++ b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
+@@ -133,6 +133,14 @@ public class NetherPortalBlock extends Block implements Portal {
+ // CraftBukkit start
+ ResourceKey<Level> resourcekey = world.getTypeKey() == LevelStem.NETHER ? Level.OVERWORLD : Level.NETHER;
+ ServerLevel worldserver1 = world.getServer().getLevel(resourcekey);
++ // Paper start - Add EntityPortalReadyEvent
++ io.papermc.paper.event.entity.EntityPortalReadyEvent portalReadyEvent = new io.papermc.paper.event.entity.EntityPortalReadyEvent(entity.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER);
++ if (!portalReadyEvent.callEvent()) {
++ entity.portalProcess = null;
++ return null;
++ }
++ worldserver1 = portalReadyEvent.getTargetWorld() == null ? null : ((org.bukkit.craftbukkit.CraftWorld) portalReadyEvent.getTargetWorld()).getHandle();
++ // Paper end - Add EntityPortalReadyEvent
+ if (worldserver1 == null) {
+ return new DimensionTransition(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); // always fire event in case plugins wish to change it