背后的火炮和标记一定不能显示!

This commit is contained in:
Atsuishio 2025-07-16 11:37:21 +08:00 committed by Light_Quanta
parent b4ea5bb23a
commit 5f22d530e7
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
3 changed files with 21 additions and 8 deletions

View file

@ -98,9 +98,11 @@ public class SpyglassRangeOverlay implements LayeredDraw.Layer {
pos = Vec3.ZERO;
}
Vec3 point = VectorUtil.worldToScreen(pos);
float x = (float) point.x;
float y = (float) point.y;
preciseBlit(guiGraphics, INDICATOR, Mth.clamp(x - 6, 0, screenWidth - 12), Mth.clamp(y - 6, 0, screenHeight - 12), 0, 0, 12, 12, 12, 12);
if (VectorUtil.canSee(pos)) {
float x = (float) point.x;
float y = (float) point.y;
preciseBlit(guiGraphics, INDICATOR, Mth.clamp(x - 6, 0, screenWidth - 12), Mth.clamp(y - 6, 0, screenHeight - 12), 0, 0, 12, 12, 12, 12);
}
// 火炮位置
@ -111,10 +113,11 @@ public class SpyglassRangeOverlay implements LayeredDraw.Layer {
if (entity != null) {
Vec3 posF = entity.getBoundingBox().getCenter();
Vec3 pointF = VectorUtil.worldToScreen(posF);
float xf = (float) pointF.x;
float yf = (float) pointF.y;
preciseBlit(guiGraphics, FRIENDLY_INDICATOR, Mth.clamp(xf - 6, 0, screenWidth - 12), Mth.clamp(yf - 6, 0, screenHeight - 12), 0, 0, 12, 12, 12, 12);
if (VectorUtil.canSee(posF)) {
float xf = (float) pointF.x;
float yf = (float) pointF.y;
preciseBlit(guiGraphics, FRIENDLY_INDICATOR, Mth.clamp(xf - 6, 0, screenWidth - 12), Mth.clamp(yf - 6, 0, screenHeight - 12), 0, 0, 12, 12, 12, 12);
}
}
}

View file

@ -105,7 +105,7 @@ public class VehicleTeamOverlay implements LayeredDraw.Layer {
if (player.getVehicle() instanceof VehicleEntity) {
List<Entity> entities = SeekTool.getPlayer(player, player.level());
for (var e : entities) {
if (e != null && e != player && calculateAngle(e, camera) < VectorUtil.fov) {
if (e != null && e != player && VectorUtil.canSee(e.position())) {
Entity team = e;
if (e.getVehicle() != null) {
team = e.getVehicle();

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.tools;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.world.phys.Vec3;
import net.neoforged.api.distmarker.Dist;
@ -48,4 +49,13 @@ public class VectorUtil {
fov = event.getFOV();
}
}
public static boolean canSee(Vec3 pos) {
Minecraft mc = Minecraft.getInstance();
Camera camera = mc.gameRenderer.getMainCamera();
Vec3 cameraPos = camera.getPosition();
Vec3 viewVec = new Vec3(camera.getLookVector());
Vec3 v1 = cameraPos.vectorTo(pos);
return VectorTool.calculateAngle(v1, viewVec) < fov;
}
}