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

68 lines
3.0 KiB
Diff
Raw Normal View History

2020-09-02 21:06:17 +02:00
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 f7f97d441b3b7c4bd6bc34d2ce3fae5f6f5721c8..86726f48f7cdf98379da050a5d41acd40dd4db83 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) {