添加烟雾匿踪效果
This commit is contained in:
parent
d3e851af3a
commit
457c4fa749
4 changed files with 41 additions and 11 deletions
|
@ -57,6 +57,8 @@ import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
|
import static com.atsuishio.superbwarfare.tools.SeekTool.smokeFilter;
|
||||||
|
|
||||||
public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEntity, CannonEntity, OwnableEntity {
|
public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEntity, CannonEntity, OwnableEntity {
|
||||||
public static final EntityDataAccessor<Integer> ANIM_TIME = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> ANIM_TIME = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Float> GUN_ROTATE = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> GUN_ROTATE = SynchedEntityData.defineId(Hpj11Entity.class, EntityDataSerializers.FLOAT);
|
||||||
|
@ -258,7 +260,7 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
Entity target = EntityFindUtil.findEntity(level(), entityData.get(TARGET_UUID));
|
Entity target = EntityFindUtil.findEntity(level(), entityData.get(TARGET_UUID));
|
||||||
|
|
||||||
if (target != null && this.getOwner() instanceof Player player) {
|
if (target != null && this.getOwner() instanceof Player player && smokeFilter(target)) {
|
||||||
if (target instanceof LivingEntity living && living.getHealth() <= 0) {
|
if (target instanceof LivingEntity living && living.getHealth() <= 0) {
|
||||||
this.entityData.set(TARGET_UUID, "none");
|
this.entityData.set(TARGET_UUID, "none");
|
||||||
return;
|
return;
|
||||||
|
@ -314,7 +316,8 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
&& canAim(pos, e, minAngle, maxAngle)
|
&& canAim(pos, e, minAngle, maxAngle)
|
||||||
&& e instanceof LivingEntity living
|
&& e instanceof LivingEntity living
|
||||||
&& living instanceof Enemy
|
&& living instanceof Enemy
|
||||||
&& living.getHealth() > 0) {
|
&& living.getHealth() > 0
|
||||||
|
&& smokeFilter(e)) {
|
||||||
return checkNoClip(e);
|
return checkNoClip(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -49,6 +49,7 @@ import java.util.UUID;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||||
|
import static com.atsuishio.superbwarfare.tools.SeekTool.smokeFilter;
|
||||||
|
|
||||||
public class LaserTowerEntity extends EnergyVehicleEntity implements GeoEntity, OwnableEntity {
|
public class LaserTowerEntity extends EnergyVehicleEntity implements GeoEntity, OwnableEntity {
|
||||||
|
|
||||||
|
@ -252,7 +253,7 @@ public class LaserTowerEntity extends EnergyVehicleEntity implements GeoEntity,
|
||||||
|
|
||||||
Entity target = EntityFindUtil.findEntity(level(), entityData.get(TARGET_UUID));
|
Entity target = EntityFindUtil.findEntity(level(), entityData.get(TARGET_UUID));
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null && smokeFilter(target)) {
|
||||||
if (target instanceof LivingEntity living && living.getHealth() <= 0) {
|
if (target instanceof LivingEntity living && living.getHealth() <= 0) {
|
||||||
this.entityData.set(TARGET_UUID, "none");
|
this.entityData.set(TARGET_UUID, "none");
|
||||||
return;
|
return;
|
||||||
|
@ -322,7 +323,8 @@ public class LaserTowerEntity extends EnergyVehicleEntity implements GeoEntity,
|
||||||
&& canAim(pos, e, minAngle, maxAngle)
|
&& canAim(pos, e, minAngle, maxAngle)
|
||||||
&& e instanceof LivingEntity living
|
&& e instanceof LivingEntity living
|
||||||
&& living instanceof Enemy
|
&& living instanceof Enemy
|
||||||
&& living.getHealth() > 0) {
|
&& living.getHealth() > 0
|
||||||
|
&& smokeFilter(e)) {
|
||||||
return checkNoClip(e);
|
return checkNoClip(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2,9 +2,7 @@ package com.atsuishio.superbwarfare.tools;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.ClaymoreEntity;
|
import com.atsuishio.superbwarfare.entity.ClaymoreEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.C4Entity;
|
import com.atsuishio.superbwarfare.entity.projectile.*;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.DestroyableProjectileEntity;
|
|
||||||
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;
|
||||||
|
@ -19,6 +17,7 @@ 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;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.entity.EntityTypeTest;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
@ -47,6 +46,7 @@ public class SeekTool {
|
||||||
&& calculateAngle(e, entity) < seekAngle
|
&& calculateAngle(e, entity) < seekAngle
|
||||||
&& e != entity
|
&& e != entity
|
||||||
&& baseFilter(e)
|
&& baseFilter(e)
|
||||||
|
&& smokeFilter(e)
|
||||||
&& e.getVehicle() == null
|
&& e.getVehicle() == null
|
||||||
) {
|
) {
|
||||||
return level.clip(new ClipContext(
|
return level.clip(new ClipContext(
|
||||||
|
@ -69,6 +69,7 @@ public class SeekTool {
|
||||||
&& calculateAngle(e, entity) < seekAngle
|
&& calculateAngle(e, entity) < seekAngle
|
||||||
&& e != entity
|
&& e != entity
|
||||||
&& baseFilter(e)
|
&& baseFilter(e)
|
||||||
|
&& smokeFilter(e)
|
||||||
&& e.getVehicle() == null
|
&& e.getVehicle() == null
|
||||||
&& !(e instanceof SwarmDroneEntity swarmDrone && swarmDrone.getOwner() != entity)
|
&& !(e instanceof SwarmDroneEntity swarmDrone && swarmDrone.getOwner() != entity)
|
||||||
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {
|
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {
|
||||||
|
@ -88,6 +89,7 @@ public class SeekTool {
|
||||||
&& calculateAngle(e, entity) < seekAngle
|
&& calculateAngle(e, entity) < seekAngle
|
||||||
&& e != entity
|
&& e != entity
|
||||||
&& baseFilter(e)
|
&& baseFilter(e)
|
||||||
|
&& smokeFilter(e)
|
||||||
&& e.getVehicle() == null
|
&& e.getVehicle() == null
|
||||||
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))
|
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))
|
||||||
) {
|
) {
|
||||||
|
@ -109,6 +111,7 @@ public class SeekTool {
|
||||||
&& calculateAngleVehicle(e, vehicle) < seekAngle
|
&& calculateAngleVehicle(e, vehicle) < seekAngle
|
||||||
&& e != vehicle
|
&& e != vehicle
|
||||||
&& baseFilter(e)
|
&& baseFilter(e)
|
||||||
|
&& smokeFilter(e)
|
||||||
&& e.getVehicle() == null
|
&& e.getVehicle() == null
|
||||||
&& (!e.isAlliedTo(vehicle) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {
|
&& (!e.isAlliedTo(vehicle) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {
|
||||||
return level.clip(new ClipContext(
|
return level.clip(new ClipContext(
|
||||||
|
@ -137,7 +140,8 @@ public class SeekTool {
|
||||||
|
|
||||||
public static List<Entity> getEntitiesWithinRange(BlockPos pos, Level level, double range) {
|
public static List<Entity> getEntitiesWithinRange(BlockPos pos, Level level, double range) {
|
||||||
return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false)
|
return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false)
|
||||||
.filter(e -> e.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) <= range * range && baseFilter(e))
|
.filter(e -> e.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) <= range * range
|
||||||
|
&& baseFilter(e) && smokeFilter(e) && !(e instanceof DecoyEntity))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +172,25 @@ public class SeekTool {
|
||||||
|| includedByConfig(entity);
|
|| includedByConfig(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean smokeFilter(Entity pEntity) {
|
||||||
|
var Box = pEntity.getBoundingBox().inflate(8);
|
||||||
|
|
||||||
|
var entities = pEntity.level().getEntities(EntityTypeTest.forClass(Entity.class), Box,
|
||||||
|
entity -> entity instanceof SmokeDecoyEntity)
|
||||||
|
.stream().toList();
|
||||||
|
|
||||||
|
boolean result = true;
|
||||||
|
|
||||||
|
for (var e : entities) {
|
||||||
|
if (e != null) {
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean includedByConfig(Entity entity) {
|
public static boolean includedByConfig(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 VehicleConfig.COLLISION_ENTITY_WHITELIST.get().contains(type.toString());
|
||||||
|
|
|
@ -12,6 +12,8 @@ import net.minecraft.world.entity.projectile.ProjectileUtil;
|
||||||
import net.minecraft.world.level.ClipContext;
|
import net.minecraft.world.level.ClipContext;
|
||||||
import net.minecraft.world.phys.*;
|
import net.minecraft.world.phys.*;
|
||||||
|
|
||||||
|
import static com.atsuishio.superbwarfare.tools.SeekTool.smokeFilter;
|
||||||
|
|
||||||
public class TraceTool {
|
public class TraceTool {
|
||||||
|
|
||||||
public static boolean laserHeadshot = false;
|
public static boolean laserHeadshot = false;
|
||||||
|
@ -31,7 +33,7 @@ public class TraceTool {
|
||||||
Vec3 viewVec = entity.getViewVector(1.0F);
|
Vec3 viewVec = entity.getViewVector(1.0F);
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
||||||
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(entity, eyePos, toVec, aabb, p -> !p.isSpectator() && entity.getVehicle() != p && p.isAlive(), distance);
|
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(entity, eyePos, toVec, aabb, p -> !p.isSpectator() && entity.getVehicle() != p && p.isAlive() && smokeFilter(p), distance);
|
||||||
if (entityhitresult != null) {
|
if (entityhitresult != null) {
|
||||||
Vec3 targetPos = entityhitresult.getLocation();
|
Vec3 targetPos = entityhitresult.getLocation();
|
||||||
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
||||||
|
@ -75,7 +77,7 @@ public class TraceTool {
|
||||||
Vec3 viewVec = player.getViewVector(1.0F);
|
Vec3 viewVec = player.getViewVector(1.0F);
|
||||||
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
||||||
AABB aabb = player.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
AABB aabb = player.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
||||||
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, p -> !p.isSpectator() && player.getVehicle() != p && p.isAlive(), distance);
|
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, p -> !p.isSpectator() && player.getVehicle() != p && p.isAlive() && smokeFilter(p), distance);
|
||||||
if (entityhitresult != null) {
|
if (entityhitresult != null) {
|
||||||
Vec3 hitVec = entityhitresult.getLocation();
|
Vec3 hitVec = entityhitresult.getLocation();
|
||||||
if (checkNoClip(player, hitVec)) {
|
if (checkNoClip(player, hitVec)) {
|
||||||
|
@ -106,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), distance);
|
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);
|
||||||
if (entityhitresult != null) {
|
if (entityhitresult != null) {
|
||||||
hitResult = entityhitresult;
|
hitResult = entityhitresult;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue