From 89eb7a7232fa6640f89170c7623b28778f5c0261 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 1 May 2020 21:56:50 -0400 Subject: [PATCH] Use Vanilla Bed Search for non players (Villagers) Should help #2959 --- .../Configurable-Bed-Search-Radius.patch | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Spigot-Server-Patches/Configurable-Bed-Search-Radius.patch b/Spigot-Server-Patches/Configurable-Bed-Search-Radius.patch index 8ad8131a9a..75608b1267 100644 --- a/Spigot-Server-Patches/Configurable-Bed-Search-Radius.patch +++ b/Spigot-Server-Patches/Configurable-Bed-Search-Radius.patch @@ -30,7 +30,7 @@ index cea15d50ed..387e0dcb9f 100644 + } } diff --git a/src/main/java/net/minecraft/server/BlockBed.java b/src/main/java/net/minecraft/server/BlockBed.java -index 7947563426..74e915c21e 100644 +index 7947563426..e0bc6080ef 100644 --- a/src/main/java/net/minecraft/server/BlockBed.java +++ b/src/main/java/net/minecraft/server/BlockBed.java @@ -0,0 +0,0 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity { @@ -38,18 +38,16 @@ index 7947563426..74e915c21e 100644 public static Optional a(EntityTypes entitytypes, IWorldReader iworldreader, BlockPosition blockposition, int i) { EnumDirection enumdirection = (EnumDirection) iworldreader.getType(blockposition).get(BlockBed.FACING); + // Paper start - configurable bed search radius -+ return findSafePosition(entitytypes, (World) iworldreader, enumdirection, blockposition); -+ } -+/* ++ if (entitytypes == EntityTypes.PLAYER) return findSafePosition(entitytypes, (World) iworldreader, enumdirection, blockposition); ++ int j = blockposition.getX(); int k = blockposition.getY(); int l = blockposition.getZ(); @@ -0,0 +0,0 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity { - return Optional.empty(); } -+ */ -+ + +- protected static Optional a(EntityTypes entitytypes, IWorldReader iworldreader, BlockPosition blockposition) { + private static Optional findSafePosition(EntityTypes entitytypes, World world, EnumDirection updirection, BlockPosition blockposition){ + int radius = world.paperConfig.bedSearchRadius; + double angle = Math.PI / 2; @@ -143,8 +141,7 @@ index 7947563426..74e915c21e 100644 + return Optional.empty(); + } + // Paper end - -- protected static Optional a(EntityTypes entitytypes, IWorldReader iworldreader, BlockPosition blockposition) { ++ + // Paper start -- add maxBelow param + protected static Optional a(EntityTypes entitytypes, IWorldReader iworldreader, BlockPosition blockposition) { return isSafeRespawn(entitytypes, iworldreader, blockposition, 2); } + protected static Optional isSafeRespawn(EntityTypes entitytypes, IWorldReader iworldreader, BlockPosition blockposition, int maxBelow) {