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 f5252fb595683797b3f3ca3cece74d2482a79299..05f9d4c9603247802b279976d56b25cd0cf83d3a 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -150,7 +150,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 implements Attackable { @@ -2048,6 +2047,20 @@ public abstract class LivingEntity extends Entity implements Attackable { 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 3283ed99c35ffed6805567705e0518d9f84feedc..6bd07ab4bd46bc6ffd4b20132e05fccb1adf1329 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -298,7 +298,7 @@ public class ActivationRange if ( entity instanceof LivingEntity ) { LivingEntity living = (LivingEntity) entity; - if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper + if ( living.onClimbableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper // Gale - Airplane - cache on climbable check - use cached { return 1; // Paper }