Fix Bed respawn deviating too far from vanilla (#3195)

This commit is contained in:
Omer Uddin 2020-04-20 23:14:28 -04:00 committed by GitHub
parent 68a7b9fec8
commit eeb2f67db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
From 06cdbf697ba30e29c676c9f6ee6e4a72b0114655 Mon Sep 17 00:00:00 2001 From 9acfa558bf7e3b4f3454663fbb3804ffa9d57007 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Wed, 4 Jul 2018 15:22:06 -0400 Date: Wed, 4 Jul 2018 15:22:06 -0400
Subject: [PATCH] Configurable Bed Search Radius Subject: [PATCH] Configurable Bed Search Radius
@ -10,7 +10,7 @@ player at their bed should it of became obstructed.
Defaults to vanilla 1. Defaults to vanilla 1.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index cea15d50ed..387e0dcb9f 100644 index cea15d50e..387e0dcb9 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -377,4 +377,15 @@ public class PaperWorldConfig { @@ -377,4 +377,15 @@ public class PaperWorldConfig {
@ -30,21 +30,21 @@ index cea15d50ed..387e0dcb9f 100644
+ } + }
} }
diff --git a/src/main/java/net/minecraft/server/BlockBed.java b/src/main/java/net/minecraft/server/BlockBed.java diff --git a/src/main/java/net/minecraft/server/BlockBed.java b/src/main/java/net/minecraft/server/BlockBed.java
index 7947563426..06a35629ab 100644 index 794756342..74e915c21 100644
--- a/src/main/java/net/minecraft/server/BlockBed.java --- a/src/main/java/net/minecraft/server/BlockBed.java
+++ b/src/main/java/net/minecraft/server/BlockBed.java +++ b/src/main/java/net/minecraft/server/BlockBed.java
@@ -196,6 +196,10 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity { @@ -196,6 +196,10 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
public static Optional<Vec3D> a(EntityTypes<?> entitytypes, IWorldReader iworldreader, BlockPosition blockposition, int i) { public static Optional<Vec3D> a(EntityTypes<?> entitytypes, IWorldReader iworldreader, BlockPosition blockposition, int i) {
EnumDirection enumdirection = (EnumDirection) iworldreader.getType(blockposition).get(BlockBed.FACING); EnumDirection enumdirection = (EnumDirection) iworldreader.getType(blockposition).get(BlockBed.FACING);
+ // Paper start - configurable bed search radius + // Paper start - configurable bed search radius
+ return findSafePosition(entitytypes, (World) iworldreader, enumdirection, blockposition); + return findSafePosition(entitytypes, (World) iworldreader, enumdirection, blockposition);
+ } + }
+ /* +/*
int j = blockposition.getX(); int j = blockposition.getX();
int k = blockposition.getY(); int k = blockposition.getY();
int l = blockposition.getZ(); int l = blockposition.getZ();
@@ -224,7 +228,103 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity { @@ -224,8 +228,106 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
return Optional.empty(); return Optional.empty();
} }
@ -97,7 +97,7 @@ index 7947563426..06a35629ab 100644
+ numIterated++; + numIterated++;
+ +
+ pos = corePosition[index].add(0, h, 0); + pos = corePosition[index].add(0, h, 0);
+ vector = isSafeRespawn(entitytypes, world, pos); + vector = isSafeRespawn(entitytypes, world, pos, 0);
+ if (vector.isPresent()) { + if (vector.isPresent()) {
+ return vector; + return vector;
+ } + }
@ -117,20 +117,20 @@ index 7947563426..06a35629ab 100644
+ tmpPosition[index] = tmpPosition[index].add(tmpPositionDirection[index].getAdjacentX(), 0, tmpPositionDirection[index].getAdjacentZ()); + tmpPosition[index] = tmpPosition[index].add(tmpPositionDirection[index].getAdjacentX(), 0, tmpPositionDirection[index].getAdjacentZ());
+ pos = tmpPosition[index]; + pos = tmpPosition[index];
+ +
+ vector = isSafeRespawn(entitytypes, world, pos); + vector = isSafeRespawn(entitytypes, world, pos, 0);
+ if (vector.isPresent()) { + if (vector.isPresent()) {
+ return vector; + return vector;
+ } + }
+ } + }
+ } + }
+ switch (h) { + switch (h) {
+ case -1:
+ h = 1;
+ break;
+ case 0: + case 0:
+ h = -1; + h = -1;
+ break; + break;
+ case 1: + case -1:
+ h = -2;
+ break;
+ case -2:
+ h = Integer.MAX_VALUE; + h = Integer.MAX_VALUE;
+ break; + break;
+ } + }
@ -144,10 +144,23 @@ index 7947563426..06a35629ab 100644
+ } + }
+ // Paper end + // Paper end
+ protected static Optional<Vec3D> isSafeRespawn(EntityTypes<?> entityTypes, IWorldReader iworldreader, BlockPosition blockPosition) { return a(entityTypes, iworldreader, blockPosition); } // Paper -- obfhelper - protected static Optional<Vec3D> a(EntityTypes<?> entitytypes, IWorldReader iworldreader, BlockPosition blockposition) {
protected static Optional<Vec3D> a(EntityTypes<?> entitytypes, IWorldReader iworldreader, BlockPosition blockposition) { + // Paper start -- add maxBelow param
+ protected static Optional<Vec3D> a(EntityTypes<?> entitytypes, IWorldReader iworldreader, BlockPosition blockposition) { return isSafeRespawn(entitytypes, iworldreader, blockposition, 2); }
+ protected static Optional<Vec3D> isSafeRespawn(EntityTypes<?> entitytypes, IWorldReader iworldreader, BlockPosition blockposition, int maxBelow) {
+ // Paper end
VoxelShape voxelshape = iworldreader.getType(blockposition).getCollisionShape(iworldreader, blockposition); VoxelShape voxelshape = iworldreader.getType(blockposition).getCollisionShape(iworldreader, blockposition);
-- if (voxelshape.c(EnumDirection.EnumAxis.Y) > 0.4375D) {
2.25.1 @@ -233,7 +335,7 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
} else {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(blockposition);
- while (blockposition_mutableblockposition.getY() >= 0 && blockposition.getY() - blockposition_mutableblockposition.getY() <= 2 && iworldreader.getType(blockposition_mutableblockposition).getCollisionShape(iworldreader, blockposition_mutableblockposition).isEmpty()) {
+ while (blockposition_mutableblockposition.getY() >= 0 && blockposition.getY() - blockposition_mutableblockposition.getY() <= maxBelow && iworldreader.getType(blockposition_mutableblockposition).getCollisionShape(iworldreader, blockposition_mutableblockposition).isEmpty()) { // Paper -- configurable max distance to search below
blockposition_mutableblockposition.c(EnumDirection.DOWN);
}
--
2.22.0