Files
Purpur/patches/server/0090-Add-option-to-teleport-to-spawn-if-outside-world-bor.patch
BillyGalbreath 4e8a150377 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
98a702c7d [CI-SKIP] [Auto] Rebuild Patches
cab361600 Expose LivingEntity hurt direction
7ef05fbd8 Do not perform neighbour updates when using debug stick (Fixes #2134)
2020-12-23 00:45:57 -06:00

66 lines
3.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/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 92095d28bfdcf309585b5684be3b880591b7d18c..e2635413da43f4afc412c0443ab99bc3aaa0ca33 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -277,6 +277,7 @@ public abstract class EntityLiving extends Entity {
double d1 = this.world.getWorldBorder().getDamageAmount();
if (d1 > 0.0D) {
+ if (world.purpurConfig.teleportIfOutsideBorder && this instanceof EntityPlayer) { ((EntityPlayer) this).teleport(MCUtil.toLocation(world, world.getSpawn())); return; } // Purpur
this.damageEntity(DamageSource.STUCK, (float) Math.max(1, MathHelper.floor(-d0 * d1)));
}
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 4caca2cb5ce981aa555ceb7464fedc9e32779d88..0d4ab4e8eda4059fbafe7645c9627ab5566edd85 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -2378,4 +2378,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
return (CraftPlayer) super.getBukkitEntity();
}
// CraftBukkit end
+
+ // Purpur start
+ public void teleport(Location to) {
+ this.ejectPassengers();
+ this.stopRiding(true);
+
+ if (this.isSleeping()) {
+ this.wakeup(true, false);
+ }
+
+ if (this.activeContainer != this.defaultContainer) {
+ this.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT);
+ }
+
+ WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();
+ if (this.world == toWorld) {
+ this.playerConnection.teleport(to);
+ } else {
+ this.server.getPlayerList().moveToWorld(this, toWorld, true, to, !toWorld.paperConfig.disableTeleportationSuffocationCheck);
+ }
+ }
+ // Purpur end
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 2f326f88257f5a45deee872865211d15fc67fac6..73027d6eed7b93fa8b9f580235259a262d50b96d 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -178,6 +178,11 @@ public class PurpurWorldConfig {
playerInvulnerableWhileAcceptingResourcePack = getBoolean("gameplay-mechanics.player.invulnerable-while-accepting-resource-pack", playerInvulnerableWhileAcceptingResourcePack);
}
+ public boolean teleportIfOutsideBorder = false;
+ private void teleportIfOutsideBorder() {
+ teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder);
+ }
+
public boolean silkTouchEnabled = false;
public String silkTouchSpawnerName = "Spawner";
public List<String> silkTouchSpawnerLore = new ArrayList<>();