Files
Shiroha/shiroha-server/minecraft-patches/features/0081-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch
T
NanaChiyo0721 d1786e96ef
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s
Reduce allocation in SignalGetter
2026-08-07 15:51:57 +08:00

43 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Sat, 20 Jun 2026 23:16:15 +0800
Subject: [PATCH] Gale Reduce lambda and Optional allocation in
EntityBasedExplosionDamageCalculator
License: LGPL-3.0-only (https://www.gnu.org/licenses/lgpl-3.0.html)
Gale - https://github.com/GaleMC/Gale
This patch is based on the following mixin:
"net/caffeinemc/mods/lithium/mixin/alloc/explosion_behavior/EntityBasedExplosionDamageCalculatorMixin.java"
By: 2No2Name <2No2Name@web.de>
As part of: Lithium (https://github.com/CaffeineMC/lithium)
Licensed under: LGPL-3.0-only (https://www.gnu.org/licenses/lgpl-3.0.html)
diff --git a/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
index 356a3a0dda09af007c3fbddfe360b38f4d7204ce..aff8d67c9b9797402a3bf6c5bce54af19af0ade7 100644
--- a/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
+++ b/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
@@ -17,8 +17,20 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula
public Optional<Float> getBlockExplosionResistance(
final Explosion explosion, final BlockGetter level, final BlockPos pos, final BlockState block, final FluidState fluid
) {
- return super.getBlockExplosionResistance(explosion, level, pos, block, fluid)
- .map(resistance -> this.source.getBlockExplosionResistance(explosion, level, pos, block, fluid, resistance));
+ // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
+ Optional<Float> optionalBlastResistance = super.getBlockExplosionResistance(explosion, level, pos, block, fluid);
+
+ if (optionalBlastResistance.isPresent()) {
+ float resistance = optionalBlastResistance.get();
+ float effectiveExplosionResistance = this.source.getBlockExplosionResistance(explosion, level, pos, block, fluid, resistance);
+
+ if (effectiveExplosionResistance != resistance) {
+ return Optional.of(effectiveExplosionResistance);
+ }
+ }
+
+ return optionalBlastResistance;
+ // Gale end - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
}
@Override