PaperMC/patches/server/0812-Add-EntityPortalReadyEvent.patch
2024-01-18 15:56:25 +01:00

32 lines
2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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 053dbed42a74a5721cfe9f6d70cd965ede3ef1f3..5a57fe0dacd4baf3fea9b64f6325acc34b946036 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3099,6 +3099,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit
this.level().getProfiler().push("portal");
this.portalTime = i;
+ // Paper start - Add EntityPortalReadyEvent
+ io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER);
+ if (!event.callEvent()) {
+ this.portalTime = 0;
+ } else {
+ worldserver1 = event.getTargetWorld() == null ? null : ((CraftWorld) event.getTargetWorld()).getHandle();
+ // Paper end - Add EntityPortalReadyEvent
this.setPortalCooldown();
// CraftBukkit start
if (this instanceof ServerPlayer) {
@@ -3106,6 +3113,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
} else {
this.changeDimension(worldserver1);
}
+ } // Paper - Add EntityPortalReadyEvent
// CraftBukkit end
this.level().getProfiler().pop();
}