Yatopia/patches/server/0031-Nuke-streams-off-SectionPosition.patch

68 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Tue, 1 Sep 2020 19:21:52 +0300
Subject: [PATCH] Nuke streams off SectionPosition
diff --git a/src/main/java/net/minecraft/server/BehaviorUtil.java b/src/main/java/net/minecraft/server/BehaviorUtil.java
index d0e7c6b4c0b1e5993f0019e7a448423e048a8af5..b788685331bc28e0d339e6600b5805a2bed4cf27 100644
--- a/src/main/java/net/minecraft/server/BehaviorUtil.java
+++ b/src/main/java/net/minecraft/server/BehaviorUtil.java
@@ -84,12 +84,25 @@ public class BehaviorUtil {
public static SectionPosition a(WorldServer worldserver, SectionPosition sectionposition, int i) {
int j = worldserver.b(sectionposition);
+ // Yatopia start - replace stream
+ SectionPosition best = null;
+ for (SectionPosition pos : SectionPosition.getPosList(sectionposition, i)) {
+ if (worldserver.b(pos) < j) {
+ if (best == null || worldserver.b(pos) < worldserver.b(best)) {
+ best = pos;
+ }
+ }
+ }
+ if (best == null) best = sectionposition;
+ return best;
+ /*
Stream<SectionPosition> stream = SectionPosition.a(sectionposition, i).filter((sectionposition1) -> { // CraftBukkit - decompile error
return worldserver.b(sectionposition1) < j;
});
worldserver.getClass();
return (SectionPosition) stream.min(Comparator.comparingInt(worldserver::b)).orElse(sectionposition);
+ */ // Yatopia end
}
public static boolean a(EntityInsentient entityinsentient, EntityLiving entityliving, int i) {
diff --git a/src/main/java/net/minecraft/server/Raid.java b/src/main/java/net/minecraft/server/Raid.java
index 78f818bc7542868ec9e7caeb10a75180fb0b5e07..11f768e04d71b96350fdb586a280c52e062dfcf2 100644
--- a/src/main/java/net/minecraft/server/Raid.java
+++ b/src/main/java/net/minecraft/server/Raid.java
@@ -355,6 +355,18 @@ public class Raid {
}
private void z() {
+ // Yatopia start - replace impl
+ BlockPosition best = null;
+ for (SectionPosition pos : SectionPosition.getPosList(SectionPosition.a(center), 2)) {
+ if (world.a(pos)) {
+ BlockPosition asBlockPos = pos.q();
+ if (best == null || asBlockPos.distanceSquared(center) < best.distanceSquared(center)) {
+ best = asBlockPos;
+ }
+ }
+ }
+ if (best != null) this.c(best);
+ /*
Stream<SectionPosition> stream = SectionPosition.a(SectionPosition.a(this.center), 2);
WorldServer worldserver = this.world;
@@ -362,6 +374,7 @@ public class Raid {
stream.filter(worldserver::a).map(SectionPosition::q).min(Comparator.comparingDouble((blockposition) -> {
return blockposition.j(this.center);
})).ifPresent(this::c);
+ */ // Yatopia end
}
private Optional<BlockPosition> d(int i) {