mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-30 04:09:09 +00:00
Fix and individually configure durable materials being damaged by tnt
This commit is contained in:
@@ -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 = 9; // (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 = 10; // (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) {
|
||||
@@ -88,13 +88,11 @@ public final class WorldConfiguration extends ConfigurationPart {
|
||||
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()));
|
||||
map.put(Blocks.CHIPPED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
|
||||
map.put(Blocks.DAMAGED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance()));
|
||||
map.put(Blocks.OBSIDIAN, new DurableMaterial(4, Blocks.COBBLESTONE.getExplosionResistance(), true));
|
||||
map.put(Blocks.ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance(), true));
|
||||
map.put(Blocks.CHIPPED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance(), true));
|
||||
map.put(Blocks.DAMAGED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance(), true));
|
||||
});
|
||||
@Comment("When disabled all explosions will be able to damage durable materials.")
|
||||
public boolean requireTntToDamageDurableMaterials = true;
|
||||
|
||||
public boolean protectScaffoldingFromCreepers = false;
|
||||
public boolean destroyWaterloggedBlocks = false;
|
||||
|
||||
@@ -32,7 +32,8 @@ public final class LocalValueConfig {
|
||||
storage.get(LocalValueKeys.DURABLE_MATERIALS).ifPresent(materials -> {
|
||||
materials.forEach((materialType, materialProperties) -> {
|
||||
Block nmsBlock = CraftMagicNumbers.getBlock(materialType);
|
||||
DurableMaterial durableMaterial = new DurableMaterial(materialProperties.getKey(), materialProperties.getValue());
|
||||
// temp, will be updated later
|
||||
DurableMaterial durableMaterial = new DurableMaterial(materialProperties.getKey(), materialProperties.getValue(), false);
|
||||
this.durableMaterials.put(nmsBlock, durableMaterial);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,6 +28,7 @@ public final class ConfigurationTransformations {
|
||||
V7_FixTntDuplicationName.apply(versionedBuilder);
|
||||
V8_RenameExplosionResistantItems.apply(versionedBuilder);
|
||||
V9_RenameAllowNonTntBreakingDurableBlocks.apply(versionedBuilder);
|
||||
V10_DurableMaterialOnlyDamagedByTnt.apply(versionedBuilder);
|
||||
// ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE
|
||||
versionedBuilder.build().apply(node);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.samsuik.sakura.configuration.transformation.world;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.NodePath;
|
||||
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
||||
import org.spongepowered.configurate.transformation.TransformAction;
|
||||
|
||||
import static org.spongepowered.configurate.NodePath.path;
|
||||
|
||||
public final class V10_DurableMaterialOnlyDamagedByTnt implements TransformAction {
|
||||
private static final int VERSION = 10;
|
||||
private static final V10_DurableMaterialOnlyDamagedByTnt INSTANCE = new V10_DurableMaterialOnlyDamagedByTnt();
|
||||
private static final NodePath EXPLOSION_PATH = path("cannons", "explosion");
|
||||
|
||||
public static void apply(final ConfigurationTransformation.VersionedBuilder builder) {
|
||||
builder.addVersion(VERSION, ConfigurationTransformation.builder()
|
||||
.addAction(EXPLOSION_PATH.plus(path("durable-materials")), INSTANCE)
|
||||
.addAction(EXPLOSION_PATH.plus(path("require-tnt-to-damage-durable-materials")), TransformAction.remove())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object @Nullable [] visitPath(final NodePath path, final ConfigurationNode value) throws ConfigurateException {
|
||||
for (final ConfigurationNode child : value.childrenList()) {
|
||||
child.node(path("only-damaged-by-tnt"), true);
|
||||
}
|
||||
|
||||
return new Object[0];
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package me.samsuik.sakura.explosion.durable;
|
||||
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Required;
|
||||
|
||||
@ConfigSerializable
|
||||
public record DurableMaterial(int durability, float resistance) {
|
||||
public record DurableMaterial(int durability, float resistance, @Required boolean onlyDamagedByTnt) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user