mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-22 16:39:22 +00:00
37 lines
1.7 KiB
Diff
37 lines
1.7 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/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
|
index 800bc29502ed46bd77cb04c0a79143898f109a48..77fa472d970c0f187f228b06e0b459ebdcaeb7fd 100644
|
|
--- a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
|
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
|
@@ -109,10 +109,20 @@ public class BehaviorUtils {
|
|
|
|
public static SectionPos findSectionClosestToVillage(ServerLevel serverLevel, SectionPos sectionPos, int radius) {
|
|
int i = serverLevel.sectionsToVillage(sectionPos);
|
|
- return SectionPos.cube(sectionPos, radius)
|
|
- .filter(pos -> serverLevel.sectionsToVillage(pos) < i)
|
|
- .min(Comparator.comparingInt(serverLevel::sectionsToVillage))
|
|
- .orElse(sectionPos);
|
|
+ // Leaf start - Remove stream in BehaviorUtils
|
|
+ SectionPos closestSection = sectionPos;
|
|
+ int closestDistance = i;
|
|
+
|
|
+ for (SectionPos pos : SectionPos.cube(sectionPos, radius).toList()) {
|
|
+ int distance = serverLevel.sectionsToVillage(pos);
|
|
+ if (distance < closestDistance) {
|
|
+ closestDistance = distance;
|
|
+ closestSection = pos;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return closestSection;
|
|
+ // Leaf end - Remove stream in BehaviorUtils
|
|
}
|
|
|
|
public static boolean isWithinAttackRange(Mob mob, LivingEntity target, int cooldown) {
|