mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-23 16:59:24 +00:00
33 lines
1.8 KiB
Diff
33 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sun, 6 Jul 2025 01:52:18 +0300
|
|
Subject: [PATCH] lithium: cached_iterate_outwards
|
|
|
|
By: 2No2Name <2No2Name@web.de>
|
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
|
|
diff --git a/net/minecraft/core/BlockPos.java b/net/minecraft/core/BlockPos.java
|
|
index 6518d3fff6daf331b24a7bf5b39fa1920b73711d..0dc73d76c2d86e05bedb3eb4f51d638c17390277 100644
|
|
--- a/net/minecraft/core/BlockPos.java
|
|
+++ b/net/minecraft/core/BlockPos.java
|
|
@@ -347,7 +347,18 @@ public class BlockPos extends Vec3i {
|
|
};
|
|
}
|
|
|
|
+ // DivineMC start - lithium: cached_iterate_outwards
|
|
+ private static final org.bxteam.divinemc.util.cache.IterateOutwardsCache ITERATE_OUTWARDS_CACHE = new org.bxteam.divinemc.util.cache.IterateOutwardsCache(50);
|
|
+ private static final it.unimi.dsi.fastutil.longs.LongList HOGLIN_PIGLIN_CACHE = ITERATE_OUTWARDS_CACHE.getOrCompute(8, 4, 8);
|
|
+ // DivineMC end - lithium: cached_iterate_outwards
|
|
+
|
|
public static Iterable<BlockPos> withinManhattan(BlockPos pos, int xSize, int ySize, int zSize) {
|
|
+ // DivineMC start - lithium: cached_iterate_outwards
|
|
+ if (pos != org.bxteam.divinemc.util.cache.IterateOutwardsCache.POS_ZERO) {
|
|
+ final it.unimi.dsi.fastutil.longs.LongList positions = xSize == 8 && ySize == 4 && zSize == 8 ? HOGLIN_PIGLIN_CACHE : ITERATE_OUTWARDS_CACHE.getOrCompute(xSize, ySize, zSize);
|
|
+ return new org.bxteam.divinemc.util.cache.LongList2BlockPosMutableIterable(pos, positions);
|
|
+ }
|
|
+ // DivineMC end - lithium: cached_iterate_outwards
|
|
int i = xSize + ySize + zSize;
|
|
int x1 = pos.getX();
|
|
int y1 = pos.getY();
|