58 lines
3.1 KiB
Diff
58 lines
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Thu, 14 Jan 2021 16:48:10 -0600
|
|
Subject: [PATCH] Fix stuck in portals
|
|
|
|
Original code by PurpurMC, licensed under MIT
|
|
You can find the original code on https://github.com/PurpurMC/Purpur
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 56e5679a3910a6e5b25aeb0d3eb7420444296932..666189dae2400decc3d5bf97e073301e2de40472 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1153,6 +1153,7 @@ public class ServerPlayer extends Player {
|
|
playerlist.sendPlayerPermissionLevel(this);
|
|
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
|
this.unsetRemoved();
|
|
+ this.portalPos = net.minecraft.server.MCUtil.toBlockPosition(exit); // Purpur
|
|
|
|
// CraftBukkit end
|
|
this.setLevel(worldserver);
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 9630d95ad2d47bb4a043dcb143bb58cd183c00c1..69976b3fd9b50e66ca48122cdb05360a94a7f2fb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -2861,12 +2861,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
return Vec3.directionFromRotation(this.getRotationVector());
|
|
}
|
|
|
|
+ public BlockPos portalPos = BlockPos.ZERO; // Purpur
|
|
public void handleInsidePortal(BlockPos pos) {
|
|
if (this.isOnPortalCooldown()) {
|
|
+ if (!(wtf.etil.mirai.MiraiConfig.playerFixStuckPortal && this instanceof Player && !pos.equals(portalPos))) // Purpur
|
|
this.setPortalCooldown();
|
|
} else {
|
|
if (!this.level.isClientSide && !pos.equals(this.portalEntrancePos)) {
|
|
this.portalEntrancePos = pos.immutable();
|
|
+ portalPos = BlockPos.ZERO; // Purpur
|
|
}
|
|
|
|
this.isInsidePortal = true;
|
|
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
|
|
index 375a56a4fe9d1a2d32f3db32c09341d249557342..c6439c941de76384fe72cae4459461f5740026e8 100644
|
|
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
|
|
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
|
|
@@ -189,4 +189,11 @@ public class MiraiConfig {
|
|
"'{} sent expired chat: '{}'. Is the client/server system time unsynchronized?'");
|
|
}
|
|
|
|
+ public static boolean playerFixStuckPortal;
|
|
+ private static void fixStuckPortal() {
|
|
+ playerFixStuckPortal = getBoolean("player-fix-stuck-in-portal", false,
|
|
+ "Whether or not players can reset portal cooldown by",
|
|
+ "walking to another block in case they are stuck.");
|
|
+ }
|
|
+
|
|
}
|
|
\ No newline at end of file
|