mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-30 20:39:21 +00:00
ClassInstanceMultiMap belongs to Minecraft vanilla entity storage. And is unused, since replaced by spottedleaf's entity storage (rewrite chunk system). However these patches might be useful for vanilla entity storage if is used.
54 lines
3.0 KiB
Diff
54 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Wed, 19 Mar 2025 15:18:58 +0100
|
|
Subject: [PATCH] Remove streams on InsideBrownianWalk
|
|
|
|
This method is mainly visible when ton of villagers suddenly wants to sleep
|
|
Safe optimization, no need to provide any numbers.
|
|
|
|
diff --git a/net/minecraft/world/entity/ai/behavior/InsideBrownianWalk.java b/net/minecraft/world/entity/ai/behavior/InsideBrownianWalk.java
|
|
index cbde74f4b6d586a5f80cdd675573441636bf682d..2324b941c7513692608b5146bc90c8e6124d2ee6 100644
|
|
--- a/net/minecraft/world/entity/ai/behavior/InsideBrownianWalk.java
|
|
+++ b/net/minecraft/world/entity/ai/behavior/InsideBrownianWalk.java
|
|
@@ -20,16 +20,31 @@ public class InsideBrownianWalk {
|
|
return false;
|
|
} else {
|
|
BlockPos blockPos = mob.blockPosition();
|
|
- List<BlockPos> list = BlockPos.betweenClosedStream(blockPos.offset(-1, -1, -1), blockPos.offset(1, 1, 1))
|
|
- .map(BlockPos::immutable)
|
|
- .collect(Util.toMutableList());
|
|
+ // Leaf start - Remove streams on InsideBrownianWalk
|
|
+ BlockPos minPos = blockPos.offset(-1, -1, -1);
|
|
+ BlockPos maxPos = blockPos.offset(1, 1, 1);
|
|
+ List<BlockPos> list = new java.util.ArrayList<>();
|
|
+
|
|
+ for (int x = minPos.getX(); x <= maxPos.getX(); x++) {
|
|
+ for (int y = minPos.getY(); y <= maxPos.getY(); y++) {
|
|
+ for (int z = minPos.getZ(); z <= maxPos.getZ(); z++) {
|
|
+ list.add(new BlockPos(x, y, z).immutable());
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
Collections.shuffle(list);
|
|
- list.stream()
|
|
- .filter(pos -> !level.canSeeSky(pos))
|
|
- .filter(pos -> level.loadedAndEntityCanStandOn(pos, mob))
|
|
- .filter(pos -> level.noCollision(mob))
|
|
- .findFirst()
|
|
- .ifPresent(pos -> walkTarget.set(new WalkTarget(pos, speedModifier, 0)));
|
|
+
|
|
+ for (BlockPos pos : list) {
|
|
+ if (!level.canSeeSky(pos) &&
|
|
+ level.loadedAndEntityCanStandOn(pos, mob) &&
|
|
+ level.noCollision(mob)) {
|
|
+ walkTarget.set(new WalkTarget(pos, speedModifier, 0));
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ // Leaf end - Remove streams on InsideBrownianWalk
|
|
+
|
|
return true;
|
|
}
|
|
}
|