diff --git a/divinemc-server/minecraft-patches/features/0054-Reduce-chunk-loading-lookups.patch b/divinemc-server/minecraft-patches/features/0054-Reduce-chunk-loading-lookups.patch new file mode 100644 index 0000000..09b69c1 --- /dev/null +++ b/divinemc-server/minecraft-patches/features/0054-Reduce-chunk-loading-lookups.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Wed, 11 Jun 2025 19:12:00 +0300 +Subject: [PATCH] Reduce chunk loading & lookups + +Original license: GPL v3 +Original project: 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 c7cc8e1277bbfa8bcac596a5043e418cb1567971..146826c99a410bef2afd5ed055b40a6ae6b38701 100644 +--- a/net/minecraft/world/entity/monster/EnderMan.java ++++ b/net/minecraft/world/entity/monster/EnderMan.java +@@ -334,11 +334,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); ++ // DivineMC start - Reduce chunk loading & lookups ++ BlockState blockState; ++ if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.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); + } ++ // DivineMC end - Reduce chunk loading & lookups + +- BlockState blockState = this.level().getBlockState(mutableBlockPos); + boolean flag = blockState.blocksMotion(); + boolean isWater = blockState.getFluidState().is(FluidTags.WATER); + if (flag && !isWater) { diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java b/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java index 490b91f..dfb6c13 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/config/DivineConfig.java @@ -331,6 +331,7 @@ public class DivineConfig { public static boolean useCompactBitStorage = false; public static boolean commandBlockParseResultsCaching = true; public static boolean sheepOptimization = true; + public static boolean reduceChuckLoadAndLookup = true; public static boolean hopperThrottleWhenFull = false; public static int hopperThrottleSkipTicks = 0; @@ -437,6 +438,8 @@ public class DivineConfig { "Caches the parse results of command blocks, can significantly reduce performance impact."); sheepOptimization = getBoolean(ConfigCategory.PERFORMANCE.key("optimizations.sheep-optimization"), sheepOptimization, "Enables optimization from Carpet Fixes mod, using a prebaked list of all the possible colors and combinations for sheep."); + reduceChuckLoadAndLookup = getBoolean(ConfigCategory.PERFORMANCE.key("optimizations.reduce-chunk-load-and-lookup"), reduceChuckLoadAndLookup, + "If enabled, optimizes chunk loading and block state lookups by reducing the number of chunk accesses required during operations such as Enderman teleportation."); hopperThrottleWhenFull = getBoolean(ConfigCategory.PERFORMANCE.key("optimizations.hopper-throttle-when-full.enabled"), hopperThrottleWhenFull, "When enabled, hoppers will throttle if target container is full.");