9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/patches/server/0080-Remove-stream-in-BehaviorUtils.patch
2024-12-31 21:51:59 -05:00

37 lines
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
Date: Sat, 26 Oct 2024 00:56:24 +0800
Subject: [PATCH] Remove stream in BehaviorUtils
Dreeam TODO: Check this
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
index 25dacd924f182d197bcbdcd7c1d8caa482fd8d37..3f8a90e3fab1ace796d2433b90a2472a7a143968 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
@@ -121,12 +121,20 @@ public class BehaviorUtils {
public static SectionPos findSectionClosestToVillage(ServerLevel world, SectionPos center, int radius) {
int j = world.sectionsToVillage(center);
- Stream<SectionPos> stream = SectionPos.cube(center, radius).filter((sectionposition1) -> { // CraftBukkit - decompile error
- return world.sectionsToVillage(sectionposition1) < j;
- });
+ // Leaf start - Remove stream in BehaviorUtils
+ SectionPos closestSection = center;
+ int closestDistance = j;
Objects.requireNonNull(world);
- return (SectionPos) stream.min(Comparator.comparingInt(world::sectionsToVillage)).orElse(center);
+ for (SectionPos sectionPosition : SectionPos.cube(center, radius).toList()) {
+ int distance = world.sectionsToVillage(sectionPosition);
+ if (distance < closestDistance) {
+ closestDistance = distance;
+ closestSection = sectionPosition;
+ }
+ }
+ return closestSection;
+ // Leaf end - Remove stream in BehaviorUtils
}
public static boolean isWithinAttackRange(Mob mob, LivingEntity target, int rangedWeaponReachReduction) {