mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-24 01:19:19 +00:00
64 lines
3.0 KiB
Diff
64 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Thu, 18 Aug 2022 16:31:08 +0800
|
|
Subject: [PATCH] Cache climbing check for activation
|
|
|
|
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 455d4f52dc4483c00a348e2833dfd99b1ece80f3..41489207c80f0cc9ca2abc6b1ea2d87239e07158 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1890,6 +1890,22 @@ public abstract class LivingEntity extends Entity {
|
|
return this.lastClimbablePos;
|
|
}
|
|
|
|
+ // Leaves start - cache climbing check
|
|
+ private boolean cachedOnClimable = false;
|
|
+ private BlockPos lastClimbingPosition = null;
|
|
+
|
|
+ public boolean onClimableCached() {
|
|
+ if (!top.leavesmc.leaves.LeavesConfig.cacheClimbCheck) {
|
|
+ return this.onClimbable();
|
|
+ }
|
|
+ if (!this.blockPosition().equals(this.lastClimbingPosition)) {
|
|
+ this.cachedOnClimable = this.onClimbable();
|
|
+ this.lastClimbingPosition = this.blockPosition();
|
|
+ }
|
|
+ return this.cachedOnClimable;
|
|
+ }
|
|
+ // Leaves end - cache climbing check
|
|
+
|
|
public boolean onClimbable() {
|
|
if (this.isSpectator()) {
|
|
return false;
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index 40b382c2e0e33fe5c24a51b211cd2f9557a60c5e..5da7dc703aeaa4d7c325574ea9f6fd8c3f424323 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -291,7 +291,7 @@ public class ActivationRange
|
|
if ( entity instanceof LivingEntity )
|
|
{
|
|
LivingEntity living = (LivingEntity) entity;
|
|
- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper
|
|
+ if ( living.onClimableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper // Leaves - use cached
|
|
{
|
|
return 1; // Paper
|
|
}
|
|
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
index 1203a5efe08cf6b3606f12c60672bd933718d52a..2d2cb73b4f8295ce5d60f3089c999bf4c5917a9a 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -328,6 +328,11 @@ public final class LeavesConfig {
|
|
asyncPathfinding = getBoolean("settings.performance.async-pathfinding", asyncPathfinding);
|
|
}
|
|
|
|
+ public static boolean cacheClimbCheck = true;
|
|
+ private static void cacheClimbCheck() {
|
|
+ cacheClimbCheck = getBoolean("settings.performance.cache-climb-check", cacheClimbCheck);
|
|
+ }
|
|
+
|
|
public static final class WorldConfig {
|
|
|
|
public final String worldName;
|