9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-21 07:49:35 +00:00
Files
LeavesMC/patches/server/0038-Cache-climbing-check-for-activation.patch
2023-07-05 17:54:16 +08:00

48 lines
2.3 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 ef324b40917b3abf3b3d25dda3c8c258bdbc443e..dfce80a9e4736f8545d20713ebd4d4d0fd377a10 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1974,6 +1974,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 eda7f0bb42f7269676d5d2193e1155912ede9920..0f7064f3fa0c0d1842c92535cf6ee30f153e5e6e 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
}