Paper/Spigot-Server-Patches/0286-Configurable-Bed-Search-Radius.patch
Aikar 835bc39b03
Paper 1.13.1 Update
Updated Upstream (Bukkit/CraftBukkit/Spigot)

Bukkit Changes:
2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields
e0fc6572 SPIGOT-4309: Add "forced" display of particles
efeeab2f Add index to README.md for easier navigation
f502bc6f Update to Minecraft 1.13.1

CraftBukkit Changes:
d0bb0a1d Fix some tests randomly failing
997d378d Fix client stall in specific teleportation scenarios
b3dc2366 SPIGOT-4307: Fix hacky API for banners on shields
2a271162 SPIGOT-4301: Fix more invalid enchants
5d0d83bb SPIGOT-4309: Add "forced" display of particles
a6772578 Add additional tests for CraftBlockData
ce1af0c3 Update to Minecraft 1.13.1

Spigot Changes:
2440e189 Rebuild patches
4ecffced Update to Minecraft 1.13.1
2018-08-26 20:51:39 -04:00

108 Zeilen
4.4 KiB
Diff

From d05da60b77c74b53dab47f6dffb3896a8c99aefe Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 8724c2816b..fb2467636a 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -422,4 +422,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 4e60509891..47cf1db6ae 100644
--- a/src/main/java/net/minecraft/server/BlockBed.java
+++ b/src/main/java/net/minecraft/server/BlockBed.java
@@ -174,7 +174,54 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
@Nullable
public static BlockPosition a(IBlockAccess iblockaccess, BlockPosition blockposition, int i) {
+ World world = (World) iblockaccess;
+
EnumDirection enumdirection = (EnumDirection) iblockaccess.getType(blockposition).get(BlockBed.FACING);
+ // Paper - replace whole method
+ int radius = world.paperConfig.bedSearchRadius;
+ for (int r = 1; r <= radius; r++) {
+ int x = -r;
+ int z = r;
+
+ // Iterates the edge of half of the box; then negates for other half.
+ while (x <= r && z > -r) {
+ for (int y = -1; y <= 1; y++) {
+ BlockPosition pos = blockposition.add(x, y, z);
+ if (isSafeRespawn(world, pos)) {
+ if (i-- <= 0) {
+ return pos;
+ }
+ }
+ pos = blockposition.add(-x, y, -z);
+ if (isSafeRespawn(world, pos)) {
+ if (i-- <= 0) {
+ return pos;
+ }
+ }
+
+ pos = blockposition.add(enumdirection.getAdjacentX() + x, y, enumdirection.getAdjacentZ() + z);
+ if (isSafeRespawn(world, pos)) {
+ if (i-- <= 0) {
+ return pos;
+ }
+ }
+
+ pos = blockposition.add(enumdirection.getAdjacentX() - x, y, enumdirection.getAdjacentZ() - z);
+ if (isSafeRespawn(world, pos)) {
+ if (i-- <= 0) {
+ return pos;
+ }
+ }
+ }
+ if (x < r) {
+ x++;
+ } else {
+ z--;
+ }
+ }
+ }
+
+ return null; /* // Paper comment out
int j = blockposition.getX();
int k = blockposition.getY();
int l = blockposition.getZ();
@@ -200,9 +247,12 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
}
}
- return null;
+ return null;*/ // Paper
}
+ protected static boolean isSafeRespawn(IBlockAccess iblockaccess, BlockPosition blockposition) { // Paper - OBFHELPER + behavior improvement
+ return a(iblockaccess, blockposition) && iblockaccess.getType(blockposition.down()).getMaterial().isBuildable(); // Paper - ensure solid block
+ }
protected static boolean a(IBlockAccess iblockaccess, BlockPosition blockposition) {
return iblockaccess.getType(blockposition.down()).q() && !iblockaccess.getType(blockposition).getMaterial().isBuildable() && !iblockaccess.getType(blockposition.up()).getMaterial().isBuildable();
}
--
2.18.0