9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-19 14:59:30 +00:00

Rename allow-non-tnt-breaking-durable-blocks

This commit is contained in:
Samsuik
2025-06-25 17:41:58 +01:00
parent e867f752dc
commit 5103f1c769
11 changed files with 73 additions and 23 deletions

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Explosion Durable Blocks
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java
index 2fbbbac9f1472354bd507926a85c25f48291edfe..e11f4c722b132340b9a48915bddf5ec6e55239ed 100644
index cc363ba3bc719d8b93992141d779b4c1d1bbd2fb..cdcaf954cec280970f29ac11db906457f18190c6 100644
--- a/net/minecraft/world/item/BlockItem.java
+++ b/net/minecraft/world/item/BlockItem.java
@@ -38,8 +38,31 @@ public class BlockItem extends Item {
@@ -41,7 +41,7 @@ index 2fbbbac9f1472354bd507926a85c25f48291edfe..e11f4c722b132340b9a48915bddf5ec6
return !interactionResult.consumesAction() && context.getItemInHand().has(DataComponents.CONSUMABLE)
? super.use(context.getLevel(), context.getPlayer(), context.getHand())
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 99571af2e473cb14322625b0287b2f18fcf116d3..769887ee6d798d0b11de72e9ffe80c9d358daf17 100644
index c7a5d369e9889353242d8a70772b2c45684a6951..54d97a271e6a500f5e4ca74bcecbb0f8a1fd1ae2 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -830,6 +830,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -53,7 +53,7 @@ index 99571af2e473cb14322625b0287b2f18fcf116d3..769887ee6d798d0b11de72e9ffe80c9d
protected Level(
WritableLevelData levelData,
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 6510ce55b9590fbfa50b70b56180840abf565731..ba067476b418fa81952a9f59528ca75eefd13746 100644
index 9f0dcaf0db44925c35fa46fdb2de83540ee959c4..48d98bac0140cec91fe2c9e7bb72a6f05a70aa49 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -131,7 +131,7 @@ public class ServerExplosion implements Explosion {
@@ -75,7 +75,7 @@ index 6510ce55b9590fbfa50b70b56180840abf565731..ba067476b418fa81952a9f59528ca75e
+ final Block block = blockState.getBlock();
+ final me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(pos).durableMaterials.get(block);
+
+ if (material != null && material.resistance() >= 0.0f && pos.getY() > this.level.getMinY() && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
+ if (material != null && material.resistance() >= 0.0f && pos.getY() > this.level.getMinY() && (!this.level.sakuraConfig().cannons.explosion.requireTntToDamageDurableMaterials || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
+ return Optional.of(material.resistance());
+ }
+ }
@@ -91,7 +91,7 @@ index 6510ce55b9590fbfa50b70b56180840abf565731..ba067476b418fa81952a9f59528ca75e
}
// CraftBukkit end
+ // Sakura start - explosion durable blocks
+ if (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt) {
+ if (!this.level.sakuraConfig().cannons.explosion.requireTntToDamageDurableMaterials || this.source instanceof net.minecraft.world.entity.item.PrimedTnt) {
+ final me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(blockPos).durableMaterials.get(block);
+ if (material != null && material.durability() >= 0 && !this.level.durabilityManager.damage(blockPos, material)) {
+ continue;

View File

@@ -5,11 +5,11 @@ Subject: [PATCH] Destroy Waterlogged Blocks
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index ba067476b418fa81952a9f59528ca75eefd13746..65d2b93a6ca6f18aae72627b7a21215eecdcc9c2 100644
index 48d98bac0140cec91fe2c9e7bb72a6f05a70aa49..5810539dbe4ed782ec638bb9f08f183e5a720284 100644
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -399,6 +399,11 @@ public class ServerExplosion implements Explosion {
if (material != null && material.resistance() >= 0.0f && pos.getY() > this.level.getMinY() && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
if (material != null && material.resistance() >= 0.0f && pos.getY() > this.level.getMinY() && (!this.level.sakuraConfig().cannons.explosion.requireTntToDamageDurableMaterials || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
return Optional.of(material.resistance());
}
+ // Sakura start - destroy water logged blocks

View File

@@ -28,7 +28,7 @@ import java.util.Set;
public final class WorldConfiguration extends ConfigurationPart {
private static final Logger LOGGER = LogUtils.getClassLogger();
static final int CURRENT_VERSION = 8; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
static final int CURRENT_VERSION = 9; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs
private transient final ResourceLocation worldKey;
WorldConfiguration(ResourceLocation worldKey) {
@@ -83,16 +83,18 @@ 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 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()));
map.put(Blocks.CHIPPED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
map.put(Blocks.DAMAGED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
});
@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 allowNonTntBreakingDurableBlocks = false;
public boolean destroyWaterloggedBlocks = false;
public boolean explodeLava = false;
public boolean consistentRadius = false;

View File

@@ -11,6 +11,7 @@ import org.spongepowered.configurate.transformation.ConfigurationTransformation;
import org.spongepowered.configurate.transformation.TransformAction;
import java.util.List;
import java.util.function.Function;
public final class ConfigurationTransformations {
private static final List<NodePath> REMOVED_GLOBAL_PATHS = List.of(
@@ -26,6 +27,7 @@ public final class ConfigurationTransformations {
V6_FixIncorrectExtraKnockback.apply(versionedBuilder);
V7_FixTntDuplicationName.apply(versionedBuilder);
V8_RenameExplosionResistantItems.apply(versionedBuilder);
V9_RenameAllowNonTntBreakingDurableBlocks.apply(versionedBuilder);
// ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE
versionedBuilder.build().apply(node);
}
@@ -44,5 +46,21 @@ public final class ConfigurationTransformations {
versionedBuilder.build().apply(node);
}
public static TransformAction newValue(final Function<ConfigurationNode, Object> func) {
return (k, v) -> {
if (!v.virtual()) {
Object val = func.apply(v);
if (val != null) {
v.raw(val);
}
}
return null;
};
}
public static TransformAction move(final NodePath path) {
return (p, n) -> path.array();
}
private ConfigurationTransformations() {}
}

View File

@@ -18,7 +18,9 @@ public final class V2_VerticalKnockbackUseDefault implements TransformAction {
private V2_VerticalKnockbackUseDefault() {}
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
builder.addVersion(VERSION, ConfigurationTransformation.builder()
.addAction(PATH, INSTANCE)
.build());
}
@Override

View File

@@ -21,7 +21,9 @@ public final class V4_RenameNonStrictMergeLevel implements TransformAction {
private V4_RenameNonStrictMergeLevel() {}
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
builder.addVersion(VERSION, ConfigurationTransformation.builder()
.addAction(PATH, INSTANCE)
.build());
}
@Override

View File

@@ -22,7 +22,9 @@ public final class V5_CombineLoadChunksOptions implements TransformAction {
private V5_CombineLoadChunksOptions() {}
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
builder.addVersion(VERSION, ConfigurationTransformation.builder()
.addAction(PATH, INSTANCE)
.build());
}
@Override

View File

@@ -17,7 +17,9 @@ public final class V6_FixIncorrectExtraKnockback implements TransformAction {
private V6_FixIncorrectExtraKnockback() {}
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build());
builder.addVersion(VERSION, ConfigurationTransformation.builder()
.addAction(PATH, INSTANCE)
.build());
}
@Override

View File

@@ -2,14 +2,18 @@ package me.samsuik.sakura.configuration.transformation.world;
import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
import org.spongepowered.configurate.transformation.TransformAction;
import static org.spongepowered.configurate.NodePath.*;
import static org.spongepowered.configurate.transformation.TransformAction.rename;
public final class V7_FixTntDuplicationName {
private static final int VERSION = 7;
private static final NodePath OLD_PATH = NodePath.path("technical", "allow-t-n-t-duplication");
private static final NodePath OLD_PATH = path("technical", "allow-t-n-t-duplication");
private static final String NEW_NAME = "allow-tnt-duplication";
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(OLD_PATH, TransformAction.rename(NEW_NAME)).build());
builder.addVersion(VERSION, ConfigurationTransformation.builder()
.addAction(OLD_PATH, rename(NEW_NAME))
.build());
}
}

View File

@@ -2,8 +2,8 @@ package me.samsuik.sakura.configuration.transformation.world;
import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
import org.spongepowered.configurate.transformation.TransformAction;
import static me.samsuik.sakura.configuration.transformation.ConfigurationTransformations.move;
import static org.spongepowered.configurate.NodePath.path;
public final class V8_RenameExplosionResistantItems {
@@ -20,8 +20,4 @@ public final class V8_RenameExplosionResistantItems {
.addAction(OLD_ITEMS_PATH, move(NEW_ITEMS_PATH))
.build());
}
private static TransformAction move(NodePath path) {
return (p, n) -> path.array();
}
}

View File

@@ -0,0 +1,22 @@
package me.samsuik.sakura.configuration.transformation.world;
import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
import static me.samsuik.sakura.configuration.transformation.ConfigurationTransformations.move;
import static me.samsuik.sakura.configuration.transformation.ConfigurationTransformations.newValue;
import static org.spongepowered.configurate.NodePath.*;
public final class V9_RenameAllowNonTntBreakingDurableBlocks {
private static final int VERSION = 9;
private static final NodePath PARENT = path("cannons", "explosion");
private static final NodePath OLD_PATH = PARENT.plus(path("allow-non-tnt-breaking-durable-blocks"));
private static final NodePath NEW_PATH = PARENT.plus(path("require-tnt-to-damage-durable-materials"));
public static void apply(ConfigurationTransformation.VersionedBuilder builder) {
builder.addVersion(VERSION, ConfigurationTransformation.builder()
.addAction(OLD_PATH, move(NEW_PATH))
.addAction(NEW_PATH, newValue(v -> !v.getBoolean()))
.build());
}
}