From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Thu, 14 Jan 2021 16:48:10 -0600 Subject: [PATCH] Fix stuck in portals diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java index 976dfffac3895015d0eb00bab0ea93f9e5cc27a2..430ea84cbca69b6d119c2739bed9de37a970c2e5 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -1687,6 +1687,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); // CraftBukkit end + this.portalPos = io.papermc.paper.util.MCUtil.toBlockPosition(exit); // Purpur - Fix stuck in portals this.setServerLevel(worldserver); this.connection.internalTeleport(PositionMoveRotation.of(teleportTarget), teleportTarget.relatives()); // CraftBukkit - use internal teleport without event this.connection.resetPosition(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 106dadefc463ba1f59e89e9c5d1386b0eda40d48..93468974af35aa2f4f72d80b72aabe2dc8519f9e 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -3470,14 +3470,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return Vec3.directionFromRotation(this.getRotationVector()); } + public BlockPos portalPos = BlockPos.ZERO; // Purpur public void setAsInsidePortal(Portal portal, BlockPos pos) { if (this.isOnPortalCooldown()) { + if (!(level().purpurConfig.playerFixStuckPortal && this instanceof Player && !pos.equals(this.portalPos))) // Purpur - Fix stuck in portals this.setPortalCooldown(); } else if (this.level.purpurConfig.entitiesCanUsePortals || this instanceof ServerPlayer) { // Purpur - Entities can use portals if (this.portalProcess != null && this.portalProcess.isSamePortal(portal)) { if (!this.portalProcess.isInsidePortalThisTick()) { this.portalProcess.updateEntryPosition(pos.immutable()); this.portalProcess.setAsInsidePortalThisTick(true); + this.portalPos = BlockPos.ZERO; // Purpur - Fix stuck in portals } } else { this.portalProcess = new PortalProcessor(portal, pos.immutable()); diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index c51747bf291561359b028500652e556f677a0aa0..0347b0d83a9824a355bdcaaaf36f98fd6828effd 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -327,6 +327,7 @@ public class PurpurWorldConfig { public int playerDeathExpDropMax = 100; public boolean teleportIfOutsideBorder = false; public boolean totemOfUndyingWorksInInventory = false; + public boolean playerFixStuckPortal = false; private void playerSettings() { if (PurpurConfig.version < 19) { boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer); @@ -342,6 +343,7 @@ public class PurpurWorldConfig { playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax); teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder); totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory); + playerFixStuckPortal = getBoolean("gameplay-mechanics.player.fix-stuck-in-portal", playerFixStuckPortal); } public boolean silkTouchEnabled = false;