From 467d4d463e522cc54f9d89594581f46ac2bb5c6e Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 4 Jul 2018 15:23:15 -0400 Subject: [PATCH] Configurable Bed Search Radius Allows you to increase how far to check for a safe place to respawn a player near their bed, allowing a better chance to respawn the player at their bed should it of became obstructed. Defaults to vanilla 1. --- .../0327-Configurable-Bed-Search-Radius.patch | 69 +++++++++++++++++++ scripts/importmcdev.sh | 1 + 2 files changed, 70 insertions(+) create mode 100644 Spigot-Server-Patches/0327-Configurable-Bed-Search-Radius.patch diff --git a/Spigot-Server-Patches/0327-Configurable-Bed-Search-Radius.patch b/Spigot-Server-Patches/0327-Configurable-Bed-Search-Radius.patch new file mode 100644 index 000000000..eb7172bb2 --- /dev/null +++ b/Spigot-Server-Patches/0327-Configurable-Bed-Search-Radius.patch @@ -0,0 +1,69 @@ +From 7c213dfb31781072573036f72bd0192cadb53146 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 4 Jul 2018 15:22:06 -0400 +Subject: [PATCH] Configurable Bed Search Radius + +Allows you to increase how far to check for a safe place to respawn +a player near their bed, allowing a better chance to respawn the +player at their bed should it of became obstructed. + +Defaults to vanilla 1. + +diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +index 06c54690f..50416f40a 100644 +--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java ++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +@@ -529,4 +529,15 @@ public class PaperWorldConfig { + private void scanForLegacyEnderDragon() { + scanForLegacyEnderDragon = getBoolean("game-mechanics.scan-for-legacy-ender-dragon", true); + } ++ ++ public int bedSearchRadius = 1; ++ private void bedSearchRadius() { ++ bedSearchRadius = getInt("bed-search-radius", 1); ++ if (bedSearchRadius < 1) { ++ bedSearchRadius = 1; ++ } ++ if (bedSearchRadius > 1) { ++ log("Bed Search Radius: " + bedSearchRadius); ++ } ++ } + } +diff --git a/src/main/java/net/minecraft/server/BlockBed.java b/src/main/java/net/minecraft/server/BlockBed.java +index 9346bddff..b12834705 100644 +--- a/src/main/java/net/minecraft/server/BlockBed.java ++++ b/src/main/java/net/minecraft/server/BlockBed.java +@@ -164,10 +164,17 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity { + int k1 = l - enumdirection.getAdjacentZ() * i1 - 1; + int l1 = j1 + 2; + int i2 = k1 + 2; +- +- for (int j2 = j1; j2 <= l1; ++j2) { +- for (int k2 = k1; k2 <= i2; ++k2) { +- BlockPosition blockposition1 = new BlockPosition(j2, k, k2); ++ // Paper start ++ int radius = world.paperConfig.bedSearchRadius - 1; ++ j1 -= radius; ++ k1 -= radius; ++ l1 += radius; ++ i2 += radius; ++ // Paper end ++ ++ for (int j2 = j1 ; j2 <= l1 ; ++j2) { ++ for (int k2 = k1 ; k2 <= i2 ; ++k2) { for (int y = -radius ; y <= radius ; y++) { // Paper ++ BlockPosition blockposition1 = new BlockPosition(j2, k + y, k2); // Paper + + if (b(world, blockposition1)) { + if (i <= 0) { +@@ -175,7 +182,7 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity { + } + + --i; +- } ++ }} // Paper + } + } + } +-- +2.18.0 + diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index b935cf79c..9e1605718 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -39,6 +39,7 @@ function import { import AxisAlignedBB import BaseBlockPosition import BiomeBase +import BlockBed import BiomeBigHills import BiomeJungle import BiomeMesa