From cba9ad73f87d809edb4bb22c8bae03f02f40fbcf Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Wed, 9 Jul 2025 01:33:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BD=BD=E5=85=B7=E5=88=9B?= =?UTF-8?q?=E6=AD=BB=E5=AE=9E=E4=BD=93=E5=90=8E=E6=98=AF=E5=90=A6=E6=94=B6?= =?UTF-8?q?=E9=9B=86=E7=89=A9=E5=93=81=E7=9A=84=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/config/server/VehicleConfig.java | 5 +++++ .../atsuishio/superbwarfare/event/LivingEventHandler.java | 6 ++++-- 2 files changed, 9 insertions(+), 2 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 be8282205..bb9f847f0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java @@ -10,6 +10,7 @@ public class VehicleConfig { public static ModConfigSpec.BooleanValue COLLISION_DESTROY_HARD_BLOCKS; public static ModConfigSpec.BooleanValue COLLISION_DESTROY_BLOCKS_BEASTLY; public static ModConfigSpec.BooleanValue VEHICLE_ITEM_PICKUP; + public static ModConfigSpec.BooleanValue COLLECT_DROPS_BY_CRASHING; public static ModConfigSpec.ConfigValue> COLLISION_ENTITY_WHITELIST; @@ -118,9 +119,13 @@ public class VehicleConfig { builder.comment("Allow vehicles to pick up items"); VEHICLE_ITEM_PICKUP = builder.define("vehicle_item_pickup", true); + builder.comment("Allow vehicles to collect drops after killing other entities by crashing"); + COLLECT_DROPS_BY_CRASHING = builder.define("collect_drops_by_crashing", true); + builder.comment("List of entities that can be damaged by collision"); COLLISION_ENTITY_WHITELIST = builder.defineList("collision_entity_whitelist", DEFAULT_COLLISION_ENTITY_WHITELIST, + () -> "", e -> e instanceof String); builder.push("repair"); diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index 51d85df8c..f61d05326 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -565,7 +565,10 @@ public class LivingEventHandler { if (!(sourceEntity instanceof Player player)) return; // 创生物收集掉落物 - if (player.getVehicle() instanceof ContainerMobileVehicleEntity containerMobileVehicleEntity && source.is(ModDamageTypes.VEHICLE_STRIKE)) { + if (VehicleConfig.COLLECT_DROPS_BY_CRASHING.get() + && player.getVehicle() instanceof ContainerMobileVehicleEntity containerMobileVehicleEntity + && source.is(ModDamageTypes.VEHICLE_STRIKE) + ) { var drops = event.getDrops(); var removed = new ArrayList(); @@ -635,7 +638,6 @@ public class LivingEventHandler { @SubscribeEvent public static void onEffectApply(MobEffectEvent.Applicable event) { var effectInstance = event.getEffectInstance(); - if (effectInstance == null) return; if (effectInstance.getEffect().value().getCategory() == MobEffectCategory.HARMFUL && event.getEntity().getVehicle() instanceof VehicleEntity vehicle