mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-19 14:59:29 +00:00
41 lines
2.4 KiB
Diff
41 lines
2.4 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:
|
|
"me/jellysquid/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/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
|
index 2f9f15d99f8b31e9f13f7f32378b2a9e09bcb5e5..4e4dfb72d5a0b46917999b709c655ccfdae27183 100644
|
|
--- a/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
|
+++ b/src/main/java/net/minecraft/world/level/EntityBasedExplosionDamageCalculator.java
|
|
@@ -15,9 +15,17 @@ public class EntityBasedExplosionDamageCalculator extends ExplosionDamageCalcula
|
|
|
|
@Override
|
|
public Optional<Float> 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);
|
|
- });
|
|
+ // Gale start - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
|
|
+ Optional<Float> 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;
|
|
+ // Gale end - Lithium - reduce lambda and Optional allocation in EntityBasedExplosionDamageCalculator
|
|
}
|
|
|
|
@Override
|