mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Updated hud texture and added page indicators. Fixes #415
This commit is contained in:
parent
b3068780ae
commit
b53a51173c
3 changed files with 17 additions and 14 deletions
|
@ -14,6 +14,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
|
@ -145,10 +146,7 @@ class Slot {
|
|||
return;
|
||||
}
|
||||
|
||||
MutableText label = KeyBindingsHandler.INSTANCE.getBinding(aSlot).getLabel().copy().formatted(Formatting.BOLD);
|
||||
|
||||
MatrixStack matrices = context.getMatrices();
|
||||
matrices.push();
|
||||
MutableText label = KeyBindingsHandler.INSTANCE.getBinding(aSlot).getLabel().copy();
|
||||
|
||||
int x = getX();
|
||||
if (uHud.xDirection > 0) {
|
||||
|
@ -158,9 +156,6 @@ class Slot {
|
|||
x -= uHud.client.textRenderer.getWidth(label)/2;
|
||||
}
|
||||
|
||||
matrices.translate(x, getY() + labelY, 0);
|
||||
matrices.scale(0.5F, 0.5F, 0.5F);
|
||||
|
||||
ActivationType activation = KeyBindingsHandler.INSTANCE.getForcedActivationType();
|
||||
if (activation.isResult()) {
|
||||
label = label.append("+T" + activation.getTapCount());
|
||||
|
@ -169,8 +164,6 @@ class Slot {
|
|||
}
|
||||
}
|
||||
|
||||
context.drawText(uHud.font, label, 0, 0, 0xFFFFFF, true);
|
||||
|
||||
matrices.pop();
|
||||
DrawableUtil.drawScaledText(context, label, x, getY() + labelY, 0.5F, Colors.WHITE);
|
||||
}
|
||||
}
|
|
@ -51,8 +51,8 @@ public class UHud {
|
|||
|
||||
private final List<Slot> slots = List.of(
|
||||
new ManaRingSlot(this, AbilitySlot.PRIMARY, AbilitySlot.PASSIVE, 0, 0),
|
||||
new Slot(this, AbilitySlot.SECONDARY, AbilitySlot.SECONDARY, 30, -8),
|
||||
new Slot(this, AbilitySlot.TERTIARY, AbilitySlot.TERTIARY, 40, 18)
|
||||
new Slot(this, AbilitySlot.SECONDARY, AbilitySlot.SECONDARY, 30, -10),
|
||||
new Slot(this, AbilitySlot.TERTIARY, AbilitySlot.TERTIARY, 43, 10)
|
||||
);
|
||||
|
||||
@Nullable
|
||||
|
@ -137,9 +137,11 @@ public class UHud {
|
|||
|
||||
slots.forEach(slot -> slot.renderBackground(context, abilities, swap, tickDelta));
|
||||
|
||||
int currentPage = Unicopia.getConfig().hudPage.get();
|
||||
int maxPages = pony.getAbilities().getMaxPage();
|
||||
|
||||
Ability<?> ability = pony.getAbilities().getStat(AbilitySlot.PRIMARY)
|
||||
.getAbility(Unicopia.getConfig().hudPage.get())
|
||||
.getAbility(currentPage)
|
||||
.orElse(null);
|
||||
boolean canCast = ability == Abilities.CAST || ability == Abilities.KIRIN_CAST || ability == Abilities.SHOOT;
|
||||
|
||||
|
@ -168,6 +170,14 @@ public class UHud {
|
|||
|
||||
slots.forEach(slot -> slot.renderLabel(context, abilities, tickDelta));
|
||||
|
||||
//if (maxPages > 0) {
|
||||
DrawableUtil.drawScaledText(context, Text.literal((currentPage + 1) + "/" + (maxPages + 1)), 44, 38, 0.5F, Colors.WHITE);
|
||||
//down
|
||||
context.drawTexture(HUD_TEXTURE, 42, 43, 52, currentPage == 0 ? 6 : 0, 6, 6, 128, 128);
|
||||
//up
|
||||
context.drawTexture(HUD_TEXTURE, 48, 43, 57, currentPage < maxPages ? 0 : 6, 8, 6, 128, 128);
|
||||
//}
|
||||
|
||||
matrices.pop();
|
||||
|
||||
if (canCast) {
|
||||
|
@ -188,7 +198,7 @@ public class UHud {
|
|||
int progress = Math.min(255, (int)(time * 255F / 20F));
|
||||
|
||||
if (progress > 8) {
|
||||
int color = 0xFFFFFF;
|
||||
int color = Colors.WHITE;
|
||||
int alpha = progress << 24 & -16777216;
|
||||
|
||||
color |= alpha;
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Loading…
Reference in a new issue