添加锁定黑名单配置

This commit is contained in:
17146 2025-05-21 02:31:51 +08:00 committed by Light_Quanta
parent 5cc381ca74
commit 4e24152a81
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
3 changed files with 42 additions and 19 deletions

View file

@ -13,8 +13,8 @@ public class ClientConfig {
DisplayConfig.init(builder); DisplayConfig.init(builder);
VehicleControlConfig.init(builder); VehicleControlConfig.init(builder);
EnvironmentChecksumConfig.init(builder); EnvironmentChecksumConfig.init(builder);
SeekConfig.init(builder);
return builder.build(); return builder.build();
} }
} }

View file

@ -0,0 +1,32 @@
package com.atsuishio.superbwarfare.config.client;
import net.neoforged.neoforge.common.ModConfigSpec;
import java.util.List;
public class SeekConfig {
public static ModConfigSpec.ConfigValue<List<? extends String>> SEEK_BLACKLIST;
public static final List<? extends String> DEFAULT_SEEK_BLACKLIST = List.of(
"minecraft:item",
"minecraft:experience_orb",
"minecraft:armor_stand",
"minecraft:area_effect_cloud",
"superbwarfare:claymore",
"superbwarfare:c4",
"touhou_little_maid:power_point",
"evilcraft:vengeance_spirit"
);
public static void init(ModConfigSpec.Builder builder) {
builder.push("seek");
builder.comment("List of entities that can NOT be sought");
SEEK_BLACKLIST = builder.defineList("seek_blacklist",
DEFAULT_SEEK_BLACKLIST,
e -> e instanceof String);
builder.pop();
}
}

View file

@ -1,18 +1,16 @@
package com.atsuishio.superbwarfare.tools; package com.atsuishio.superbwarfare.tools;
import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.config.client.SeekConfig;
import com.atsuishio.superbwarfare.entity.ClaymoreEntity; import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity;
import com.atsuishio.superbwarfare.entity.projectile.*; import com.atsuishio.superbwarfare.entity.projectile.DestroyableProjectileEntity;
import com.atsuishio.superbwarfare.entity.projectile.SmokeDecoyEntity;
import com.atsuishio.superbwarfare.entity.projectile.SwarmDroneEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.AreaEffectCloud;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.entity.decoration.HangingEntity; import net.minecraft.world.entity.decoration.HangingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.ClipContext;
@ -199,16 +197,9 @@ public class SeekTool {
public static boolean baseFilter(Entity entity) { public static boolean baseFilter(Entity entity) {
return entity.isAlive() return entity.isAlive()
&& !(entity instanceof ItemEntity && !(entity instanceof HangingEntity || (entity instanceof Projectile && !(entity instanceof DestroyableProjectileEntity)))
|| entity instanceof ExperienceOrb
|| entity instanceof HangingEntity
|| (entity instanceof Projectile && !(entity instanceof DestroyableProjectileEntity))
|| entity instanceof ArmorStand
|| entity instanceof ClaymoreEntity
|| entity instanceof C4Entity
|| entity instanceof AreaEffectCloud)
&& !(entity instanceof Player player && player.isSpectator()) && !(entity instanceof Player player && player.isSpectator())
|| includedByConfig(entity); && !isInBlackList(entity);
} }
public static boolean isOnGround(Entity entity) { public static boolean isOnGround(Entity entity) {
@ -262,8 +253,8 @@ public class SeekTool {
return result; return result;
} }
public static boolean includedByConfig(Entity entity) { public static boolean isInBlackList(Entity entity) {
var type = BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()); var type = BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType());
return VehicleConfig.COLLISION_ENTITY_WHITELIST.get().contains(type.toString()); return SeekConfig.SEEK_BLACKLIST.get().contains(type.toString());
} }
} }