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/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java index ae2bb9a73106febfe5f0d090abd4252bbb5fd27e..eee9c41e40402e52b73f34a734b4cbdeb6cfbc22 100644 --- a/io/papermc/paper/entity/activation/ActivationRange.java +++ b/io/papermc/paper/entity/activation/ActivationRange.java @@ -221,7 +221,7 @@ public final class ActivationRange { } // special cases. if (entity instanceof final LivingEntity living) { - if (living.onClimbable() || living.jumping || living.hurtTime > 0 || !living.activeEffects.isEmpty() || living.isFreezing()) { + if (living.onClimbableCached() || living.jumping || living.hurtTime > 0 || !living.activeEffects.isEmpty() || living.isFreezing()) { // Gale - Airplane - cache on climbable check - use cached return 1; } if (entity instanceof final Mob mob && mob.getTarget() != null) { diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java index 97431aa47b5425578bf14b992596962c64c87f35..e174c7b8c637e6983cf0778e6956d8d11e9cd7d1 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -2115,6 +2115,21 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin 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;