mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 10:59:16 +00:00
* rebase * optimize LivingEntity#travel * cleanup * Replace fluid height map * reuse array list in Entity#collide * cleanup * fix fire and liquid collision shape * fix checkInside * inline betweenClosed * cleanup * optimize getOnPos * optimize equals in getOnPos * update mainSupportingBlockPos on dirty * cleanup * rename * merge same patch * rebase and remove properly * [ci skip] cleanup * rebase and rebuild * fix async locator * remove async locator * cleanup * rebase --------- Co-authored-by: Taiyou06 <kaandindar21@gmail.com>
24 lines
1.2 KiB
Diff
24 lines
1.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Date: Sat, 2 Nov 2024 04:15:20 -0400
|
|
Subject: [PATCH] Cache chunk key
|
|
|
|
Cache convert process in ChunkPos to the chunkKey, to avoid unnecessary casting and shift operations.
|
|
This patch didn't cahce SectionPos or BlockPos to chunkKey, since they are mutable after creation.
|
|
|
|
The JMH benchmark of this patch can be found in SunBox's `CacheChunkKey`
|
|
|
|
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java b/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java
|
|
index bb5b9c9cb0c73edce1dbe3758ee2db0fcc8f4e40..e9ed38430e15d51692004dbf2a1110abc77b31d2 100644
|
|
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java
|
|
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java
|
|
@@ -21,7 +21,7 @@ public final class CoordinateUtils {
|
|
}
|
|
|
|
public static long getChunkKey(final ChunkPos pos) {
|
|
- return ((long)pos.z << 32) | (pos.x & 0xFFFFFFFFL);
|
|
+ return ((long)pos.z << 32) | (pos.x & 0xFFFFFFFFL); // Leaf - Cache chunk key - diff on change
|
|
}
|
|
|
|
public static long getChunkKey(final SectionPos pos) {
|