优化标枪锁定和修复攻顶模式鬼畜问题

This commit is contained in:
Atsuihsio 2024-12-24 15:50:41 +08:00
parent 9b5d17c304
commit 46f9428889
4 changed files with 30 additions and 16 deletions

View file

@ -89,11 +89,16 @@ public class JavelinHudOverlay {
RenderSystem.disableBlend(); RenderSystem.disableBlend();
RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderColor(1, 1, 1, 1);
Entity targetEntity = EntityFindUtil.findEntity(player.level(), stack.getOrCreateTag().getString("TargetEntity")); float fovAdjust = (float) Minecraft.getInstance().options.fov().get() / 80;
List<Entity> entities = SeekTool.seekLivingEntities(player, player.level(), 512, 10);
Entity naerestEntity = SeekTool.seekLivingEntity(player, player.level(), 512, 10);
double zoom = 3;
Entity targetEntity = EntityFindUtil.findEntity(player.level(), stack.getOrCreateTag().getString("TargetEntity"));
List<Entity> entities = SeekTool.seekLivingEntities(player, player.level(), 512, 10 * fovAdjust);
Entity naerestEntity = SeekTool.seekLivingEntity(player, player.level(), 512, 8);
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
double zoom = 3.1 + 0.5 * fovAdjust2;
for (var e : entities) { for (var e : entities) {
Vec3 pos = new Vec3(e.getX(), e.getEyeY(), e.getZ()); Vec3 pos = new Vec3(e.getX(), e.getEyeY(), e.getZ());

View file

@ -188,6 +188,12 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo
this.entityData.set(TARGET_Z, (float) entity.getZ()); this.entityData.set(TARGET_Z, (float) entity.getZ());
} }
double px = this.getX();
double ex = this.entityData.get(TARGET_X);
double pz = this.getZ();
double ez = this.entityData.get(TARGET_Z);
boolean dir = Math.sqrt(Math.pow(px - ex, 2) + Math.pow(pz - ez, 2)) < 10;
if (this.tickCount == 4) { if (this.tickCount == 4) {
if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) { if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.CLOUD, this.xo, this.yo, this.zo, 15, 0.8, 0.8, 0.8, 0.01, true); ParticleTool.sendParticle(serverLevel, ParticleTypes.CLOUD, this.xo, this.yo, this.zo, 15, 0.8, 0.8, 0.8, 0.01, true);
@ -197,16 +203,13 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo
if (this.tickCount > 3) { if (this.tickCount > 3) {
if (entityData.get(TOP)) { if (entityData.get(TOP)) {
double px = this.getX(); if (!dir) {
double ex = this.entityData.get(TARGET_X);
double pz = this.getZ();
double ez = this.entityData.get(TARGET_Z);
if (Math.sqrt(Math.pow(px - ex, 2) + Math.pow(pz - ez, 2)) > 10) {
this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + Mth.clamp(4 * this.tickCount, 0, 90), this.entityData.get(TARGET_Z))); this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + Mth.clamp(4 * this.tickCount, 0, 90), this.entityData.get(TARGET_Z)));
} else { } else {
this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + (entity instanceof EnderDragon ? -3 : 0), this.entityData.get(TARGET_Z))); this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + (entity instanceof EnderDragon ? -3 : 0), this.entityData.get(TARGET_Z)));
this.setDeltaMovement(this.getDeltaMovement().scale(1.1));
} }
} else { } else {
this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + (entity instanceof EnderDragon ? -3 : 0), this.entityData.get(TARGET_Z))); this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + (entity instanceof EnderDragon ? -3 : 0), this.entityData.get(TARGET_Z)));
} }
@ -214,9 +217,9 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo
if (this.tickCount > 4) { if (this.tickCount > 4) {
this.setDeltaMovement(new Vec3( this.setDeltaMovement(new Vec3(
0.7f * this.getDeltaMovement().x + 1.3f * this.getLookAngle().x, 0.7f * this.getDeltaMovement().x + (dir ? 3 : 1.3f) * this.getLookAngle().x,
0.7f * this.getDeltaMovement().y + 1.3f * this.getLookAngle().y, 0.7f * this.getDeltaMovement().y + (dir ? 3 : 1.3f) * this.getLookAngle().y,
0.7f * this.getDeltaMovement().z + 1.3f * this.getLookAngle().z 0.7f * this.getDeltaMovement().z + (dir ? 3 : 1.3f) * this.getLookAngle().z
)); ));
if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) { if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.xo, this.yo, this.zo, 1, 0, 0, 0, 0, true); ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.xo, this.yo, this.zo, 1, 0, 0, 0, 0, true);

View file

@ -17,7 +17,7 @@ public class ProjectileTool {
explosion.explode(); explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
explosion.finalizeExplosion(false); explosion.finalizeExplosion(false);
ParticleTool.spawnMediumExplosionParticles(projectile.level(), projectile.position()); ParticleTool.spawnMediumExplosionParticles(projectile.level(), target.position());
projectile.discard(); projectile.discard();
} }

View file

@ -4,7 +4,11 @@ import com.atsuishio.superbwarfare.entity.IVehicleEntity;
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.decoration.ArmorStand;
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;
@ -25,8 +29,8 @@ public class SeekTool {
&& e != entity && e != entity
&& e.isAlive() && e.isAlive()
&& e.getVehicle() == null && e.getVehicle() == null
&& !(e instanceof ProjectileEntity) && !(e instanceof ItemEntity || e instanceof ExperienceOrb || e instanceof HangingEntity || e instanceof ProjectileEntity || e instanceof Projectile || e instanceof ArmorStand)
&& !(e instanceof Projectile)) { ) {
return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(), return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(),
ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() != HitResult.Type.BLOCK; ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() != HitResult.Type.BLOCK;
} }
@ -40,6 +44,7 @@ public class SeekTool {
if (e.distanceTo(entity) <= seekRange && calculateAngle(e, entity) < seekAngle if (e.distanceTo(entity) <= seekRange && calculateAngle(e, entity) < seekAngle
&& e != entity && e != entity
&& e.isAlive() && e.isAlive()
&& !(e instanceof ItemEntity || e instanceof ExperienceOrb || e instanceof HangingEntity || e instanceof ProjectileEntity || e instanceof Projectile || e instanceof ArmorStand)
&& (e instanceof LivingEntity || e instanceof IVehicleEntity) && (e instanceof LivingEntity || e instanceof IVehicleEntity)
&& !(e instanceof Player player && (player.isCreative() || player.isSpectator())) && !(e instanceof Player player && (player.isCreative() || player.isSpectator()))
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) { && (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {
@ -56,6 +61,7 @@ public class SeekTool {
if (e.distanceTo(entity) <= seekRange && calculateAngle(e, entity) < seekAngle if (e.distanceTo(entity) <= seekRange && calculateAngle(e, entity) < seekAngle
&& e != entity && e != entity
&& e.isAlive() && e.isAlive()
&& !(e instanceof ItemEntity || e instanceof ExperienceOrb || e instanceof HangingEntity || e instanceof ProjectileEntity || e instanceof Projectile || e instanceof ArmorStand)
&& (e instanceof LivingEntity || e instanceof IVehicleEntity) && (e instanceof LivingEntity || e instanceof IVehicleEntity)
&& !(e instanceof Player player && (player.isCreative() || player.isSpectator())) && !(e instanceof Player player && (player.isCreative() || player.isSpectator()))
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) { && (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {