优化直升机hud

This commit is contained in:
Atsuihsio 2025-01-12 19:41:30 +08:00
parent 3d23f3b91b
commit 1d7af26b72
2 changed files with 25 additions and 11 deletions

View file

@ -155,29 +155,43 @@ public class HelicopterHudOverlay {
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1; float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
double zoom = 0.96 * 3 + 0.06 * fovAdjust2; double zoom = 0.96 * 3 + 0.06 * fovAdjust2;
Vec3 pos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(500)); Vec3 pos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(192));
Vec3 lookAngle = player.getLookAngle().normalize().scale(pos.distanceTo(cameraPos) * (1 - 1.0 / zoom)); Vec3 lookAngle = player.getLookAngle().normalize().scale(pos.distanceTo(cameraPos) * (1 - 1.0 / zoom));
var cPos = cameraPos.add(lookAngle); var cPos = cameraPos.add(lookAngle);
Vec3 p = RenderHelper.worldToScreen(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(500)), ClientEventHandler.zoom ? cPos : cameraPos); Vec3 p = RenderHelper.worldToScreen(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(192)), ClientEventHandler.zoom ? cPos : cameraPos);
Vec3 p3 = RenderHelper.worldToScreen(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(500)), cameraPos); if (p != null) {
if (p != null && p3 != null) {
poseStack.pushPose(); poseStack.pushPose();
float x = (float) p.x; float x = (float) p.x;
float y = (float) p.y; float y = (float) p.y;
float x3 = (float) p3.x;
float y3 = (float) p3.y;
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) { if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/crosshair_ind.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16); preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/crosshair_ind.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f))); renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
} else if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) { } else if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/drone.png"), x3 - 8, y3 - 8, 0, 0, 16, 16, 16, 16); poseStack.pushPose();
renderKillIndicator(guiGraphics, x3 - 7.5f + (float) (2 * (Math.random() - 0.5f)), y3 - 7.5f + (float) (2 * (Math.random() - 0.5f))); poseStack.rotateAround(Axis.ZP.rotationDegrees(iHelicopterEntity.getRotZ(event.getPartialTick())), x, y, 0);
} preciseBlit(guiGraphics, ModUtils.loc("textures/screens/drone.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
poseStack.pushPose();
poseStack.translate(x, y, 0);
poseStack.scale(0.75f, 0.75f, 1);
if (multiWeaponVehicle.getWeaponType() == 0) {
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "" : iHelicopterEntity.getAmmoCount(player))), 25, -9, -1, false);
} else {
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), 25, -9, -1, false);
}
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("FLARE " + iHelicopterEntity.getDecoy()), 25, 1, -1, false);
poseStack.popPose();
poseStack.popPose();
}
poseStack.popPose(); poseStack.popPose();
} }

View file

@ -1243,12 +1243,12 @@ public class ClientEventHandler {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom && mc.options.getCameraType() == CameraType.FIRST_PERSON) { if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom) {
event.setFOV(event.getFOV() / 5); event.setFOV(event.getFOV() / 5);
return; return;
} }
if (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && zoom && mc.options.getCameraType() == CameraType.FIRST_PERSON) { if (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && zoom) {
event.setFOV(event.getFOV() / 3); event.setFOV(event.getFOV() / 3);
return; return;
} }