背后的火炮和标记一定不能显示!
This commit is contained in:
parent
b4ea5bb23a
commit
5f22d530e7
3 changed files with 21 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue