From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: NanaChiyo0721 Date: Mon, 27 Jul 2026 20:43:17 +0800 Subject: [PATCH] Kaiiju: Vanilla end portal teleportation Co-authored by: Sofiane H. Djerbi <46628754+kugge@users.noreply.github.com> As part of: Kaiiju (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2ec408e6411e6f752379da/patches/server/0024-Vanilla-end-portal-teleportation.patch) Licensed under: GPL-3.0 (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2ec408e6411e6f752379da/LICENSE) diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java index 34dff91f9694b6a884bac2039891d05fdec7c12c..453261efff85beec55fb0f9796be0269470670af 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -4660,15 +4660,19 @@ public abstract class Entity targetPos, 16, // load 16 blocks to be safe from block physics ca.spottedleaf.concurrentutil.util.Priority.HIGH, (chunks) -> { - net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, targetPos.below(), true, null); - + //net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, targetPos.below(), true, null); // Kaiiju - Vanilla end teleportation - moved down + // Kaiiju start - Vanilla end teleportation + Vec3 finalPos; + if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(targetPos.below()); + else finalPos = Vec3.atBottomCenterOf(targetPos); + // Kaiiju end // the portal obsidian is placed at targetPos.y - 2, so if we want to place the entity // on the obsidian, we need to spawn at targetPos.y - 1 portalInfoCompletable.complete( new net.minecraft.world.level.portal.TeleportTransition( - destination, Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, Direction.WEST.toYRot(), 0.0f, + destination, finalPos, this.getDeltaMovement(), Direction.WEST.toYRot(), 0.0f, // Kaiiju - Vanilla end teleportation false, false, - Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)), + java.util.Collections.EMPTY_SET, // Kaiiju - Vanilla end teleportation TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL, TeleportTransition.PassengerTeleportationMode.POSITION_RIDER @@ -4684,13 +4688,17 @@ public abstract class Entity ca.spottedleaf.concurrentutil.util.Priority.HIGH, (chunks) -> { BlockPos adjustedSpawn = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, spawnPos); - + // Kaiiju start - Vanilla end teleportation + Vec3 finalPos; + if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(adjustedSpawn.below()); + else finalPos = Vec3.atBottomCenterOf(adjustedSpawn); + // Kaiiju end // done portalInfoCompletable.complete( new net.minecraft.world.level.portal.TeleportTransition( - destination, Vec3.atBottomCenterOf(adjustedSpawn), Vec3.ZERO, 0.0f, 0.0f, + destination, finalPos, this.getDeltaMovement(), 0.0f, 0.0f, // Kaiiju - Vanilla end teleportation false, false, - Relative.union(Relative.DELTA, Relative.ROTATION), + java.util.Collections.EMPTY_SET, // Kaiiju - Vanilla end teleportation TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL, TeleportTransition.PassengerTeleportationMode.POSITION_RIDER @@ -4869,6 +4877,10 @@ public abstract class Entity return false; } + // Kaiiju start - sync end platform spawning & entity teleportation + final java.util.function.Consumer tpComplete = type == PortalType.END && destination.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END ? + e -> {net.minecraft.world.level.levelgen.feature.EndPlatformFeature.createEndPlatform(destination, ServerLevel.END_SPAWN_POINT.below(), true, null); if (teleportComplete != null) {teleportComplete.accept(e);}} : teleportComplete; + // Kaiiju end Vec3 initialPosition = this.position(); ChunkPos initialPositionChunk = new ChunkPos( ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(initialPosition), @@ -4932,9 +4944,14 @@ public abstract class Entity info.postTeleportTransition().onTransition(teleported); } - if (teleportComplete != null) { + // Kaiiju start - vanilla end teleportation + /*if (teleportComplete != null) { teleportComplete.accept(teleported); + }*/ + if (tpComplete != null){ + tpComplete.accept(teleported); } + // Kaiiju end } ); });