mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-08-23 14:22:47 +02:00
62 lines
3.4 KiB
Diff
62 lines
3.4 KiB
Diff
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] Use block distance in portal search radius
|
|
|
|
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 1d98bfdee95fb1052fcd9f141a2ab82ba9dcf2f9..9549b857020bb749c039420950684c74c1108945 100644
|
|
--- a/src/main/java/de/minebench/origami/OrigamiConfig.java
|
|
+++ b/src/main/java/de/minebench/origami/OrigamiConfig.java
|
|
@@ -165,6 +165,11 @@ public final class OrigamiConfig {
|
|
&& 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 97fadc4a1fa7859a07dc5d6c122beb66ca01c97f..b4e1487489228b37af23f35033cf0892c7afce5f 100644
|
|
--- a/src/main/java/net/minecraft/server/PortalTravelAgent.java
|
|
+++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java
|
|
@@ -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) {
|
|
+ list.removeIf(villagePlaceRecord -> {
|
|
+ BlockPosition portalPosition = villagePlaceRecord.getPosition();
|
|
+ return Math.abs(portalPosition.getX() - blockposition.getX()) > i
|
|
+ || Math.abs(portalPosition.getZ() - blockposition.getZ()) > i;
|
|
+ });
|
|
+ }
|
|
+ // Yatopia end
|
|
Optional<VillagePlaceRecord> optional = Optional.empty();
|
|
if (!list.isEmpty()) {
|
|
list.sort(comparator);
|
|
diff --git a/src/main/java/net/minecraft/server/VillagePlaceRecord.java b/src/main/java/net/minecraft/server/VillagePlaceRecord.java
|
|
index 0b40c2f4dada7d8432e3f91e9cf206c2bda3b24b..c8c231f3d5e8e495ebb9a27ae18f7665cb263330 100644
|
|
--- a/src/main/java/net/minecraft/server/VillagePlaceRecord.java
|
|
+++ b/src/main/java/net/minecraft/server/VillagePlaceRecord.java
|
|
@@ -62,6 +62,7 @@ public class VillagePlaceRecord {
|
|
return this.c != this.b.b();
|
|
}
|
|
|
|
+ public final BlockPosition getPosition() { return f(); } // Yatopia - OBFHELPER
|
|
public BlockPosition f() {
|
|
return this.a;
|
|
}
|