调整实体搜寻逻辑

This commit is contained in:
17146 2025-06-12 17:52:43 +08:00 committed by Light_Quanta
parent 6447d92f81
commit 406486817f
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
3 changed files with 3 additions and 8 deletions

View file

@ -1,4 +0,0 @@
package com.atsuishio.superbwarfare.entity.projectile;
public interface DestroyableProjectileEntity {
}

View file

@ -2,11 +2,11 @@ package com.atsuishio.superbwarfare.tools;
import com.atsuishio.superbwarfare.config.server.SeekConfig; import com.atsuishio.superbwarfare.config.server.SeekConfig;
import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity; import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity;
import com.atsuishio.superbwarfare.entity.projectile.DestroyableProjectileEntity;
import com.atsuishio.superbwarfare.entity.projectile.SmokeDecoyEntity; import com.atsuishio.superbwarfare.entity.projectile.SmokeDecoyEntity;
import com.atsuishio.superbwarfare.entity.projectile.SwarmDroneEntity; 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 com.atsuishio.superbwarfare.init.ModTags;
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.Entity; import net.minecraft.world.entity.Entity;
@ -197,7 +197,7 @@ public class SeekTool {
public static boolean baseFilter(Entity entity) { public static boolean baseFilter(Entity entity) {
return entity.isAlive() return entity.isAlive()
&& !(entity instanceof HangingEntity || (entity instanceof Projectile && !(entity instanceof DestroyableProjectileEntity))) && !(entity instanceof HangingEntity || (entity instanceof Projectile && !entity.getType().is(ModTags.EntityTypes.DESTROYABLE_PROJECTILE)))
&& !(entity instanceof Player player && player.isSpectator()) && !(entity instanceof Player player && player.isSpectator())
&& !isInBlackList(entity); && !isInBlackList(entity);
} }

View file

@ -1,7 +1,6 @@
package com.atsuishio.superbwarfare.tools; package com.atsuishio.superbwarfare.tools;
import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity; import com.atsuishio.superbwarfare.entity.projectile.DecoyEntity;
import com.atsuishio.superbwarfare.entity.projectile.DestroyableProjectileEntity;
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.Direction; import net.minecraft.core.Direction;
@ -109,7 +108,7 @@ public class TraceTool {
Vec3 viewVec = vehicle.getBarrelVector(1); Vec3 viewVec = vehicle.getBarrelVector(1);
Vec3 toVec = eye.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach); Vec3 toVec = eye.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
AABB aabb = vehicle.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D); AABB aabb = vehicle.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(vehicle, eye, toVec, aabb, p -> !p.isSpectator() && p.isAlive() && !(p instanceof Projectile && !(p instanceof DestroyableProjectileEntity)) && SeekTool.baseFilter(p) && !(p instanceof DecoyEntity) && smokeFilter(p), distance); EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(vehicle, eye, toVec, aabb, p -> !p.isSpectator() && p.isAlive() && SeekTool.baseFilter(p) && !(p instanceof DecoyEntity) && smokeFilter(p), distance);
if (entityhitresult != null) { if (entityhitresult != null) {
hitResult = entityhitresult; hitResult = entityhitresult;