diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java index 0c07294f9..b0dc8aadc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java @@ -4,6 +4,9 @@ import net.minecraftforge.common.ForgeConfigSpec; public class VehicleConfig { + public static ForgeConfigSpec.BooleanValue COLLISION_DESTROY_BLOCKS; + public static ForgeConfigSpec.BooleanValue COLLISION_DESTROY_HARD_BLOCKS; + public static ForgeConfigSpec.IntValue MK42_HP; public static ForgeConfigSpec.IntValue MK42_AP_DAMAGE; public static ForgeConfigSpec.IntValue MK42_AP_EXPLOSION_DAMAGE; @@ -58,8 +61,17 @@ public class VehicleConfig { public static ForgeConfigSpec.IntValue BMP_2_CANNON_EXPLOSION_DAMAGE; public static ForgeConfigSpec.DoubleValue BMP_2_CANNON_EXPLOSION_RADIUS; - public static void init(ForgeConfigSpec.Builder builder) { + builder.push("vehicle"); + + builder.comment("Allows vehicles to destroy blocks via collision"); + COLLISION_DESTROY_BLOCKS = builder.define("collision_destroy_blocks", false); + + builder.comment("Allows vehicles to destroy hard blocks via collision"); + COLLISION_DESTROY_HARD_BLOCKS = builder.define("collision_destroy_hard_blocks", false); + + builder.pop(); + builder.push("mk_42"); builder.comment("The HealthPoint of MK-42"); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java index 9edee90bb..c5d3db0bb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.entity.vehicle; +import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.C4Entity; import com.atsuishio.superbwarfare.entity.TargetEntity; import com.atsuishio.superbwarfare.entity.projectile.FlareDecoyEntity; @@ -88,6 +89,8 @@ public class MobileVehicleEntity extends EnergyVehicleEntity { public void collideBlock() { if (level() instanceof ServerLevel) { + if (!VehicleConfig.COLLISION_DESTROY_BLOCKS.get()) return; + AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6)); BlockPos.betweenClosedStream(aabb).forEach((pos) -> { BlockState blockstate = this.level().getBlockState(pos); @@ -95,7 +98,6 @@ public class MobileVehicleEntity extends EnergyVehicleEntity { || blockstate.is(BlockTags.LEAVES) || blockstate.is(BlockTags.FENCES) || blockstate.is(BlockTags.FENCE_GATES) || blockstate.is(BlockTags.DOORS) || blockstate.is(BlockTags.TRAPDOORS) || blockstate.is(Blocks.BAMBOO) - || blockstate.is(Tags.Blocks.GLASS) || blockstate.is(Tags.Blocks.GLASS_PANES) || blockstate.is(Blocks.MELON) || blockstate.is(Blocks.PUMPKIN) || blockstate.is(Blocks.HAY_BLOCK) || blockstate.is(Blocks.BELL) || blockstate.is(BlockTags.WALLS) || blockstate.is(Blocks.CHAIN)) { @@ -108,10 +110,13 @@ public class MobileVehicleEntity extends EnergyVehicleEntity { public void collideHardBlock() { if (level() instanceof ServerLevel) { + if (!VehicleConfig.COLLISION_DESTROY_HARD_BLOCKS.get()) return; + AABB aabb = getBoundingBox().inflate(0.1).move(this.getDeltaMovement().scale(0.6)); BlockPos.betweenClosedStream(aabb).forEach((pos) -> { BlockState blockstate = this.level().getBlockState(pos); - if (blockstate.is(BlockTags.LOGS) || blockstate.is(BlockTags.PLANKS)) { + if (blockstate.is(BlockTags.LOGS) || blockstate.is(BlockTags.PLANKS) + || blockstate.is(Tags.Blocks.GLASS) || blockstate.is(Tags.Blocks.GLASS_PANES)) { this.level().destroyBlock(pos, true); this.setDeltaMovement(this.getDeltaMovement().scale(0.6)); }