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