mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-19 14:59:29 +00:00
43 lines
2.3 KiB
Diff
43 lines
2.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Sat, 26 Nov 2022 16:28:23 +0100
|
|
Subject: [PATCH] Reduce lambda and Optional allocation in
|
|
EntityBasedExplosionDamageCalculator
|
|
|
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following mixin:
|
|
"net/caffeinemc/mods/lithium/mixin/alloc/explosion_behavior/EntityExplosionBehaviorMixin.java"
|
|
By: 2No2Name <2No2Name@web.de>
|
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
|
Licensed under: LGPL-3.0 (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 52cb2dcd714cf8c16f167466333eeb923e4ff183..af9d8f5988431eaf82da6a564c19a7a359a693d0 100644
|
|
--- a/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
|
+++ b/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
|
@@ -15,8 +15,20 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula
|
|
|
|
@Override
|
|
public Optional<Float> getBlockExplosionResistance(Explosion explosion, BlockGetter reader, BlockPos pos, BlockState state, FluidState fluid) {
|
|
- return super.getBlockExplosionResistance(explosion, reader, pos, state, fluid)
|
|
- .map(resistance -> this.source.getBlockExplosionResistance(explosion, reader, pos, state, fluid, resistance));
|
|
+ // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
|
|
+ Optional<Float> optionalBlastResistance = super.getBlockExplosionResistance(explosion, reader, pos, state, fluid);
|
|
+
|
|
+ if (optionalBlastResistance.isPresent()) {
|
|
+ float resistance = optionalBlastResistance.get();
|
|
+ float effectiveExplosionResistance = this.source.getBlockExplosionResistance(explosion, reader, pos, state, fluid, resistance);
|
|
+
|
|
+ if (effectiveExplosionResistance != resistance) {
|
|
+ return Optional.of(effectiveExplosionResistance);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return optionalBlastResistance;
|
|
+ // Gale end - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
|
|
}
|
|
|
|
@Override
|