mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-22 08:29:22 +00:00
Update MC Technical Survival Mode
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Sun, 14 Aug 2022 08:17:28 +0800
|
||||
Subject: [PATCH] Optimize entity coordinate key
|
||||
|
||||
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index d1a59c2af0557a816c094983ec60097fb4de060c..25e77520f269e25492d14d498f51c16b5c0c3c2d 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -209,7 +209,13 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final Entity entity) {
|
||||
- return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL);
|
||||
+ // Leaves start - eliminate double -> long cast in hotpath
|
||||
+ if (top.leavesmc.leaves.LeavesConfig.optimizeEntityCoordinateKey) {
|
||||
+ return ((long)(entity.blockPosition.getZ() >> 4) << 32) | ((entity.blockPosition.getX() >> 4) & 0xFFFFFFFFL);
|
||||
+ } else {
|
||||
+ return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL);
|
||||
+ }
|
||||
+ // Leaves end - eliminate double -> long cast in hotpath
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final ChunkPos pair) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 07755625a713359e468eb907fdc7667e719a28a7..a4f32bb4d474c97e9b924e1d275f640ddfedc31f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -291,7 +291,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
public double yo;
|
||||
public double zo;
|
||||
private Vec3 position;
|
||||
- private BlockPos blockPosition;
|
||||
+ public BlockPos blockPosition; // Leaves - private -> public
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
||||
private float yRot;
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index 1476e2433ed07d3e1ec86ee0e3a84c7e6f16a147..5856270f8f4e0eb6b89ed36b361af958066d341c 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -254,6 +254,12 @@ public final class LeavesConfig {
|
||||
fixPaper6045 = getBoolean("settings.performance.fix.fix-paper-6045", fixPaper6045);
|
||||
}
|
||||
|
||||
+ public static boolean optimizeEntityCoordinateKey = true;
|
||||
+ private static void optimizeEntityCoordinateKey() {
|
||||
+ optimizeEntityCoordinateKey = getBoolean("settings.performance.optimize-entity-coordinate-key", optimizeEntityCoordinateKey);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
public static final class WorldConfig {
|
||||
|
||||
public final String worldName;
|
||||
Reference in New Issue
Block a user