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 27fca66db..5e1cfd493 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java @@ -2,11 +2,19 @@ package com.atsuishio.superbwarfare.config.server; import net.minecraftforge.common.ForgeConfigSpec; +import java.util.List; + public class VehicleConfig { public static ForgeConfigSpec.BooleanValue COLLISION_DESTROY_BLOCKS; public static ForgeConfigSpec.BooleanValue COLLISION_DESTROY_HARD_BLOCKS; + public static ForgeConfigSpec.ConfigValue> COLLISION_ENTITY_BLACKLIST; + + @SuppressWarnings("SpellCheckingInspection") + public static final List DEFAULT_COLLISION_ENTITY_BLACKLIST = + List.of("create:super_glue", "zombieawareness:scent"); + public static ForgeConfigSpec.IntValue MK42_HP; public static ForgeConfigSpec.IntValue MK42_AP_DAMAGE; public static ForgeConfigSpec.IntValue MK42_AP_EXPLOSION_DAMAGE; @@ -70,6 +78,11 @@ public class VehicleConfig { builder.comment("Allows vehicles to destroy hard blocks via collision"); COLLISION_DESTROY_HARD_BLOCKS = builder.define("collision_destroy_hard_blocks", false); + builder.comment("List of entities that cannot be damaged by collision"); + COLLISION_ENTITY_BLACKLIST = builder.defineList("collision_entity_blacklist", + DEFAULT_COLLISION_ENTITY_BLACKLIST, + e -> e instanceof String); + 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 8c84e066e..24a71782a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java @@ -34,6 +34,7 @@ import net.minecraft.world.level.entity.EntityTypeTest; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.Tags; +import net.minecraftforge.registries.ForgeRegistries; import org.jetbrains.annotations.NotNull; import org.joml.Math; import org.joml.Vector3f; @@ -234,10 +235,17 @@ public class MobileVehicleEntity extends EnergyVehicleEntity { var entities = level().getEntities(EntityTypeTest.forClass(Entity.class), frontBox, entity -> entity != this && entity != getFirstPassenger() && entity.getVehicle() == null) - .stream().filter(entity -> entity.isAlive() - && !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity || entity instanceof LaserEntity || entity instanceof FlareDecoyEntity || entity instanceof AreaEffectCloud || entity instanceof C4Entity) - && !(entity instanceof Player player && (player.isSpectator() || player.isCreative())) - && !entity.getType().getDescriptionId().equals("entity.create.super_glue")) + .stream().filter(entity -> { + if (entity.isAlive() + && !(entity instanceof ItemEntity || entity instanceof Projectile || entity instanceof ProjectileEntity || entity instanceof LaserEntity || entity instanceof FlareDecoyEntity || entity instanceof AreaEffectCloud || entity instanceof C4Entity) + && !(entity instanceof Player player && (player.isSpectator() || player.isCreative()))) { + var type = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType()); + if (type == null) return false; + return !VehicleConfig.COLLISION_ENTITY_BLACKLIST.get().contains(type.toString()); + } + return false; + } + ) .toList(); for (var entity : entities) {