9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-27 10:49:06 +00:00

Protect blocks above a configured Y-level from explosions

This commit is contained in:
Samsuik
2025-06-25 17:59:34 +01:00
parent 519ab29adc
commit 2e15653375
2 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Wed, 25 Jun 2025 17:57:44 +0100
Subject: [PATCH] Protect blocks above a configured Y-level from explosions
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 71401708e65c9b06f30d124757fecf5f61eff957..d6ef61484019095399bb2ba3fcbd7aac30cff435 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -417,6 +417,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(Blocks.BARRIER.getExplosionResistance());
}
// Sakura end - protect scaffolding from creepers
+ // Sakura start - protect blocks above a configured Y-level from explosions
+ if (this.level.sakuraConfig().cannons.explosion.protectBlocksAboveY.test(val -> pos.getY() >= val)) {
+ return Optional.of(net.minecraft.world.level.block.Blocks.BARRIER.getExplosionResistance());
+ }
+ // Sakura end - protect blocks above a configured Y-level from explosions
}
return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);

View File

@@ -99,6 +99,13 @@ public final class WorldConfiguration extends ConfigurationPart {
public boolean explosionsDropItems = true;
public boolean useBlockCacheAcrossExplosions = false;
public boolean breakBlocksWhenOutsideTheWorldBorder = true;
@Comment(
"Protects blocks above the configured height from explosions.\n" +
"Can be used to replicate the regen caps found on complexmc, and\n" +
"useful for protecting the nether roof when bedrock is a durable-material."
)
public IntOr.Disabled protectBlocksAboveY = IntOr.Disabled.DISABLED;
}
public Mechanics mechanics = new Mechanics();