Files
Shiroha/shiroha-server/minecraft-patches/features/0067-Gale-Reduce-enderman-teleport-chunk-lookups.patch
T

59 lines
2.6 KiB
Diff
Raw Normal View History

2026-07-09 00:03:09 +08:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Thu, 4 Jun 2026 17:22:55 +0800
Subject: [PATCH] Gale: Reduce enderman teleport chunk lookups
License: GPL-3.0-only (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://github.com/GaleMC/Gale
This patch is based on the following patch:
"Reduce chunk loading & lookups"
By: Paul Sauve <paul@technove.co>
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
Licensed under: GPL-3.0-only (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 <https://www.gnu.org/licenses/>.
diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java
index 9b4ae8afda1f2202761cb49bc4f1181ce4eb55d5..d2ac2a0c5bb18c2bca18e5166ed65afd01166e04 100644
--- a/net/minecraft/world/entity/monster/EnderMan.java
+++ b/net/minecraft/world/entity/monster/EnderMan.java
@@ -298,11 +298,19 @@ public class EnderMan extends Monster implements NeutralMob {
private boolean teleport(final double x, final double y, final double z) {
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(x, y, z);
- while (pos.getY() > this.level().getMinY() && !this.level().getBlockState(pos).blocksMotion()) {
+ // Gale start - Airplane - single chunk lookup
+ net.minecraft.world.level.chunk.LevelChunk chunk = this.level().getChunkIfLoaded(pos);
+
+ if (chunk == null) {
+ return false;
+ }
+
+ while (pos.getY() > this.level().getMinY() && !chunk.getBlockState(pos).blocksMotion()) {
+ // Gale end - Airplane - single chunk lookup
pos.move(Direction.DOWN);
}
- BlockState blockState = this.level().getBlockState(pos);
+ BlockState blockState = chunk.getBlockState(pos); // Gale - Airplane - single chunk lookup
boolean couldStandOn = blockState.blocksMotion();
boolean isWet = blockState.getFluidState().is(FluidTags.WATER);
if (couldStandOn && !isWet) {