diff --git a/patches/server/0004-Leaves-Server-Config-And-Command.patch b/patches/server/0004-Leaves-Server-Config-And-Command.patch index c0cde531..c06159ea 100644 --- a/patches/server/0004-Leaves-Server-Config-And-Command.patch +++ b/patches/server/0004-Leaves-Server-Config-And-Command.patch @@ -128,10 +128,10 @@ index 35d2da9d91dcdd89de7c0f4af028fd182376ea8d..d73482fb1e71fe2951e96ae0593de268 .withRequiredArg() diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..d88e1f1bc0517c96bb3ab4e63b29469d2fb02992 +index 0000000000000000000000000000000000000000..85a94d60e52c6a6d0f1bd46b67436fbb53081073 --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -0,0 +1,891 @@ +@@ -0,0 +1,896 @@ +package top.leavesmc.leaves; + +import com.destroystokyo.paper.util.SneakyThrow; @@ -848,6 +848,11 @@ index 0000000000000000000000000000000000000000..d88e1f1bc0517c96bb3ab4e63b29469d + optimizeSunBurnTick = getBoolean("settings.performance.optimize-sun-burn-tick", optimizeSunBurnTick); + } + ++ public static boolean removeDamageLambda = true; ++ private static void removeDamageLambda() { ++ removeDamageLambda = getBoolean("settings.performance.remove.damage-lambda", removeDamageLambda); ++ } ++ + public static final class WorldConfig { + + public final String worldName; diff --git a/patches/server/0101-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch b/patches/server/0101-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch new file mode 100644 index 00000000..12d5102d --- /dev/null +++ b/patches/server/0101-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Thu, 20 Jul 2023 15:30:56 +0800 +Subject: [PATCH] Reduce lambda and Optional allocation in + EntityBasedExplosionDamageCalculator + +This patch is Powered by Gale(https://github.com/GaleMC/Gale) + +diff --git a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java +index 2f9f15d99f8b31e9f13f7f32378b2a9e09bcb5e5..623f6713a5294ba54baf6319b222a2f35940d458 100644 +--- a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java ++++ b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java +@@ -15,9 +15,21 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula + + @Override + public Optional getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState) { +- return super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState).map((max) -> { +- return this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max); +- }); ++ if (!top.leavesmc.leaves.LeavesConfig.removeDamageLambda) { ++ return super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState).map((max) -> { ++ return this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, max); ++ }); ++ } else { ++ Optional optionalBlastResistance = super.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState); ++ if (optionalBlastResistance.isPresent()) { ++ float blastResistance = optionalBlastResistance.get(); ++ float effectiveExplosionResistance = this.source.getBlockExplosionResistance(explosion, world, pos, blockState, fluidState, blastResistance); ++ if (effectiveExplosionResistance != blastResistance) { ++ return Optional.of(effectiveExplosionResistance); ++ } ++ } ++ return optionalBlastResistance; ++ } + } + + @Override