From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Martijn Muijsers Date: Wed, 23 Nov 2022 20:40:40 +0100 Subject: [PATCH] Cache on climbable check License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org This patch is based on the following patch: "Cache climbing check for activation" By: Paul Sauve As part of: Airplane (https://github.com/TECHNOVE/Airplane) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) * Airplane copyright * Airplane Copyright (C) 2020 Technove LLC This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 4ede155dc9a5f8935043f58640616c72e7898309..3b3b4adc1c1a298e15c88aa115f4137742a7ab51 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -143,7 +143,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; // CraftBukkit end -import co.aikar.timings.MinecraftTimings; // Paper public abstract class LivingEntity extends Entity { @@ -1932,6 +1931,20 @@ public abstract class LivingEntity extends Entity { return this.lastClimbablePos; } + + // Gale start - Airplane - cache on climbable check + private boolean cachedOnClimbable = false; + private BlockPos lastClimbingPosition = null; + + public boolean onClimbableCached() { + if (!this.blockPosition().equals(this.lastClimbingPosition)) { + this.cachedOnClimbable = this.onClimbable(); + this.lastClimbingPosition = this.blockPosition(); + } + return this.cachedOnClimbable; + } + // Gale end - Airplane - cache on climbable 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 1b42c98956342832c37f0aa266f85271daa4ba5b..ad1187d2a513dbfd624d15b0663e07c70dc72f3a 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.onClimbableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper // Gale - Airplane - cache on climbable check - use cached { return 1; // Paper }