mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-20 23:39:34 +00:00
Update 1.20.2 (#139)
This commit is contained in:
@@ -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<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);
|
||||
- });
|
||||
+ 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<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;
|
||||
+ }
|
||||
}
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user