9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0024-Reduce-chunk-loading-lookups.patch
Lumine1909 f09fbb247d 1.21.5 (#470)
---------

Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
Co-authored-by: Fortern <blueten.ki@gmail.com>
Co-authored-by: MC_XiaoHei <xor7xiaohei@gmail.com>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
Co-authored-by: MC_XiaoHei <xiaohei.xor7@outlook.com>
2025-06-05 18:41:51 +08:00

44 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Sun, 21 Aug 2022 08:29:15 +0800
Subject: [PATCH] Reduce chunk loading & lookups
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java
index ab7f7846d3fc0252c6f71277b3e67d7a785a96b5..8ac90690bd3fb7b5bf8798a4ca5c900e8bc7acb3 100644
--- a/net/minecraft/world/entity/monster/EnderMan.java
+++ b/net/minecraft/world/entity/monster/EnderMan.java
@@ -300,11 +300,28 @@ public class EnderMan extends Monster implements NeutralMob {
private boolean teleport(double x, double y, double z) {
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(x, y, z);
- while (mutableBlockPos.getY() > this.level().getMinY() && !this.level().getBlockState(mutableBlockPos).blocksMotion()) {
- mutableBlockPos.move(Direction.DOWN);
+ // Leaves start - single chunk lookup
+ BlockState blockState;
+ if (org.leavesmc.leaves.LeavesConfig.performance.reduceChuckLoadAndLookup) {
+ net.minecraft.world.level.chunk.LevelChunk chunk = this.level().getChunkIfLoaded(mutableBlockPos);
+ if (chunk == null) {
+ return false;
+ }
+
+ while (mutableBlockPos.getY() > this.level().getMinY() && !chunk.getBlockState(mutableBlockPos).blocksMotion()) {
+ mutableBlockPos.move(Direction.DOWN);
+ }
+
+ blockState = chunk.getBlockState(mutableBlockPos);
+ } else {
+ while (mutableBlockPos.getY() > this.level().getMinY() && !this.level().getBlockState(mutableBlockPos).blocksMotion()) {
+ mutableBlockPos.move(Direction.DOWN);
+ }
+
+ blockState = this.level().getBlockState(mutableBlockPos);
}
+ // Leaves end - single chunk lookup
- BlockState blockState = this.level().getBlockState(mutableBlockPos);
boolean flag = blockState.blocksMotion();
boolean isWater = blockState.getFluidState().is(FluidTags.WATER);
if (flag && !isWater) {