From 9dcee7a1958d92b4d023ab529ce91c06ef87244b Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Thu, 30 Jan 2025 23:15:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=92=9E=E5=87=BB=E7=A0=B4?= =?UTF-8?q?=E5=9D=8F=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/config/server/VehicleConfig.java | 14 +++++++++++++- .../entity/vehicle/MobileVehicleEntity.java | 9 +++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) 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)); }