From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Mon, 20 Apr 2026 01:10:30 +0800 Subject: [PATCH] Entity portal-teleport speed fix diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java index 35ab432bbd59aba80a6eaca1769e6aa82c8a7e46..e541189887f446844ffd77ff099d1f4dba556fe9 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -1492,7 +1492,31 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet foliaProfiler.startTimer(timerId); try { // Folia end - profiler + // Shiroha start - Entity portal-teleport speed fix if (isActive) { // Paper - EAR 2 + if (!(entity instanceof Player) && entity.teleportTickType == io.nanachiyo0721.shiroha.enums.EnumTeleportStage.NEED_SYNC) { // Luminol - after portal compensate tick + entity.tick(); + while (entity.losingTicks-- > 0) { + entity.tick(); + } + entity.teleportTickType = io.nanachiyo0721.shiroha.enums.EnumTeleportStage.NORMAL; + if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) { + return; + } + if (entity.handlePortal()) { + return; + } + } else if (!(entity instanceof Player) && entity.teleportTickType == io.nanachiyo0721.shiroha.enums.EnumTeleportStage.STOP_TICKING) { // Luminol - portal teleport only + if (io.nanachiyo0721.shiroha.config.modules.fixes.TeleportConfig.enableDelayCompensation && entity.losingTicks < io.nanachiyo0721.shiroha.config.modules.fixes.TeleportConfig.maxDelayCompensationTicks) { + entity.losingTicks++; + } + if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) { + return; + } + if (entity.handlePortal()) { + return; + } + } else { entity.tick(); // Folia start - region threading if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) { @@ -1503,6 +1527,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet // portalled return; } + } + // Shiroha end - Entity portal-teleport speed fix // Folia end - region threading } else {entity.inactiveTick();} // Paper - EAR 2 profiler.pop(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java index 75dabd3e7b6077b5ae8ee30048786442742b93f9..5d4d4d07cae83a98fcf16370c98a5118c39e1f5a 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -388,6 +388,8 @@ public abstract class Entity public long activatedTick = Integer.MIN_VALUE; public boolean isTemporarilyActive; public long activatedImmunityTick = Integer.MIN_VALUE; + public io.nanachiyo0721.shiroha.enums.EnumTeleportStage teleportTickType = io.nanachiyo0721.shiroha.enums.EnumTeleportStage.NORMAL; // Shiroha - Entity portal-teleport speed fix + public int losingTicks = 0; // Shiroha - Entity portal-teleport speed fix public void inactiveTick() { } @@ -3597,6 +3599,7 @@ public abstract class Entity } else { if (this.portalProcess == null || !this.portalProcess.isSamePortal(portal)) { this.portalProcess = new PortalProcessor(portal, pos.immutable()); + this.teleportTickType = io.nanachiyo0721.shiroha.enums.EnumTeleportStage.STOP_TICKING; // Shiroha - Entity portal-teleport speed fix } else if (!this.portalProcess.isInsidePortalThisTick()) { this.portalProcess.updateEntryPosition(pos.immutable()); this.portalProcess.setAsInsidePortalThisTick(true); @@ -4559,6 +4562,7 @@ public abstract class Entity public void postChangeDimension() { this.resetStoredPositions(); + this.teleportTickType = io.nanachiyo0721.shiroha.enums.EnumTeleportStage.NEED_SYNC; // Shiroha - Entity portal-teleport speed fix } protected static enum PortalType {