mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@608482d cleanup filtered sign text (#7777) PaperMC/Paper@4166632 Updated Upstream (Bukkit/CraftBukkit) (#7776) PaperMC/Paper@e564110 Couple fixes/improvements to PlayerSetSpawnEvent (#6754) PaperMC/Paper@e5da93a Deprecate duplicate SoundGroup API (#7509)
78 lines
4.3 KiB
Diff
78 lines
4.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Mon, 13 Jul 2020 11:40:00 -0500
|
|
Subject: [PATCH] Add option to teleport to spawn if outside world border
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 54c6433daec4574fd1653a73fa80761ddf49549e..697b48d1234c8faa426c7dc67bd0fcc2a9cbd696 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -2544,4 +2544,26 @@ public class ServerPlayer extends Player {
|
|
// CraftBukkit end
|
|
|
|
public final int getViewDistance() { throw new UnsupportedOperationException("Use PlayerChunkLoader"); } // Paper - placeholder
|
|
+
|
|
+ // Purpur start
|
|
+ public void teleport(Location to) {
|
|
+ this.ejectPassengers();
|
|
+ this.stopRiding(true);
|
|
+
|
|
+ if (this.isSleeping()) {
|
|
+ this.stopSleepInBed(true, false);
|
|
+ }
|
|
+
|
|
+ if (this.containerMenu != this.inventoryMenu) {
|
|
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT);
|
|
+ }
|
|
+
|
|
+ ServerLevel toLevel = ((CraftWorld) to.getWorld()).getHandle();
|
|
+ if (this.level == toLevel) {
|
|
+ this.connection.teleport(to);
|
|
+ } else {
|
|
+ this.server.getPlayerList().respawn(this, toLevel, true, to, !toLevel.paperConfig.disableTeleportationSuffocationCheck);
|
|
+ }
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index a50035eae2faec356bb8cc3956ae39618f8dace2..36008beb94e69ddfa37c7610c7f8174b21157f45 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -45,6 +45,7 @@ import net.minecraft.network.syncher.EntityDataAccessor;
|
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
|
import net.minecraft.network.syncher.SynchedEntityData;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
+import net.minecraft.server.MCUtil;
|
|
import net.minecraft.server.level.ServerChunkCache;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
@@ -409,6 +410,7 @@ public abstract class LivingEntity extends Entity {
|
|
double d1 = this.level.getWorldBorder().getDamagePerBlock();
|
|
|
|
if (d1 > 0.0D) {
|
|
+ if (level.purpurConfig.teleportIfOutsideBorder && this instanceof ServerPlayer) { ((ServerPlayer) this).teleport(MCUtil.toLocation(level, ((ServerLevel) level).getSharedSpawnPos())); return; } // Purpur
|
|
this.hurt(DamageSource.IN_WALL, (float) Math.max(1, Mth.floor(-d0 * d1)));
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
index d25af1733601d26b6d2173837a0a5948ae01a6d4..a9a3f13a64cd7d9152f65285a5f5f48f5a31b7a3 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -243,6 +243,7 @@ public class PurpurWorldConfig {
|
|
public boolean playerInvulnerableWhileAcceptingResourcePack = false;
|
|
public String playerDeathExpDropEquation = "expLevel * 7";
|
|
public int playerDeathExpDropMax = 100;
|
|
+ public boolean teleportIfOutsideBorder = false;
|
|
private void playerSettings() {
|
|
if (PurpurConfig.version < 19) {
|
|
boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer);
|
|
@@ -258,6 +259,7 @@ public class PurpurWorldConfig {
|
|
playerInvulnerableWhileAcceptingResourcePack = getBoolean("gameplay-mechanics.player.invulnerable-while-accepting-resource-pack", playerInvulnerableWhileAcceptingResourcePack);
|
|
playerDeathExpDropEquation = getString("gameplay-mechanics.player.exp-dropped-on-death.equation", playerDeathExpDropEquation);
|
|
playerDeathExpDropMax = getInt("gameplay-mechanics.player.exp-dropped-on-death.maximum", playerDeathExpDropMax);
|
|
+ teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder);
|
|
}
|
|
|
|
public boolean silkTouchEnabled = false;
|