9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

faster player movement checks

This commit is contained in:
Taiyou06
2025-05-11 00:06:55 +02:00
parent 06baf83a90
commit 8c56c79a35
2 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Sat, 10 May 2025 23:18:17 +0200
Subject: [PATCH] Optimise player movement checks
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 2786fbc43f238be058b153ba551f0a616c4a18f4..48c386360c331b8e1a44524951b74874a953df5e 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1149,6 +1149,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return;
}
// Gale end - VMP - skip entity move if movement is zero
+
+
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
if (this.noPhysics) {
@@ -1176,6 +1178,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
// Paper end
+ if (!org.dreeam.leaf.config.modules.opt.OptimizePlayerMovementProcessing.enabled) {
+ movement = this.maybeBackOffFromEdge(movement, type);
+ }
+
movement = this.maybeBackOffFromEdge(movement, type);
Vec3 vec3 = this.collide(movement);
double d = vec3.lengthSqr();

View File

@@ -0,0 +1,22 @@
package org.dreeam.leaf.config.modules.opt;
import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory;
public class OptimizePlayerMovementProcessing extends ConfigModules {
public String getBasePath() {
return EnumConfigCategory.PERF.getBaseKeyName();
}
public static boolean enabled = true;
@Override
public void onLoaded() {
enabled = config.getBoolean(getBasePath() + ".optimize-player-movement", enabled, config.pickStringRegionBased("""
Whether to optimize player movement processing by skipping unnecessary edge checks and avoiding redundant view distance updates.""",
"""
是否优化玩家移动处理,跳过不必要的边缘检查并避免冗余的视距更新。"""));
}
}