mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-04 18:01:17 +01:00
ea855e2b46
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Developers!: You will need to clean up your work/Minecraft/1.13.2 folder for this Also, restore a patch that was dropped in the last upstream Bukkit Changes: 279eeab3 Fix command description not being set 96e2bb18 Remove debug print from SyntheticEventTest CraftBukkit Changes:d3ed1516
Fix dangerously threaded beacons217a293d
Don't relocate joptsimple to allow --help to work.1be05a21
Prepare for imminent Java 12 releasea49270b2
Mappings Update5259d80c
SPIGOT-4669: Fix PlayerTeleportEvent coordinates for relative teleports Spigot Changes: e6eb36f2 Rebuild patches
106 lines
4.4 KiB
Diff
106 lines
4.4 KiB
Diff
From 36acae6d7bd94abfd53508a8a7e9af5729c8c990 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 74185b31f..92acfa6fb 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -443,4 +443,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 06f627002..d81a2db6c 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockBed.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockBed.java
|
|
@@ -187,6 +187,52 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
|
|
@Nullable
|
|
public static BlockPosition a(IBlockAccess iblockaccess, BlockPosition blockposition, int i) {
|
|
EnumDirection enumdirection = (EnumDirection) iblockaccess.getType(blockposition).get(BlockBed.FACING);
|
|
+ // Paper - replace whole method
|
|
+ World world = (World) iblockaccess;
|
|
+ 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();
|
|
@@ -212,9 +258,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.21.0
|
|
|