Fix portal fuckery

This commit is contained in:
Ivan Pekov 2020-09-02 20:58:08 +03:00 committed by GitHub
parent 6866737d61
commit 921b0cdd6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 29 deletions

View File

@ -2286,10 +2286,10 @@ index 759862aba781ec6f1ae0c9a76c4ab6352d603a4c..00000000000000000000000000000000
-
- if (chunkHolder.protoChunk != null) {try (Timing ignored2 = this.world.timings.chunkLoadLevelTimer.startTimingIfSync()) { // Paper start - timings // Paper - chunk is created async
diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java
index 205f3f697e9c31674a4ac8db38467bb2e61cfe6b..e09fd73d9bbb59323a30dabdbfd9f3e1b8413541 100644
index 205f3f697e9c31674a4ac8db38467bb2e61cfe6b..6b2465bfe540af5d609160e6d232564b1d6c0617 100644
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
@@ -23,15 +23,21 @@ public class PortalTravelAgent {
@@ -23,15 +23,17 @@ public class PortalTravelAgent {
// CraftBukkit end
villageplace.a(this.world, blockposition, i);
@ -2304,16 +2304,12 @@ index 205f3f697e9c31674a4ac8db38467bb2e61cfe6b..e09fd73d9bbb59323a30dabdbfd9f3e1
- return this.world.getType(villageplacerecord.f()).b(BlockProperties.E);
- }).findFirst();
+ });
+ boolean seen = false;
+ VillagePlaceRecord best = null;
+ java.util.List<VillagePlaceRecord> list = villageplace.b(type -> type == VillagePlaceType.v, blockposition, i, VillagePlace.Occupancy.ANY).collect(java.util.stream.Collectors.toList());
+ for (VillagePlaceRecord villagePlaceRecord : list) {
+ if (!seen || comparator.compare(villagePlaceRecord, best) < 0) {
+ seen = true;
+ best = villagePlaceRecord;
+ }
+ Optional<VillagePlaceRecord> optional = Optional.empty();
+ if (!list.isEmpty()) {
+ list.sort(comparator);
+ optional = Optional.of(list.get(0));
+ }
+ Optional<VillagePlaceRecord> optional = seen ? Optional.of(best) : Optional.empty();
return optional.map((villageplacerecord) -> {
BlockPosition blockposition1 = villageplacerecord.f();

View File

@ -28,12 +28,12 @@ index 7fc45446218ee6a31abca2e16d192efff5e4aaf9..39b9372eee675b4d9ec0f41d72f149aa
}
diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java
index e09fd73d9bbb59323a30dabdbfd9f3e1b8413541..f2640522b34f72c2c53a3cd66818af82ad026f9f 100644
index 6b2465bfe540af5d609160e6d232564b1d6c0617..3c6fb2dfd4d7e8951ea5e0b93eb5b28d2078f51b 100644
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
@@ -31,12 +31,22 @@ public class PortalTravelAgent {
boolean seen = false;
VillagePlaceRecord best = null;
@@ -29,6 +29,15 @@ public class PortalTravelAgent {
return villageplacerecord.f().getY();
});
java.util.List<VillagePlaceRecord> list = villageplace.b(type -> type == VillagePlaceType.v, blockposition, i, VillagePlace.Occupancy.ANY).collect(java.util.stream.Collectors.toList());
+ // Yatopia start - fix portal bug
+ if (world.origamiConfig.useBlockDistanceInPortalSearchRadius) {
@ -43,14 +43,7 @@ index e09fd73d9bbb59323a30dabdbfd9f3e1b8413541..f2640522b34f72c2c53a3cd66818af82
+ || Math.abs(portalPosition.getZ() - blockposition.getZ()) > i;
+ });
+ }
+ if (!list.isEmpty()) {
for (VillagePlaceRecord villagePlaceRecord : list) {
if (!seen || comparator.compare(villagePlaceRecord, best) < 0) {
seen = true;
best = villagePlaceRecord;
}
}
+ } // Yatopia end
Optional<VillagePlaceRecord> optional = seen ? Optional.of(best) : Optional.empty();
return optional.map((villageplacerecord) -> {
+ // Yatopia end
Optional<VillagePlaceRecord> optional = Optional.empty();
if (!list.isEmpty()) {
list.sort(comparator);

View File

@ -114,13 +114,13 @@ index b46b20cae83e5e39ee2818c3d080b23b65bd1451..f724ca51511691f036cf03e07fea6065
Vec3D vec3d = Vec3D.a;
diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java
index f2640522b34f72c2c53a3cd66818af82ad026f9f..9bff481c60c10d460225dd2b651302b86fd103d7 100644
index 3c6fb2dfd4d7e8951ea5e0b93eb5b28d2078f51b..0b44f23b3d345df49663f4135b4b6bbf7b75f54f 100644
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
@@ -30,7 +30,7 @@ public class PortalTravelAgent {
@@ -28,7 +28,7 @@ public class PortalTravelAgent {
}).thenComparingInt((villageplacerecord) -> {
return villageplacerecord.f().getY();
});
boolean seen = false;
VillagePlaceRecord best = null;
- java.util.List<VillagePlaceRecord> list = villageplace.b(type -> type == VillagePlaceType.v, blockposition, i, VillagePlace.Occupancy.ANY).collect(java.util.stream.Collectors.toList());
+ java.util.List<VillagePlaceRecord> list = villageplace.bList(type -> type == VillagePlaceType.v, blockposition, i, VillagePlace.Occupancy.ANY); // Yatopia
// Yatopia start - fix portal bug