mirror of https://github.com/YatopiaMC/Yatopia.git
66 lines
3.3 KiB
Diff
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 878199d01161953811d535ae49c817c82adf9776..9f3b9b42c1509bfd71206702799421dd716e61e4 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -280,6 +280,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 074389c45965df5ab0803103e1dfc39f6fdc8cb0..8fb6b05ca4497e25272d726297536683a38f67f6 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -2394,4 +2394,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 5a04f0e506293f76bc43540142ca3b26cf97c760..0b2a9a2d9f157dd9879c4429be6745859b4f28bf 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -196,6 +196,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<>();
|