9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-19 14:59:30 +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 5103f1c769
commit d6e9d03a3b
2 changed files with 33 additions and 3 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 82fdd92a7a8122a9e409db2491a56df0311cad30..1b48793a6472ab015d0f7d7755d77104cccd18c3 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -414,6 +414,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(net.minecraft.world.level.block.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

@@ -83,6 +83,10 @@ public final class WorldConfiguration extends ConfigurationPart {
public Explosion explosion = new Explosion();
public class Explosion extends ConfigurationPart {
public boolean optimiseProtectedRegions = false;
public boolean avoidRedundantBlockSearches = false;
public boolean useBlockCacheAcrossExplosions = false;
public Map<Block, DurableMaterial> durableMaterials = Util.make(new Reference2ObjectOpenHashMap<>(), map -> {
map.put(Blocks.OBSIDIAN, new DurableMaterial(4, Blocks.COBBLESTONE.getExplosionResistance()));
map.put(Blocks.ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
@@ -92,16 +96,20 @@ public final class WorldConfiguration extends ConfigurationPart {
@Comment("When disabled all explosions will be able to damage durable materials.")
public boolean requireTntToDamageDurableMaterials = true;
public boolean optimiseProtectedRegions = false;
public boolean avoidRedundantBlockSearches = false;
public boolean protectScaffoldingFromCreepers = false;
public boolean destroyWaterloggedBlocks = false;
public boolean explodeLava = false;
public boolean consistentRadius = false;
public boolean explosionsHurtPlayers = true;
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();