2018-12-15 01:17:27 +00:00
|
|
|
From c67f05080f86570908b8e71f87484372bbe3b7c6 Mon Sep 17 00:00:00 2001
|
2018-07-04 19:23:15 +00:00
|
|
|
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
|
2018-12-13 00:40:29 +00:00
|
|
|
index 74185b31f..92acfa6fb 100644
|
2018-07-04 19:23:15 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2018-12-13 00:40:29 +00:00
|
|
|
@@ -443,4 +443,15 @@ public class PaperWorldConfig {
|
2018-07-04 19:23:15 +00:00
|
|
|
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
|
2018-12-13 00:40:29 +00:00
|
|
|
index 06f627002..d81a2db6c 100644
|
2018-07-04 19:23:15 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockBed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockBed.java
|
2018-11-03 00:23:27 +00:00
|
|
|
@@ -187,6 +187,52 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
|
2018-07-08 07:30:40 +00:00
|
|
|
@Nullable
|
2018-07-18 23:16:19 +00:00
|
|
|
public static BlockPosition a(IBlockAccess iblockaccess, BlockPosition blockposition, int i) {
|
2018-11-03 00:23:27 +00:00
|
|
|
EnumDirection enumdirection = (EnumDirection) iblockaccess.getType(blockposition).get(BlockBed.FACING);
|
2018-07-08 07:30:40 +00:00
|
|
|
+ // Paper - replace whole method
|
2018-08-31 22:56:57 +00:00
|
|
|
+ World world = (World) iblockaccess;
|
2018-07-08 07:30:40 +00:00
|
|
|
+ int radius = world.paperConfig.bedSearchRadius;
|
|
|
|
+ for (int r = 1; r <= radius; r++) {
|
|
|
|
+ int x = -r;
|
|
|
|
+ int z = r;
|
2018-07-04 19:23:15 +00:00
|
|
|
+
|
2018-07-08 07:30:40 +00:00
|
|
|
+ // 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();
|
2018-11-03 00:23:27 +00:00
|
|
|
@@ -212,9 +258,12 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
|
2018-07-04 19:23:15 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-08 07:30:40 +00:00
|
|
|
|
|
|
|
- return null;
|
|
|
|
+ return null;*/ // Paper
|
|
|
|
}
|
|
|
|
|
2018-07-18 23:16:19 +00:00
|
|
|
+ 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
|
2018-07-08 07:30:40 +00:00
|
|
|
+ }
|
2018-07-18 23:16:19 +00:00
|
|
|
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();
|
2018-07-08 07:30:40 +00:00
|
|
|
}
|
2018-07-04 19:23:15 +00:00
|
|
|
--
|
2018-12-13 00:40:29 +00:00
|
|
|
2.20.0
|
2018-07-04 19:23:15 +00:00
|
|
|
|