From 46f9428889c4048eee69c60a5ed4ed5edbb07369 Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Tue, 24 Dec 2024 15:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=87=E6=9E=AA=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E5=92=8C=E4=BF=AE=E5=A4=8D=E6=94=BB=E9=A1=B6=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E9=AC=BC=E7=95=9C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/screens/JavelinHudOverlay.java | 13 ++++++++---- .../projectile/JavelinMissileEntity.java | 21 +++++++++++-------- .../superbwarfare/tools/ProjectileTool.java | 2 +- .../superbwarfare/tools/SeekTool.java | 10 +++++++-- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/JavelinHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/JavelinHudOverlay.java index 9f5a4b3c9..27ca43788 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/JavelinHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/JavelinHudOverlay.java @@ -89,11 +89,16 @@ public class JavelinHudOverlay { RenderSystem.disableBlend(); RenderSystem.setShaderColor(1, 1, 1, 1); - Entity targetEntity = EntityFindUtil.findEntity(player.level(), stack.getOrCreateTag().getString("TargetEntity")); - List entities = SeekTool.seekLivingEntities(player, player.level(), 512, 10); - Entity naerestEntity = SeekTool.seekLivingEntity(player, player.level(), 512, 10); + float fovAdjust = (float) Minecraft.getInstance().options.fov().get() / 80; - double zoom = 3; + + Entity targetEntity = EntityFindUtil.findEntity(player.level(), stack.getOrCreateTag().getString("TargetEntity")); + List 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) { Vec3 pos = new Vec3(e.getX(), e.getEyeY(), e.getZ()); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java index 3fc4500f2..c915b1097 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java @@ -188,6 +188,12 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo 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.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); @@ -197,16 +203,13 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo if (this.tickCount > 3) { if (entityData.get(TOP)) { - double px = this.getX(); - 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) { + if (!dir) { 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 { 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 { 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) { this.setDeltaMovement(new Vec3( - 0.7f * this.getDeltaMovement().x + 1.3f * this.getLookAngle().x, - 0.7f * this.getDeltaMovement().y + 1.3f * this.getLookAngle().y, - 0.7f * this.getDeltaMovement().z + 1.3f * this.getLookAngle().z + 0.7f * this.getDeltaMovement().x + (dir ? 3 : 1.3f) * this.getLookAngle().x, + 0.7f * this.getDeltaMovement().y + (dir ? 3 : 1.3f) * this.getLookAngle().y, + 0.7f * this.getDeltaMovement().z + (dir ? 3 : 1.3f) * this.getLookAngle().z )); 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); diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/ProjectileTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/ProjectileTool.java index 92eb1a973..87032bdef 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/ProjectileTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/ProjectileTool.java @@ -17,7 +17,7 @@ public class ProjectileTool { explosion.explode(); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion); explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(projectile.level(), projectile.position()); + ParticleTool.spawnMediumExplosionParticles(projectile.level(), target.position()); projectile.discard(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java index a57fa83f6..3fd15ba66 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java @@ -4,7 +4,11 @@ import com.atsuishio.superbwarfare.entity.IVehicleEntity; import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.ExperienceOrb; 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.projectile.Projectile; import net.minecraft.world.level.ClipContext; @@ -25,8 +29,8 @@ public class SeekTool { && e != entity && e.isAlive() && e.getVehicle() == null - && !(e instanceof ProjectileEntity) - && !(e instanceof Projectile)) { + && !(e instanceof ItemEntity || e instanceof ExperienceOrb || e instanceof HangingEntity || e instanceof ProjectileEntity || e instanceof Projectile || e instanceof ArmorStand) + ) { return level.clip(new ClipContext(entity.getEyePosition(), e.getEyePosition(), 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 && e != entity && 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 Player player && (player.isCreative() || player.isSpectator())) && (!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 && e != entity && 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 Player player && (player.isCreative() || player.isSpectator())) && (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {