优化63式弹药显示效果
This commit is contained in:
parent
0b2823abe9
commit
919fd1aa1c
1 changed files with 23 additions and 13 deletions
|
@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.component.ModDataComponents;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity;
|
import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.item.FiringParameters;
|
import com.atsuishio.superbwarfare.item.FiringParameters;
|
||||||
import com.atsuishio.superbwarfare.item.common.ammo.MediumRocketItem;
|
|
||||||
import com.atsuishio.superbwarfare.tools.*;
|
import com.atsuishio.superbwarfare.tools.*;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
|
@ -37,6 +36,10 @@ public class Type63InfoOverlay implements LayeredDraw.Layer {
|
||||||
|
|
||||||
public static final ResourceLocation ID = Mod.loc("type_63_info");
|
public static final ResourceLocation ID = Mod.loc("type_63_info");
|
||||||
|
|
||||||
|
private static final ItemStack AP = new ItemStack(ModItems.MEDIUM_ROCKET_AP.get());
|
||||||
|
private static final ItemStack HE = new ItemStack(ModItems.MEDIUM_ROCKET_HE.get());
|
||||||
|
private static final ItemStack CM = new ItemStack(ModItems.MEDIUM_ROCKET_CM.get());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, @NotNull DeltaTracker deltaTracker) {
|
public void render(GuiGraphics guiGraphics, @NotNull DeltaTracker deltaTracker) {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
@ -70,9 +73,9 @@ public class Type63InfoOverlay implements LayeredDraw.Layer {
|
||||||
int type = items.get(i);
|
int type = items.get(i);
|
||||||
|
|
||||||
ItemStack stack = switch (type) {
|
ItemStack stack = switch (type) {
|
||||||
case 0 -> new ItemStack(ModItems.MEDIUM_ROCKET_AP.get());
|
case 0 -> AP;
|
||||||
case 1 -> new ItemStack(ModItems.MEDIUM_ROCKET_HE.get());
|
case 1 -> HE;
|
||||||
case 2 -> new ItemStack(ModItems.MEDIUM_ROCKET_CM.get());
|
case 2 -> CM;
|
||||||
default -> ItemStack.EMPTY;
|
default -> ItemStack.EMPTY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,20 +86,27 @@ public class Type63InfoOverlay implements LayeredDraw.Layer {
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
float x = (float) point.x;
|
float x = (float) point.x;
|
||||||
float y = (float) point.y;
|
float y = (float) point.y;
|
||||||
poseStack.translate(x, y, 0);
|
|
||||||
|
|
||||||
var component = Component.literal("[").append(stack.getHoverName()).append("]");
|
var component = stack.getHoverName();
|
||||||
|
|
||||||
if (!(stack.getItem() instanceof MediumRocketItem)) {
|
if (stack.isEmpty()) {
|
||||||
component = Component.literal("[").append(Component.translatable("tips.superbwarfare.barrel_empty")).append("]");
|
component = Component.translatable("tips.superbwarfare.barrel_empty");
|
||||||
|
int width = Minecraft.getInstance().font.width(component);
|
||||||
|
|
||||||
|
poseStack.translate(x - width / 2F, y, 0);
|
||||||
|
guiGraphics.drawString(Minecraft.getInstance().font, component, 0, 0, -1, false);
|
||||||
|
} else {
|
||||||
|
int width = Minecraft.getInstance().font.width(component) + 20;
|
||||||
|
|
||||||
|
poseStack.pushPose();
|
||||||
|
poseStack.translate(x - width / 2F, y, 0);
|
||||||
|
guiGraphics.renderFakeItem(stack, 0, 0);
|
||||||
|
|
||||||
|
poseStack.translate(20, 4, 0);
|
||||||
|
guiGraphics.drawString(Minecraft.getInstance().font, component, 0, 0, -1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int width = Minecraft.getInstance().font.width(component);
|
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, component, -width / 2, -4, -1, false);
|
|
||||||
|
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue