Yatopia/patches/server/0031-PaperPR-Use-block-distance-in-portal-search-radius.patch

48 lines
2.8 KiB
Diff
Raw Normal View History

2020-08-11 21:29:06 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Patrick Hemmer <patrick.hemmer@gmail.com>
Date: Tue, 11 Aug 2020 22:11:53 +0300
Subject: [PATCH] PaperPR: Use block distance in portal search radius
2020-08-11 21:29:06 +02:00
Original author: Patrick Hemmer <patrick.hemmer@gmail.com>
Previously when searching for a portal, the server would use the search radius to determine which chunks it needs to search, and then would
consider any portal within those chunks as a match, even if it is outside the search radius.
This changes it so that the portal list is filtered to only include portals within the configured search radius (ignoring the Y coordinate).
Ported to Yatopia and added per world config option by MrIvanPlays <ivan@mrivanplays.com>
diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java
index 4230872de3551393a35c567d07a570dd07976fb8..febd0a7413382e059b681a43cc9ac42ab5c14128 100644
2020-08-11 21:29:06 +02:00
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java
+++ b/src/main/java/de/minebench/origami/OrigamiConfig.java
@@ -172,6 +172,11 @@ public final class OrigamiConfig {
2020-08-11 21:29:06 +02:00
&& pillagerCollisions && ironGolemCollisions && miscCollisions && itemCollisions
&& waterCreatureCollisions && waterAmbientCollisions;
}
+
+ public boolean useBlockDistanceInPortalSearchRadius = false;
+ private void useBlockDistanceInPortalSearchRadius() {
+ useBlockDistanceInPortalSearchRadius = getBoolean("use-block-distance-in-portal-search-radius", false);
+ }
// Yatopia end
}
diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java
index f6ffefd7e356c9c68cb6591cab55de9363442faf..eddf3dff9a00bf3c7318745e52befd4c04fa2af7 100644
2020-08-11 21:29:06 +02:00
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
@@ -30,6 +30,13 @@ public class PortalTravelAgent {
}); // Yatopia
// Yatopia start
java.util.List<VillagePlaceRecord> list = villageplace.b(type -> type == VillagePlaceType.v, blockposition, i, VillagePlace.Occupancy.ANY).collect(java.util.stream.Collectors.toList());
2020-08-11 21:29:06 +02:00
+ if (world.origamiConfig.useBlockDistanceInPortalSearchRadius) {
+ list.removeIf(villagePlaceRecord -> {
+ BlockPosition portalPosition = villagePlaceRecord.getPosition();
+ return Math.abs(portalPosition.getX() - blockposition.getX()) > i
+ || Math.abs(portalPosition.getZ() - blockposition.getZ()) > i;
2020-08-11 21:29:06 +02:00
+ });
+ }
2020-09-02 19:58:08 +02:00
Optional<VillagePlaceRecord> optional = Optional.empty();
if (!list.isEmpty()) {
list.sort(comparator);