mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 10:59:16 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939) PaperMC/Paper@1922be90 Update custom tags (#12183) PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009) PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949) PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992) PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974) PaperMC/Paper@42b653b1 Expose more argument types (#12665) PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010) PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996) PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
49 lines
2.2 KiB
Diff
49 lines
2.2 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
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
|
index cc8f0586fca7b12a95afadb08d51077c74713ce3..ceddfed85cedbe2ddaea9ef6530688b69f087874 100644
|
|
--- a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
|
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
|
@@ -112,10 +112,33 @@ 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;
|
|
+
|
|
+ final int lowerX = sectionPos.getX() - radius;
|
|
+ final int lowerY = sectionPos.getY() - radius;
|
|
+ final int lowerZ = sectionPos.getZ() - radius;
|
|
+ final int upperX = sectionPos.getX() + radius;
|
|
+ final int upperY = sectionPos.getY() + radius;
|
|
+ final int upperZ = sectionPos.getZ() + radius;
|
|
+
|
|
+ for (int x = lowerX; x <= upperX; x++) {
|
|
+ for (int z = lowerZ; z <= upperZ; z++) {
|
|
+ for (int y = lowerY; y <= upperY; y++) {
|
|
+ SectionPos pos = SectionPos.of(x, y, z);
|
|
+ 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) {
|