添加载具创死实体后是否收集物品的配置项
This commit is contained in:
parent
b8bcac246d
commit
cba9ad73f8
2 changed files with 9 additions and 2 deletions
|
@ -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<List<? extends String>> 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");
|
||||
|
|
|
@ -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<ItemEntity>();
|
||||
|
||||
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue