9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-22 16:29:26 +00:00
Files
Gale/patches/server/0015-Reduce-enderman-teleport-chunk-lookups.patch
2022-11-29 15:20:19 +01:00

56 lines
2.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MartijnMuijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 19:53:35 +0100
Subject: [PATCH] Reduce enderman teleport chunk lookups
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
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 (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 <http://www.gnu.org/licenses/>.
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index f22e615dba31619c97bf58930da060476a52facf..f9b34853c8c37bf622f30c40b795929c05aac725 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -317,11 +317,17 @@ public class EnderMan extends Monster implements NeutralMob {
private boolean teleport(double x, double y, double z) {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z);
- while (blockposition_mutableblockposition.getY() > this.level.getMinBuildHeight() && !this.level.getBlockState(blockposition_mutableblockposition).getMaterial().blocksMotion()) {
+ // Gale start - Airplane - single chunk lookup
+ net.minecraft.world.level.chunk.LevelChunk chunk = this.level.getChunkIfLoaded(blockposition_mutableblockposition);
+ if (chunk == null) {
+ return false;
+ }
+ while (blockposition_mutableblockposition.getY() > this.level.getMinBuildHeight() && !chunk.getBlockState(blockposition_mutableblockposition).getMaterial().blocksMotion()) {
+ // Gale end - Airplane - single chunk lookup
blockposition_mutableblockposition.move(Direction.DOWN);
}
- BlockState iblockdata = this.level.getBlockState(blockposition_mutableblockposition);
+ BlockState iblockdata = chunk.getBlockState(blockposition_mutableblockposition); // Gale - Airplane - single chunk lookup
boolean flag = iblockdata.getMaterial().blocksMotion();
boolean flag1 = iblockdata.getFluidState().is(FluidTags.WATER);