mirror of https://github.com/YatopiaMC/Yatopia.git
74 lines
3.8 KiB
Diff
74 lines
3.8 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/EntityPlayer.java b/src/main/java/net/minecraft/server/level/EntityPlayer.java
|
|
index 257265a036a62c7d5fbcff17a10a41198ed880a4..da708df0dc50ea02441f9db2bfd52f04d9a8e3da 100644
|
|
--- a/src/main/java/net/minecraft/server/level/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/EntityPlayer.java
|
|
@@ -2556,4 +2556,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/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
index 135e8b14d8b295797b87b2524a084f682bbf98ab..9c4bcc691ad2f6896b28d83f386fc8daa2777a3a 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
@@ -45,6 +45,7 @@ import net.minecraft.network.syncher.DataWatcher;
|
|
import net.minecraft.network.syncher.DataWatcherObject;
|
|
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
import net.minecraft.resources.MinecraftKey;
|
|
+import net.minecraft.server.MCUtil;
|
|
import net.minecraft.server.level.ChunkProviderServer;
|
|
import net.minecraft.server.level.EntityPlayer;
|
|
import net.minecraft.server.level.WorldServer;
|
|
@@ -376,6 +377,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/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 2289c2ea20bddd4bdd93b1e25c04ed8ad8967053..22d3b094f23bde7d3195125c46bb09e7fa3c2346 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -230,6 +230,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<>();
|