From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MelnCat Date: Sat, 1 Oct 2022 13:29:17 -0700 Subject: [PATCH] Configurable block blast resistance diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java index 86d765cd40cda9c8b7f4f7898d604ba2fdefa8fd..37360b896edecf3f2e09f0f7da6a37d6c769c630 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -79,7 +79,7 @@ public abstract class BlockBehaviour implements FeatureElement { protected static final Direction[] UPDATE_SHAPE_ORDER = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP}; public final Material material; // Purpur - protected -> public public final boolean hasCollision; - protected final float explosionResistance; + public float explosionResistance; // Purpur - protected final -> public protected final boolean isRandomlyTicking; protected final SoundType soundType; protected final float friction; diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java index 3a04cb4c646c07abf4338c70c865a4c4cb34b1bc..b05b4d3d97bca159c297f150005b5ab5bf6087e0 100644 --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java @@ -239,7 +239,7 @@ public abstract class LavaFluid extends FlowingFluid { @Override protected float getExplosionResistance() { - return 100.0F; + return Blocks.LAVA.getExplosionResistance(); // Purpur } @Override diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java index ec6c63075306f9e5389e83641d2c8a82369ddc6b..0f16deddd8cbb506ef7886f57ae640a42e841703 100644 --- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java +++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java @@ -116,7 +116,7 @@ public abstract class WaterFluid extends FlowingFluid { @Override protected float getExplosionResistance() { - return 100.0F; + return Blocks.WATER.getExplosionResistance(); // Purpur } @Override diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java index 29bc829c61c907b8793ae15b65f5e4cb4d099df3..e91e6c43197b52d6e29779959df066c991d425a1 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java @@ -559,4 +559,19 @@ public class PurpurConfig { private static void fixProjectileLootingTransfer() { fixProjectileLootingTransfer = getBoolean("settings.fix-projectile-looting-transfer", fixProjectileLootingTransfer); } + + private static void blastResistanceSettings() { + getMap("settings.blast-resistance-overrides", Collections.emptyMap()).forEach((blockId, value) -> { + Block block = BuiltInRegistries.BLOCK.get(new ResourceLocation(blockId)); + if (block == Blocks.AIR) { + log(Level.SEVERE, "Invalid block for `settings.blast-resistance-overrides`: " + blockId); + return; + } + if (!(value instanceof Number blastResistance)) { + log(Level.SEVERE, "Invalid blast resistance for `settings.blast-resistance-overrides." + blockId + "`: " + value); + return; + } + block.explosionResistance = blastResistance.floatValue(); + }); + } }