164 lines
9.0 KiB
Diff
164 lines
9.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <wangxyper@163.com>
|
|
Date: Fri, 31 Jan 2025 20:28:45 +0800
|
|
Subject: [PATCH] Add missing teleportation apis for folia
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
|
index 886299f6a69e57286b6acbee416b552163f2c5b2..af0a5766ff344bdaa602a6ee35726fef41fbb95d 100644
|
|
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1648,6 +1648,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
if (respawnComplete != null) {
|
|
respawnComplete.accept(ServerPlayer.this);
|
|
}
|
|
+ // Luminol - Add missing teleportation apis
|
|
+ new me.earthme.luminol.api.entity.player.PostPlayerRespawnEvent(ServerPlayer.this.getBukkitEntity()).callEvent();
|
|
+ // Luminol end
|
|
}
|
|
);
|
|
});
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 7d026161ef0290405bdf86b4e5d6b6f0ca5f6556..8361652ba69e9112f4ac2b81bb8b59ff43eeddfc 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -4309,6 +4309,31 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
// TODO any events that can modify go HERE
|
|
+ // Luminol start - Add missing teleportation apis
|
|
+ org.bukkit.Location destinationLoc;
|
|
+
|
|
+ if (pitch == null) {
|
|
+ if (yaw == null) {
|
|
+ destinationLoc = io.papermc.paper.util.MCUtil.toLocation(destination, pos, Float.NaN, Float.NaN);
|
|
+ } else {
|
|
+ destinationLoc = io.papermc.paper.util.MCUtil.toLocation(destination, pos, yaw, Float.NaN);
|
|
+ }
|
|
+ }else {
|
|
+ if (yaw == null) {
|
|
+ destinationLoc = io.papermc.paper.util.MCUtil.toLocation(destination, pos, Float.NaN, pitch);
|
|
+ }else {
|
|
+ destinationLoc = io.papermc.paper.util.MCUtil.toLocation(destination, pos, yaw, pitch);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ final me.earthme.luminol.api.entity.EntityTeleportAsyncEvent wrapped = new me.earthme.luminol.api.entity.EntityTeleportAsyncEvent(
|
|
+ this.getBukkitEntity(),
|
|
+ cause,
|
|
+ destinationLoc
|
|
+ );
|
|
+
|
|
+ wrapped.callEvent();
|
|
+ // Luminol end
|
|
|
|
// check for same region
|
|
if (destination == this.level()) {
|
|
@@ -4425,7 +4450,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
// we just select the spawn position
|
|
case END: {
|
|
if (destination.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END) {
|
|
- BlockPos targetPos = ServerLevel.END_SPAWN_POINT;
|
|
+ BlockPos targetPos = ServerLevel.END_SPAWN_POINT; // Luminol - Rename
|
|
+ // Luminol start - Add missing teleportation apis
|
|
+ final org.bukkit.Location orginalPortalLocation = io.papermc.paper.util.MCUtil.toLocation(origin, originPortal);
|
|
+ final org.bukkit.Location targetPortalLocation = io.papermc.paper.util.MCUtil.toLocation(destination, targetPos);
|
|
+
|
|
+ final me.earthme.luminol.api.portal.PortalLocateEvent portalLocateEvent = new me.earthme.luminol.api.portal.PortalLocateEvent(
|
|
+ orginalPortalLocation,
|
|
+ targetPortalLocation
|
|
+ );
|
|
+
|
|
+ portalLocateEvent.callEvent();
|
|
+ // Luminol end
|
|
// need to load chunks so we can create the platform
|
|
destination.moonrise$loadChunksAsync(
|
|
targetPos, 16, // load 16 blocks to be safe from block physics
|
|
@@ -4446,7 +4482,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
);
|
|
} else {
|
|
- BlockPos spawnPos = destination.getSharedSpawnPos();
|
|
+ BlockPos spawnPos = destination.getSharedSpawnPos(); // Luminol - Rename
|
|
+ // Luminol start - Add missing teleportation apis
|
|
+ final org.bukkit.Location orginalPortalLocation = io.papermc.paper.util.MCUtil.toLocation(origin, originPortal);
|
|
+ final org.bukkit.Location targetPortalLocation = io.papermc.paper.util.MCUtil.toLocation(destination, spawnPos);
|
|
+
|
|
+ final me.earthme.luminol.api.portal.PortalLocateEvent portalLocateEvent = new me.earthme.luminol.api.portal.PortalLocateEvent(
|
|
+ orginalPortalLocation,
|
|
+ targetPortalLocation
|
|
+ );
|
|
+
|
|
+ portalLocateEvent.callEvent();
|
|
+ // Luminol end
|
|
// need to load chunk for heightmap
|
|
destination.moonrise$loadChunksAsync(
|
|
spawnPos, 0,
|
|
@@ -4497,8 +4544,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
|
|
WorldBorder destinationBorder = destination.getWorldBorder();
|
|
double dimensionScale = net.minecraft.world.level.dimension.DimensionType.getTeleportationScale(origin.dimensionType(), destination.dimensionType());
|
|
- BlockPos targetPos = destination.getWorldBorder().clampToBounds(this.getX() * dimensionScale, this.getY(), this.getZ() * dimensionScale);
|
|
+ BlockPos targetPos = destination.getWorldBorder().clampToBounds(this.getX() * dimensionScale, this.getY(), this.getZ() * dimensionScale); // Luminol - Rename
|
|
+ // Luminol start - Add missing teleportation apis
|
|
+ final org.bukkit.Location orginalPortalLocation = io.papermc.paper.util.MCUtil.toLocation(origin, originPortal);
|
|
+ final org.bukkit.Location targetPortalLocation = io.papermc.paper.util.MCUtil.toLocation(destination, targetPos);
|
|
+
|
|
+ final me.earthme.luminol.api.portal.PortalLocateEvent portalLocateEvent = new me.earthme.luminol.api.portal.PortalLocateEvent(
|
|
+ orginalPortalLocation,
|
|
+ targetPortalLocation
|
|
+ );
|
|
|
|
+ portalLocateEvent.callEvent();
|
|
+ // Luminol end
|
|
ca.spottedleaf.concurrentutil.completable.CallbackCompletable<BlockUtil.FoundRectangle> portalFound
|
|
= new ca.spottedleaf.concurrentutil.completable.CallbackCompletable<>();
|
|
|
|
@@ -4635,6 +4692,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
if (!this.canPortalAsync(destination, takePassengers)) {
|
|
return false;
|
|
}
|
|
+ // Luminol start - Add missing teleportation events
|
|
+ if (!new me.earthme.luminol.api.entity.PreEntityPortalEvent(
|
|
+ this.getBukkitEntity(),
|
|
+ io.papermc.paper.util.MCUtil.toLocation(this.level, portalPos),
|
|
+ destination.getWorld()
|
|
+ ).callEvent()) {
|
|
+ return false;
|
|
+ }
|
|
+ // Luminol end
|
|
|
|
Vec3 initialPosition = this.position();
|
|
ChunkPos initialPositionChunk = new ChunkPos(
|
|
@@ -4702,6 +4768,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
if (teleportComplete != null) {
|
|
teleportComplete.accept(teleported);
|
|
}
|
|
+ // Kaiiju end
|
|
}
|
|
);
|
|
});
|
|
diff --git a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
index 12b9a6c16501cb0c01983c44bb247071ce675274..2dbf5064f0353b5d60d75573dc9724c3c42a25fe 100644
|
|
--- a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
+++ b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
|
@@ -193,6 +193,18 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
|
|
portalTile.trySearchForExit(portalWorld, portalPos);
|
|
return false;
|
|
}
|
|
+ // Luminol start - Add missing teleportation apis
|
|
+ final org.bukkit.Location orginalPortalLocation = io.papermc.paper.util.MCUtil.toLocation(toTeleport.level(), portalPos);
|
|
+ final org.bukkit.Location targetPortalLocation = io.papermc.paper.util.MCUtil.toLocation(portalWorld, teleportPos);
|
|
+
|
|
+ final me.earthme.luminol.api.portal.PortalLocateEvent portalLocateEvent = new me.earthme.luminol.api.portal.PortalLocateEvent(
|
|
+ orginalPortalLocation,
|
|
+ targetPortalLocation
|
|
+ );
|
|
+
|
|
+ portalLocateEvent.callEvent();
|
|
+ // Luminol end
|
|
+
|
|
|
|
// note: we handle the position from the TeleportTransition
|
|
net.minecraft.world.level.portal.TeleportTransition teleport = net.minecraft.world.level.block.EndGatewayBlock.getTeleportTransition(
|