添加碰撞黑名单配置
This commit is contained in:
parent
d6859856d2
commit
8716c80426
2 changed files with 25 additions and 4 deletions
|
@ -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<List<? extends String>> COLLISION_ENTITY_BLACKLIST;
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public static final List<? extends String> 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");
|
||||
|
|
|
@ -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()
|
||||
.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()))
|
||||
&& !entity.getType().getDescriptionId().equals("entity.create.super_glue"))
|
||||
&& !(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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue