Paper/patches/server/0941-Improve-PortalEvents.patch

27 lines
1.5 KiB
Diff
Raw Normal View History

2022-12-17 18:36:02 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 15 Dec 2022 10:33:39 -0800
Subject: [PATCH] Improve PortalEvents
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
2023-03-14 22:29:14 +01:00
index 071b241de8f6e00f57e8564bb3feb757ee1f05eb..56e7e423ef3f1016ea095ef98dc9c06e7763ac3b 100644
2022-12-17 18:36:02 +01:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2023-03-14 22:29:14 +01:00
@@ -3561,7 +3561,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
2022-12-17 18:36:02 +01:00
Location enter = bukkitEntity.getLocation();
Location exit = new Location(exitWorldServer.getWorld(), exitPosition.x(), exitPosition.y(), exitPosition.z());
- EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius);
+ // Paper start
+ final org.bukkit.PortalType portalType = switch (cause) {
+ case END_PORTAL -> org.bukkit.PortalType.ENDER;
+ case NETHER_PORTAL -> org.bukkit.PortalType.NETHER;
+ default -> org.bukkit.PortalType.CUSTOM;
+ };
+ EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius, portalType);
+ // Paper end
event.getEntity().getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.isAlive()) {
return null;