From a92a95b296ae4664d026341db8e457b8096169cd Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Fri, 31 Jan 2025 21:40:12 +0800 Subject: [PATCH] Fix threading issue when changed the destination position of the end portal --- .../0009-Add-missing-teleportation-apis-for-folia.patch | 6 ++++-- .../0041-Add-missing-teleportation-apis-for-folia.patch | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/luminol-api/paper-patches/features/0009-Add-missing-teleportation-apis-for-folia.patch b/luminol-api/paper-patches/features/0009-Add-missing-teleportation-apis-for-folia.patch index 8187c5d..544a823 100644 --- a/luminol-api/paper-patches/features/0009-Add-missing-teleportation-apis-for-folia.patch +++ b/luminol-api/paper-patches/features/0009-Add-missing-teleportation-apis-for-folia.patch @@ -310,10 +310,10 @@ index 0000000000000000000000000000000000000000..cf87a7cce5d1ebec9709b76259560934 +} diff --git a/src/main/java/me/earthme/luminol/api/portal/PortalLocateEvent.java b/src/main/java/me/earthme/luminol/api/portal/PortalLocateEvent.java new file mode 100644 -index 0000000000000000000000000000000000000000..2b67f99aafda11eebc55386c503e34772de6cd8a +index 0000000000000000000000000000000000000000..c8ded49d74a06995c0388d47a5cbf3c070a03abb --- /dev/null +++ b/src/main/java/me/earthme/luminol/api/portal/PortalLocateEvent.java -@@ -0,0 +1,62 @@ +@@ -0,0 +1,64 @@ +package me.earthme.luminol.api.portal; + +import org.apache.commons.lang3.Validate; @@ -324,6 +324,8 @@ index 0000000000000000000000000000000000000000..2b67f99aafda11eebc55386c503e3477 + +/** + * A event fired when the portal process started locating the destination position ++ * Notice: If you changed the destination to an another position in end teleportation.The end platform won't create under the entity and won't create ++ * if the position is out of current tick region + */ +public class PortalLocateEvent extends Event { + private static final HandlerList HANDLERS = new HandlerList(); diff --git a/luminol-server/minecraft-patches/features/0041-Add-missing-teleportation-apis-for-folia.patch b/luminol-server/minecraft-patches/features/0041-Add-missing-teleportation-apis-for-folia.patch index b29e509..0011520 100644 --- a/luminol-server/minecraft-patches/features/0041-Add-missing-teleportation-apis-for-folia.patch +++ b/luminol-server/minecraft-patches/features/0041-Add-missing-teleportation-apis-for-folia.patch @@ -19,7 +19,7 @@ index 9fd3fe181df2ce6dbe695f6463d3940ac4c01167..822d401150d3764004b2570da828b4f6 ); }); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 406c382ae2fdaa7d8996d250487bbdfb7e4bb7f9..29fc2e5af0b6ec81c3f0c1c89f76166e7f4ac19c 100644 +index 406c382ae2fdaa7d8996d250487bbdfb7e4bb7f9..c742695ea24588826f50740ad442f3234953ba81 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -4164,6 +4164,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -120,7 +120,7 @@ index 406c382ae2fdaa7d8996d250487bbdfb7e4bb7f9..29fc2e5af0b6ec81c3f0c1c89f76166e // Kaiiju start - sync end platform spawning & entity teleportation final java.util.function.Consumer tpComplete = type == PortalType.END && destination.getTypeKey() == LevelStem.END ? - e -> net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, ServerLevel.END_SPAWN_POINT.below(), true, null) : teleportComplete; -+ e -> { if (new me.earthme.luminol.api.portal.EndPlatformCreateEvent().callEvent()) net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, ServerLevel.END_SPAWN_POINT.below(), true, null); } : teleportComplete; // Luminol - Add missing teleportation events ++ e -> { if (new me.earthme.luminol.api.portal.EndPlatformCreateEvent().callEvent() && ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(e.level, ServerLevel.END_SPAWN_POINT.below())) net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, ServerLevel.END_SPAWN_POINT.below(), true, null); } : teleportComplete; // Luminol - Add missing teleportation events & Fix teleportation api threading issue // Kaiiju end Vec3 initialPosition = this.position();