Add option to teleport to spawn if outside world border

This commit is contained in:
William Blake Galbreath
2025-01-07 16:57:11 -08:00
committed by granny
parent d2a0414806
commit bb8ed69b06
6 changed files with 48 additions and 75 deletions

View File

@@ -1,5 +1,18 @@
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -459,6 +_,12 @@
if (d < 0.0) {
double damagePerBlock = this.level().getWorldBorder().getDamagePerBlock();
if (damagePerBlock > 0.0) {
+ // Purpur start - Add option to teleport to spawn if outside world border
+ if (this.level().purpurConfig.teleportIfOutsideBorder && this instanceof ServerPlayer serverPlayer) {
+ serverPlayer.teleport(io.papermc.paper.util.MCUtil.toLocation(this.level(), this.level().getSharedSpawnPos()));
+ return;
+ }
+ // Purpur end - Add option to teleport to spawn if outside world border
this.hurtServer(serverLevel1, this.damageSources().outOfBorder(), Math.max(1, Mth.floor(-d * damagePerBlock)));
}
}
@@ -1788,6 +_,7 @@
boolean flag = this.lastHurtByPlayerTime > 0;
this.dropEquipment(level); // CraftBukkit - from below