提取载具UI渲染方法
This commit is contained in:
parent
cbdd279d40
commit
8e97519cd7
7 changed files with 177 additions and 114 deletions
|
@ -69,13 +69,13 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/compass_white.png"), (float) w / 2 - 128, (float) 10, 128 + ((float) 64 / 45 * (Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), cannon.yRotO, cannon.getYRot()))), 0, 256, 16, 512, 16);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/roll_ind_white.png"), w / 2F - 4, 27, 0, 0.0F, 8, 8, 8, 8);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/roll_ind_white.png"), (float) w / 2 - 4, 27, 0, 0.0F, 8, 8, 8, 8);
|
||||
|
||||
String angle = FormatTool.DECIMAL_FORMAT_1ZZ.format(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), cannon.yRotO, cannon.getYRot()));
|
||||
int width = Minecraft.getInstance().font.width(angle);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(angle), w / 2 - width / 2, 40, -1, false);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/cannon_pitch.png"), w / 2F + 166, h / 2F - 64, 0, 0.0F, 8, 128, 8, 128);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/cannon_pitch.png"), (float) w / 2 + 166, (float) h / 2 - 64, 0, 0.0F, 8, 128, 8, 128);
|
||||
|
||||
String pitch = FormatTool.DECIMAL_FORMAT_1ZZ.format(-Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), cannon.xRotO, cannon.getXRot()));
|
||||
int widthP = Minecraft.getInstance().font.width(pitch);
|
||||
|
@ -83,7 +83,7 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
poseStack.pushPose();
|
||||
|
||||
guiGraphics.pose().translate(0, Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), cannon.xRotO, cannon.getXRot()) * 0.7, 0);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/cannon_pitch_ind.png"), w / 2F + 158, h / 2F - 4, 0, 0.0F, 8, 8, 8, 8);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/cannon_pitch_ind.png"), (float) w / 2 + 158, (float) h / 2 - 4, 0, 0.0F, 8, 8, 8, 8);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(pitch), w / 2 + 157 - widthP, h / 2 - 4, -1, false);
|
||||
poseStack.popPose();
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
}
|
||||
float diffY = -Mth.wrapDegrees(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yHeadRotO, player.getYHeadRot()) - Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), cannon.yRotO, cannon.getYRot()));
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/indicator.png"), w / 2F - 4.3f + 0.45f * diffY, h / 2F - 10, 0, 0.0F, 8, 8, 8, 8);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/indicator.png"), (float) w / 2 - 4.3f + 0.45f * diffY, (float) h / 2 - 10, 0, 0.0F, 8, 8, 8, 8);
|
||||
} else {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/cannon_crosshair_notzoom.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.client.overlay;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.*;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.HeliRocketWeapon;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.LaserWeapon;
|
||||
|
@ -47,9 +47,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.LOADED_MISSILE;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity.MISSILE_COUNT;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity.*;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class VehicleHudOverlay implements LayeredDraw.Layer {
|
||||
|
@ -142,7 +139,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
public static void renderLandArmorHud(GuiGraphics guiGraphics, DeltaTracker deltaTracker, int w, int h) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
var player = mc.player;
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
|
@ -150,7 +147,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
assert player != null;
|
||||
|
||||
if (player.getVehicle() instanceof LandArmorEntity iLand && iLand.isDriver(player)
|
||||
&& iLand instanceof WeaponVehicleEntity weaponVehicle
|
||||
&& iLand instanceof WeaponVehicleEntity
|
||||
&& iLand instanceof MobileVehicleEntity mobileVehicle
|
||||
&& !(player.getVehicle() instanceof SpeedboatEntity)) {
|
||||
poseStack.pushPose();
|
||||
|
@ -167,12 +164,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
scopeScale = Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), scopeScale, 1F);
|
||||
float f = (float) Math.min(w, h);
|
||||
float f1 = Math.min((float) w / f, (float) h / f) * scopeScale;
|
||||
float i = Mth.floor(f * f1);
|
||||
float j = Mth.floor(f * f1);
|
||||
float k = ((w - i) / 2);
|
||||
float l = ((h - j) / 2);
|
||||
float scale = scopeScale;
|
||||
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || ClientEventHandler.zoomVehicle) {
|
||||
int addW = (w / h) * 48;
|
||||
|
@ -181,30 +173,6 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/line.png"), w / 2f - 64, h - 56, 0, 0.0F, 128, 1, 128, 1);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/line.png"), w / 2f + 112, h - 71, 0, 0.0F, 1, 16, 1, 16);
|
||||
|
||||
// 不同武器种类的准星
|
||||
if (weaponVehicle instanceof Yx100Entity) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/tank_cannon_cross_ap.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/tank_cannon_cross_he.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_gun_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 3) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_missile_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
|
||||
} else if (weaponVehicle instanceof PrismTankEntity) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_missile_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
} else {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_cannon_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_gun_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_missile_cross.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
}
|
||||
|
||||
// 指南针
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/compass.png"), (float) w / 2 - 128, (float) 10, 128 + ((float) 64 / 45 * player.getYRot()), 0, 256, 16, 512, 16);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/roll_ind.png"), w / 2f - 8, 30, 0, 0.0F, 16, 16, 16, 16);
|
||||
|
@ -245,6 +213,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
entityRange = player.distanceTo(lookingEntity);
|
||||
}
|
||||
|
||||
// 测距
|
||||
if (lookAtEntity) {
|
||||
guiGraphics.drawString(mc.font, Component.literal(FormatTool.format1D(entityRange, "m")),
|
||||
w / 2 - 6, h - 53, 0x66FF00, false);
|
||||
|
@ -257,43 +226,8 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
}
|
||||
}
|
||||
|
||||
// 武器名称
|
||||
// LAV-150
|
||||
if (player.getVehicle() instanceof Lav150Entity lav) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
double heat = 1 - lav.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : lav.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
} else {
|
||||
double heat = 1 - lav.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal("7.62MM COAX " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : lav.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
}
|
||||
}
|
||||
|
||||
// BMP-2
|
||||
if (player.getVehicle() instanceof Bmp2Entity bmp2) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
double heat = 1 - bmp2.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal(" 30MM 2A42 " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp2.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||
double heat = 1 - bmp2.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal(" 7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp2.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
} else {
|
||||
guiGraphics.drawString(mc.font, Component.literal(" 9M113 " + bmp2.getEntityData().get(LOADED_MISSILE) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp2.getEntityData().get(MISSILE_COUNT))), w / 2 - 33, h - 65, 0x66FF00, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// YX-100
|
||||
if (player.getVehicle() instanceof Yx100Entity yx100) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), w / 2 - 33, h - 65, 0x66FF00, false);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
||||
double heat = 1 - yx100.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal(" 12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getAmmoCount(player))), w / 2 - 33, h - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
}
|
||||
}
|
||||
// 载具自定义第一人称渲染
|
||||
mobileVehicle.renderFirstPersonOverlay(guiGraphics, mc.font, player, w, h, scale);
|
||||
|
||||
// 血量
|
||||
double heal = mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||
|
@ -308,7 +242,6 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
|
||||
poseStack.pushPose();
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 12, y - 12, 0, 0, 24, 24, 24, 24);
|
||||
renderKillIndicator3P(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
|
||||
|
@ -317,48 +250,16 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
|
||||
// LAV-150
|
||||
if (weaponVehicle instanceof Lav150Entity lav1501) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
double heat = lav1501.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : lav1501.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
} else {
|
||||
double heat2 = lav1501.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("7.62MM COAX " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : lav1501.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
||||
}
|
||||
}
|
||||
// BMP-2
|
||||
if (weaponVehicle instanceof Bmp2Entity bmp201) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
double heat = bmp201.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("30MM 2A42 " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp201.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||
double heat2 = bmp201.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp201.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("9M113 " + bmp201.getEntityData().get(LOADED_MISSILE) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : bmp201.getEntityData().get(MISSILE_COUNT))), 30, -9, -1, false);
|
||||
}
|
||||
}
|
||||
// YX-100
|
||||
if (weaponVehicle instanceof Yx100Entity yx100) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(AMMO))), 30, -9, -1, false);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
||||
double heat2 = yx100.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
||||
}
|
||||
}
|
||||
// 载具自定义第三人称准心
|
||||
mobileVehicle.renderThirdPersonOverlay(guiGraphics, mc.font, player, w, h, scale);
|
||||
|
||||
double heal = 1 - mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||
double health = 1 - mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HP " +
|
||||
FormatTool.format0D(100 * mobileVehicle.getHealth() / mobileVehicle.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) heal, 1.0F), false);
|
||||
FormatTool.format0D(100 * mobileVehicle.getHealth() / mobileVehicle.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) health, 1.0F), false);
|
||||
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
poseStack.popPose();
|
||||
|
|
|
@ -25,9 +25,13 @@ import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
|||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
|
@ -680,4 +684,32 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
public ResourceLocation getVehicleIcon() {
|
||||
return Mod.loc("textures/vehicle_icon/bmp2_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFirstPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
super.renderFirstPersonOverlay(guiGraphics, font, player, screenWidth, screenHeight, scale);
|
||||
|
||||
if (this.getWeaponIndex(0) == 0) {
|
||||
double heat = 1 - this.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal(" 30MM 2A42 " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), screenWidth / 2 - 33, screenHeight - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
} else if (this.getWeaponIndex(0) == 1) {
|
||||
double heat = 1 - this.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal(" 7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), screenWidth / 2 - 33, screenHeight - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
} else {
|
||||
guiGraphics.drawString(font, Component.literal(" 9M113 " + this.getEntityData().get(LOADED_MISSILE) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getEntityData().get(MISSILE_COUNT))), screenWidth / 2 - 33, screenHeight - 65, 0x66FF00, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderThirdPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
if (this.getWeaponIndex(0) == 0) {
|
||||
double heat = this.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("30MM 2A42 " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
} else if (this.getWeaponIndex(0) == 1) {
|
||||
double heat2 = this.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("7.62MM ПКТ " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
||||
} else {
|
||||
guiGraphics.drawString(font, Component.literal("9M113 " + this.getEntityData().get(LOADED_MISSILE) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getEntityData().get(MISSILE_COUNT))), 30, -9, -1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,13 @@ import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
|||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -587,4 +591,30 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
public ResourceLocation getVehicleIcon() {
|
||||
return Mod.loc("textures/vehicle_icon/lav150_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFirstPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
super.renderFirstPersonOverlay(guiGraphics, font, player, screenWidth, screenHeight, scale);
|
||||
|
||||
if (this.getWeaponIndex(0) == 0) {
|
||||
double heat = 1 - this.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), screenWidth / 2 - 33, screenHeight - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
} else {
|
||||
double heat = 1 - this.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("7.62MM COAX " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), screenWidth / 2 - 33, screenHeight - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderThirdPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
super.renderThirdPersonOverlay(guiGraphics, font, player, screenWidth, screenHeight, scale);
|
||||
|
||||
if (this.getWeaponIndex(0) == 0) {
|
||||
double heat = this.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
} else {
|
||||
double heat2 = this.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("7.62MM COAX " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
|||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
|
@ -66,6 +69,7 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
import static com.atsuishio.superbwarfare.tools.SeekTool.baseFilter;
|
||||
|
||||
|
@ -737,4 +741,27 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
public ResourceLocation getVehicleIcon() {
|
||||
return Mod.loc("textures/vehicle_icon/prism_tank_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFirstPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
float minWH = (float) Math.min(screenWidth, screenHeight);
|
||||
float scaledMinWH = Mth.floor(minWH * scale);
|
||||
float centerW = ((screenWidth - scaledMinWH) / 2);
|
||||
float centerH = ((screenHeight - scaledMinWH) / 2);
|
||||
|
||||
// 准心
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_missile_cross.png"), centerW, centerH, 0, 0.0F, scaledMinWH, scaledMinWH, scaledMinWH, scaledMinWH);
|
||||
|
||||
// 武器名称+过热
|
||||
double heat = 1 - this.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("LASER " + (this.getEntityData().get(HEAT) + 25) + " ℃"), screenWidth / 2 - 33, screenHeight - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderThirdPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
super.renderThirdPersonOverlay(guiGraphics, font, player, screenWidth, screenHeight, scale);
|
||||
|
||||
double heat = this.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("LASER " + (this.getEntityData().get(HEAT) + 25) + " ℃"), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ import com.mojang.math.Axis;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.CameraType;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -53,6 +56,7 @@ import net.minecraft.world.phys.Vec3;
|
|||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
import software.bernie.geckolib.animatable.GeoEntity;
|
||||
|
@ -62,6 +66,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
|
||||
import java.util.Comparator;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
||||
public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity {
|
||||
|
@ -1158,4 +1163,45 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
public ResourceLocation getVehicleIcon() {
|
||||
return Mod.loc("textures/vehicle_icon/yx_100_icon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFirstPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
float minWH = (float) Math.min(screenWidth, screenHeight);
|
||||
float scaledMinWH = Mth.floor(minWH * scale);
|
||||
float centerW = ((screenWidth - scaledMinWH) / 2);
|
||||
float centerH = ((screenHeight - scaledMinWH) / 2);
|
||||
|
||||
// 准心
|
||||
if (this.getWeaponIndex(0) == 0) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/tank_cannon_cross_ap.png"), centerW, centerH, 0, 0.0F, scaledMinWH, scaledMinWH, scaledMinWH, scaledMinWH);
|
||||
} else if (this.getWeaponIndex(0) == 1) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/tank_cannon_cross_he.png"), centerW, centerH, 0, 0.0F, scaledMinWH, scaledMinWH, scaledMinWH, scaledMinWH);
|
||||
} else if (this.getWeaponIndex(0) == 2) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_gun_cross.png"), centerW, centerH, 0, 0.0F, scaledMinWH, scaledMinWH, scaledMinWH, scaledMinWH);
|
||||
} else if (this.getWeaponIndex(0) == 3) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/land/lav_missile_cross.png"), centerW, centerH, 0, 0.0F, scaledMinWH, scaledMinWH, scaledMinWH, scaledMinWH);
|
||||
}
|
||||
|
||||
// 武器名称
|
||||
if (this.getWeaponIndex(0) == 0) {
|
||||
guiGraphics.drawString(font, Component.literal("AP SHELL " + this.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getEntityData().get(AMMO))), screenWidth / 2 - 33, screenHeight - 65, 0x66FF00, false);
|
||||
} else if (this.getWeaponIndex(0) == 1) {
|
||||
guiGraphics.drawString(font, Component.literal("HE SHELL " + this.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getEntityData().get(AMMO))), screenWidth / 2 - 33, screenHeight - 65, 0x66FF00, false);
|
||||
} else if (this.getWeaponIndex(0) == 2) {
|
||||
double heat = 1 - this.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal(" 12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), screenWidth / 2 - 33, screenHeight - 65, Mth.hsvToRgb((float) heat / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderThirdPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
if (this.getWeaponIndex(0) == 0) {
|
||||
guiGraphics.drawString(font, Component.literal("AP SHELL " + this.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getEntityData().get(AMMO))), 30, -9, -1, false);
|
||||
} else if (this.getWeaponIndex(0) == 1) {
|
||||
guiGraphics.drawString(font, Component.literal("HE SHELL " + this.getAmmoCount(player) + " " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getEntityData().get(AMMO))), 30, -9, -1, false);
|
||||
} else if (this.getWeaponIndex(0) == 2) {
|
||||
double heat2 = this.getEntityData().get(COAX_HEAT) / 100.0F;
|
||||
guiGraphics.drawString(font, Component.literal("12.7MM HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : this.getAmmoCount(player))), 30, -9, Mth.hsvToRgb(0F, (float) heat2, 1.0F), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.mojang.math.Axis;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
|
@ -59,6 +62,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
||||
public abstract class VehicleEntity extends Entity {
|
||||
|
@ -940,4 +944,27 @@ public abstract class VehicleEntity extends Entity {
|
|||
this.gunXRot = pGunXRot;
|
||||
}
|
||||
|
||||
public void renderFirstPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
if (!(this instanceof WeaponVehicleEntity weaponVehicle)) return;
|
||||
|
||||
float minWH = (float) Math.min(screenWidth, screenHeight);
|
||||
float scaledMinWH = Mth.floor(minWH * scale);
|
||||
float centerW = ((screenWidth - scaledMinWH) / 2);
|
||||
float centerH = ((screenHeight - scaledMinWH) / 2);
|
||||
|
||||
// 默认武器准心渲染
|
||||
var texture = Mod.loc(switch (weaponVehicle.getWeaponIndex(0)) {
|
||||
case 0 -> "textures/screens/land/lav_cannon_cross.png";
|
||||
case 1 -> "textures/screens/land/lav_gun_cross.png";
|
||||
case 2 -> "textures/screens/land/lav_missile_cross.png";
|
||||
default -> "";
|
||||
});
|
||||
if (texture.getPath().isEmpty()) return;
|
||||
|
||||
preciseBlit(guiGraphics, texture, centerW, centerH, 0, 0, scaledMinWH, scaledMinWH, scaledMinWH, scaledMinWH);
|
||||
}
|
||||
|
||||
public void renderThirdPersonOverlay(GuiGraphics guiGraphics, Font font, LocalPlayer player, int screenWidth, int screenHeight, float scale) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue