Files
MiraiMC/patches/server/0039-Fix-stuck-in-portals.patch
2022-10-15 19:24:38 +02:00

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/dev/etil/mirai/MiraiConfig.java b/src/main/java/dev/etil/mirai/MiraiConfig.java
index 15e0cf25afc0a57f70af63294e5933632b409630..a907c023ec88011f2806a9c27bc27e129aa49980 100644
--- a/src/main/java/dev/etil/mirai/MiraiConfig.java
+++ b/src/main/java/dev/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
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index eb634c540842a06bfea196bc9fe4bfbd73012bf1..63e222d8a981a391b1dd01a8a10bb5df8099f922 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1157,6 +1157,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 d96422f871c18303ce7ff7a182c685b0ddbfa04d..e144637e995ed0b4bd336e2c444e2b30e083dc09 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2875,12 +2875,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 (!(dev.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;