修改VehicleHudOverlay图标
This commit is contained in:
parent
6403491f59
commit
4c6cd9be3b
3 changed files with 69 additions and 13 deletions
|
@ -80,17 +80,17 @@ public class VehicleHudOverlay {
|
|||
if (vehicle instanceof EnergyVehicleEntity energyVehicleEntity) {
|
||||
float energy = energyVehicleEntity.getEnergy();
|
||||
float maxEnergy = energyVehicleEntity.getMaxEnergy();
|
||||
guiGraphics.blit(ENERGY, 10, h - 22 - compatHeight, 100, 0, 0, 8, 8, 8, 8);
|
||||
guiGraphics.blit(HEALTH_FRAME, 20, h - 21 - compatHeight, 100, 0, 0, 60, 6, 60, 6);
|
||||
guiGraphics.blit(HEALTH, 20, h - 21 - compatHeight, 100, 0, 0, (int) (60 * energy / maxEnergy), 6, 60, 6);
|
||||
preciseBlit(guiGraphics, ENERGY, 10, h - 22 - compatHeight, 100, 0, 0, 8, 8, 8, 8);
|
||||
preciseBlit(guiGraphics, HEALTH_FRAME, 20, h - 21 - compatHeight, 100, 0, 0, 60, 6, 60, 6);
|
||||
preciseBlit(guiGraphics, HEALTH, 20, h - 21 - compatHeight, 100, 0, 0, (int) (60 * energy / maxEnergy), 6, 60, 6);
|
||||
}
|
||||
|
||||
if (vehicle instanceof VehicleEntity pVehicle) {
|
||||
float health = pVehicle.getHealth();
|
||||
float maxHealth = pVehicle.getMaxHealth();
|
||||
guiGraphics.blit(ARMOR, 10, h - 13 - compatHeight, 100, 0, 0, 8, 8, 8, 8);
|
||||
guiGraphics.blit(HEALTH_FRAME, 20, h - 12 - compatHeight, 100, 0, 0, 60, 6, 60, 6);
|
||||
guiGraphics.blit(HEALTH, 20, h - 12 - compatHeight, 100, 0, 0, (int) (60 * health / maxHealth), 6, 60, 6);
|
||||
preciseBlit(guiGraphics, ARMOR, 10, h - 13 - compatHeight, 100, 0, 0, 8, 8, 8, 8);
|
||||
preciseBlit(guiGraphics, HEALTH_FRAME, 20, h - 12 - compatHeight, 100, 0, 0, 60, 6, 60, 6);
|
||||
preciseBlit(guiGraphics, HEALTH, 20, h - 12 - compatHeight, 100, 0, 0, (int) (60 * health / maxHealth), 6, 60, 6);
|
||||
}
|
||||
poseStack.popPose();
|
||||
|
||||
|
@ -209,8 +209,8 @@ public class VehicleHudOverlay {
|
|||
int addW = (w / h) * 48;
|
||||
int addH = (w / h) * 27;
|
||||
preciseBlit(guiGraphics, FRAME, (float) -addW / 2, (float) -addH / 2, 10, 0, 0.0F, w + addW, h + addH, w + addW, h + addH);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/line.png"), w / 2 - 64, h - 56, 0, 0.0F, 128, 1, 128, 1);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/line.png"), w / 2 + 112, h - 71, 0, 0.0F, 1, 16, 1, 16);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/line.png"), w / 2f - 64, h - 56, 0, 0.0F, 128, 1, 128, 1);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/line.png"), w / 2f + 112, h - 71, 0, 0.0F, 1, 16, 1, 16);
|
||||
|
||||
// 不同武器种类的准星
|
||||
if (multiWeaponVehicle.getWeaponType() == 0) {
|
||||
|
@ -223,12 +223,12 @@ public class VehicleHudOverlay {
|
|||
|
||||
// 指南针
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/compass.png"), (float) w / 2 - 128, (float) 10, 128 + ((float) 64 / 45 * player.getYRot()), 0, 256, 16, 512, 16);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/roll_ind.png"), w / 2 - 8, 30, 0, 0.0F, 16, 16, 16, 16);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/roll_ind.png"), w / 2f - 8, 30, 0, 0.0F, 16, 16, 16, 16);
|
||||
|
||||
// 炮塔方向
|
||||
poseStack.pushPose();
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(Mth.lerp(event.getPartialTick(), iLand.turretYRotO(), iLand.turretYRot())), w / 2 + 112, h - 56, 0);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/body.png"), w / 2 + 96, h - 72, 0, 0.0F, 32, 32, 32, 32);
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(Mth.lerp(event.getPartialTick(), iLand.turretYRotO(), iLand.turretYRot())), w / 2f + 112, h - 56, 0);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/land/body.png"), w / 2f + 96, h - 72, 0, 0.0F, 32, 32, 32, 32);
|
||||
poseStack.popPose();
|
||||
|
||||
// 时速
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package com.atsuishio.superbwarfare.compat.jade.elements;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import snownee.jade.api.Identifiers;
|
||||
import snownee.jade.api.theme.IThemeHelper;
|
||||
import snownee.jade.api.ui.Element;
|
||||
import snownee.jade.impl.config.PluginConfig;
|
||||
import snownee.jade.overlay.DisplayHelper;
|
||||
import snownee.jade.overlay.OverlayRenderer;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
|
||||
public class WrenchHealthElement extends Element {
|
||||
private final String text;
|
||||
|
||||
public WrenchHealthElement(float maxHealth, float health) {
|
||||
if (!PluginConfig.INSTANCE.get(Identifiers.MC_ENTITY_HEALTH_SHOW_FRACTIONS)) {
|
||||
maxHealth = (float) Mth.ceil(maxHealth);
|
||||
health = (float) Mth.ceil(health);
|
||||
}
|
||||
|
||||
this.text = String.format(" %s/%s", DisplayHelper.dfCommas.format(health), DisplayHelper.dfCommas.format(maxHealth));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec2 getSize() {
|
||||
Font font = Minecraft.getInstance().font;
|
||||
return new Vec2(8F + font.width(this.text), 10.0F);
|
||||
}
|
||||
|
||||
private static final ResourceLocation WRENCH_ICON = ModUtils.loc("textures/screens/vehicle_health.png");
|
||||
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, float x, float y, float maxX, float maxY) {
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, OverlayRenderer.alpha);
|
||||
RenderSystem.setShaderTexture(0, WRENCH_ICON);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
|
||||
// 扳手图标
|
||||
preciseBlit(guiGraphics, WRENCH_ICON, x + 2, y, 0, 0, 8, 8, 8, 8);
|
||||
// 文字
|
||||
DisplayHelper.INSTANCE.drawText(guiGraphics, this.text, x + 6, y, IThemeHelper.get().getNormalColor());
|
||||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package com.atsuishio.superbwarfare.compat.jade.providers;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.compat.jade.elements.WrenchHealthElement;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import snownee.jade.api.EntityAccessor;
|
||||
import snownee.jade.api.IEntityComponentProvider;
|
||||
import snownee.jade.api.ITooltip;
|
||||
import snownee.jade.api.config.IPluginConfig;
|
||||
import snownee.jade.impl.ui.HealthElement;
|
||||
|
||||
public enum VehicleHealthProvider implements IEntityComponentProvider {
|
||||
INSTANCE;
|
||||
|
@ -20,7 +20,8 @@ public enum VehicleHealthProvider implements IEntityComponentProvider {
|
|||
var vehicle = (VehicleEntity) accessor.getEntity();
|
||||
float health = vehicle.getHealth();
|
||||
float maxHealth = vehicle.getMaxHealth();
|
||||
tooltip.add(new HealthElement(maxHealth, health));
|
||||
// tooltip.add(new HealthElement(maxHealth, health));
|
||||
tooltip.add(new WrenchHealthElement(maxHealth, health));
|
||||
}
|
||||
|
||||
public ResourceLocation getUid() {
|
||||
|
|
Loading…
Add table
Reference in a new issue