mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@9b1798d6 Simplify custom payload handling (#12347) PaperMC/Paper@2552abf0 fix message mutation in PlayerSetSpawnEvent PaperMC/Paper@ae99e24f fix deprecated bungee chat api methods PaperMC/Paper@dca4aab8 add util methods to CraftChatMessage PaperMC/Paper@87c9d9b0 be more lenient on url parsing for legacy format PaperMC/Paper@4a9bd2e3 Correctly clear items in PlayerDeathEvent PaperMC/Paper@a70f7745 fix unsaveable launched trident PaperMC/Paper@41a094cf move block data/state impl PaperMC/Paper@6b26b219 remove hardcoded durability from material PaperMC/Paper@db8c646d Merge remote-tracking branch 'origin/main' into update/1.21.5
37 lines
1.8 KiB
Diff
37 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Wed, 23 Nov 2022 23:32:51 +0100
|
|
Subject: [PATCH] Optimize entity coordinate key
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following patch:
|
|
"Optimize entity coordinate key"
|
|
By: Kevin Raneri <kevin.raneri@gmail.com>
|
|
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
|
|
* Pufferfish description *
|
|
|
|
When executing getCoordinateKey for entities (a hotpath), the JVM is
|
|
required to repeatedly cast doubles to longs. The performance impact of
|
|
this depends on the CPU architecture, but generally switching between
|
|
FPU and ALU incurs a significant performance hit. The casted/rounded
|
|
data is already available in the blockPosition struct, so we use that
|
|
instead of re-doing the casting.
|
|
|
|
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 31b92bd48828cbea25b44a9f0f96886347aa1ae6..036c1a287db04c0191e5f84b027ea68d31447cbc 100644
|
|
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java
|
|
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java
|
|
@@ -16,7 +16,7 @@ public final class CoordinateUtils {
|
|
}
|
|
|
|
public static long getChunkKey(final Entity entity) {
|
|
- return ((Mth.lfloor(entity.getZ()) >> 4) << 32) | ((Mth.lfloor(entity.getX()) >> 4) & 0xFFFFFFFFL);
|
|
+ return ((long) (entity.blockPosition.getZ() >> 4) << 32) | ((entity.blockPosition.getX() >> 4) & 0xFFFFFFFFL); // Gale - Pufferfish - optimize entity coordinate key - eliminate double->long cast in hotpath
|
|
}
|
|
|
|
public static long getChunkKey(final ChunkPos pos) {
|