mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +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 0fea7b506a65d21161a538c68579982a98ca98c7..557a92bfaecf3f1bddd4c602a26a7d5373f9798d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1938,6 +1938,22 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
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 52780192d6417f8085566e4cdf3a895a83638520..eeb3522c39dde84e497d22758e90b42f3a2d5a96 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -292,7 +292,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 ab7613a1ccfc6117f8b4eed72bdaa6730b8238d3..136bd381e68318f5b2afd3616fb13e580aa0cc49 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -359,6 +359,11 @@ public final class LeavesConfig {
|
|
}
|
|
}
|
|
|
|
+ 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;
|