Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.uiAndVisuals.bars.enableBars = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.uiAndVisuals.bars.enableVanillaStyleManaBar"))
.binding(defaults.uiAndVisuals.bars.enableVanillaStyleManaBar,
() -> config.uiAndVisuals.bars.enableVanillaStyleManaBar,
newValue -> config.uiAndVisuals.bars.enableVanillaStyleManaBar = newValue)
.controller(ConfigUtils.createBooleanController())
.build())
.option(ButtonOption.createBuilder()
.name(Text.translatable("skyblocker.config.uiAndVisuals.bars.openScreen"))
.prompt(Text.translatable("text.skyblocker.open"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ public static class FancyAuctionHouse {
public static class Bars {
public boolean enableBars = true;

public boolean enableVanillaStyleManaBar = true;

public IntelligenceDisplay intelligenceDisplay = IntelligenceDisplay.ORIGINAL;

// Kept in for backwards compatibility, remove if needed
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package de.hysky.skyblocker.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars;
import de.hysky.skyblocker.skyblock.fancybars.VanillaStyleManaBar;
import de.hysky.skyblocker.skyblock.item.HotbarSlotLock;
import de.hysky.skyblocker.skyblock.item.ItemCooldowns;
import de.hysky.skyblocker.skyblock.item.ItemProtection;
Expand Down Expand Up @@ -56,9 +58,14 @@ public abstract class InGameHudMixin {
@Unique
private static final Pattern DICER_TITLE_BLACKLIST = Pattern.compile(".+? DROP!");

@Unique
final VanillaStyleManaBar vanillaStyleManaBar = new VanillaStyleManaBar();

@Shadow
@Final
private MinecraftClient client;
@Shadow
private int ticks;

@Unique
private boolean isQuiverSlot = false;
Expand Down Expand Up @@ -201,4 +208,23 @@ private static boolean shouldShowExperienceBar() {
private boolean skyblocker$shouldRenderHud(PlayerListHud playerListHud, DrawContext context, int scaledWindowWidth, Scoreboard scoreboard, ScoreboardObjective objective) {
return !Utils.isOnSkyblock() || !SkyblockerConfigManager.get().uiAndVisuals.tabHud.tabHudEnabled || TabHud.shouldRenderVanilla() || MinecraftClient.getInstance().currentScreen instanceof WidgetsConfigurationScreen;
}

@Inject(method = "renderFood", at = @At("HEAD"), cancellable = true)
private void skyblocker$renderManaOverFood(DrawContext context, PlayerEntity player, int top, int right, CallbackInfo ci) {
if (Utils.isOnSkyblock() && vanillaStyleManaBar.render(context, top, right, ticks)) ci.cancel();
}

@Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true)
private void skyblocker$renderManaOverMouthHealth(DrawContext context, CallbackInfo ci) {
// Values copied from InGameHud.renderMountHealth
int right = context.getScaledWindowWidth() / 2 + 91;
int top = context.getScaledWindowHeight() - 39;

if (Utils.isOnSkyblock() && vanillaStyleManaBar.render(context, top, right, ticks)) ci.cancel();
}

@ModifyReturnValue(method = "getAirBubbleY", at = @At("RETURN"))
private int skyblocker$moveBubblesUp(int original) {
return original - 10;
}
}
20 changes: 11 additions & 9 deletions src/main/java/de/hysky/skyblocker/skyblock/StatusBarTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ private static boolean allowOverlayMessage(Text text, boolean overlay) {
}

private static Text onOverlayMessage(Text text, boolean overlay) {
if (!overlay || !Utils.isOnSkyblock() || Utils.isInTheRift()) {
if (!overlay || !Utils.isOnSkyblock()) {
return text;
}
if (!SkyblockerConfigManager.get().uiAndVisuals.bars.enableBars) {
if (SkyblockerConfigManager.get().uiAndVisuals.bars.enableBars && !Utils.isInTheRift()) {
return Text.of(update(text.getString(), SkyblockerConfigManager.get().chat.hideMana));
} else {
//still update values for other parts of the mod to use
update(text.getString(), SkyblockerConfigManager.get().chat.hideMana);
return text;
}
return Text.of(update(text.getString(), SkyblockerConfigManager.get().chat.hideMana));
}

public static String update(String actionBar, boolean filterManaUse) {
Expand All @@ -131,13 +132,14 @@ public static String update(String actionBar, boolean filterManaUse) {
// Match health and don't add it to the string builder
// Append healing to the string builder if there is any healing
Matcher matcher = STATUS_HEALTH.matcher(actionBar);
if (!matcher.find()) return actionBar;
updateHealth(matcher);
if (matcher.group("healing") != null) {
sb.append("§c❤");
if (matcher.find()) {
updateHealth(matcher);
if (matcher.group("healing") != null) {
sb.append("§c❤");
}
if (!FancyStatusBars.isHealthFancyBarEnabled()) matcher.appendReplacement(sb, "$0");
else matcher.appendReplacement(sb, "$3");
}
if (!FancyStatusBars.isHealthFancyBarEnabled()) matcher.appendReplacement(sb, "$0");
else matcher.appendReplacement(sb, "$3");

// Match defense or mana use and don't add it to the string builder
if (matcher.usePattern(DEFENSE_STATUS).find()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package de.hysky.skyblocker.skyblock.fancybars;

import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.StatusBarTracker;
import net.minecraft.client.gl.RenderPipelines;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.Identifier;

public class VanillaStyleManaBar {
private int lastManaValue;
private int manaValueBlinkStart;

private int lastOverflowValue;
private int overflowValueBlinkStart;

private int blinkEndTick;

private static final Identifier CONTAINER_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/container");
private static final Identifier MANA_FULL_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/mana_full");
private static final Identifier MANA_HALF_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/mana_half");
private static final Identifier OVERFLOW_FULL_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/overflow_full");
private static final Identifier OVERFLOW_HALF_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/overflow_half");
private static final Identifier OVERFLOW_DARK_FULL_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/overflow_dark_full");
private static final Identifier OVERFLOW_DARK_HALF_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/overflow_dark_half");
private static final Identifier CONTAINER_BLINK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/container_blink");
private static final Identifier MANA_FULL_BLINK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/mana_full_blink");
private static final Identifier MANA_HALF_BLINK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/mana_half_blink");
private static final Identifier OVERFLOW_FULL_BLINK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/overflow_full_blink");
private static final Identifier OVERFLOW_HALF_BLINK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/overflow_half_blink");
private static final Identifier OVERFLOW_DARK_FULL_BLINK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/overflow_dark_full_blink");
private static final Identifier OVERFLOW_DARK_HALF_BLINK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "bars/vanilla_mana/overflow_dark_half_blink");


enum NotchType {
CONTAINER,
MANA,
OVERFLOW,
OVERFLOW_DARK
}

private void drawNotch(DrawContext context, int top, int right, int column, int row, NotchType notchtype, boolean isHalf, boolean isBlinking) {
int right_offset = right - column * 8 - 9;

Identifier texture = switch (notchtype) {
case CONTAINER -> isBlinking ? CONTAINER_BLINK_TEXTURE : CONTAINER_TEXTURE;
case MANA -> !isHalf ? (isBlinking ? MANA_FULL_BLINK_TEXTURE : MANA_FULL_TEXTURE) : (isBlinking ? MANA_HALF_BLINK_TEXTURE : MANA_HALF_TEXTURE);
case OVERFLOW -> !isHalf ? (isBlinking ? OVERFLOW_FULL_BLINK_TEXTURE : OVERFLOW_FULL_TEXTURE) : (isBlinking ? OVERFLOW_HALF_BLINK_TEXTURE : OVERFLOW_HALF_TEXTURE);
case OVERFLOW_DARK -> !isHalf ? (isBlinking ? OVERFLOW_DARK_FULL_BLINK_TEXTURE : OVERFLOW_DARK_FULL_TEXTURE) : (isBlinking ? OVERFLOW_DARK_HALF_BLINK_TEXTURE : OVERFLOW_DARK_HALF_TEXTURE);
};

context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, texture, right_offset, top - row * 10, 9, 9);
}

public boolean render(DrawContext context, int top, int right, int ticks) {
if (!SkyblockerConfigManager.get().uiAndVisuals.bars.enableVanillaStyleManaBar) return false;
StatusBarTracker.Resource mana = StatusBarTracker.getMana();

// Detect loss of mana to start blinking
if (lastManaValue + lastOverflowValue > mana.value() + mana.overflow() && mana.value() != mana.max()) {
boolean justStartedBlinking = blinkEndTick <= ticks;
if (justStartedBlinking) {
manaValueBlinkStart = lastManaValue;
overflowValueBlinkStart = lastOverflowValue;
}
// If already blinking, keep blinkEndTick%6 the same to maintain current blink animation frame
if (blinkEndTick >= ticks) {
blinkEndTick = (ticks + 20) / 6 * 6 + blinkEndTick % 6;
} else {
blinkEndTick = ticks + 20;
}
}
boolean blinking = blinkEndTick > ticks && (blinkEndTick - ticks) / 3 % 2 == 1;
if (blinkEndTick <= ticks) {
manaValueBlinkStart = 0;
overflowValueBlinkStart = 0;
}

lastManaValue = mana.value();
lastOverflowValue = mana.overflow();

// Notches are each of the mana icons, 20 for 2 bars
int MANA_NOTCH_COUNT = 20;
int manaHalfNotches = mana.value() * MANA_NOTCH_COUNT * 2 / mana.max();
int manaNotches = (int) Math.ceil(manaHalfNotches / 2.0);
int manaBlinkHalfNotches = manaValueBlinkStart * MANA_NOTCH_COUNT * 2 / mana.max();
int manaBlinkNotches = (int) Math.ceil(manaBlinkHalfNotches / 2.0);
int overflowHalfNotches = mana.overflow() * MANA_NOTCH_COUNT * 2 / mana.max();
int overflowNotches = (int) Math.ceil(overflowHalfNotches / 2.0);
int overflowBlinkHalfNotches = overflowValueBlinkStart * MANA_NOTCH_COUNT * 2 / mana.max();
int overflowBlinkNotches = (int) Math.ceil(overflowBlinkHalfNotches / 2.0);

for (int i = 0; i < MANA_NOTCH_COUNT; i++) {
int row = (i / 10);
int column = i % 10;

boolean manaNotch = i < manaNotches;
boolean manaNotchIsHalf = manaNotch && manaNotches - 1 == i && manaHalfNotches % 2 == 1;
boolean manaBlinkNotch = i < manaBlinkNotches;
boolean manaBlinkNotchIsHalf = manaBlinkNotch && manaBlinkNotches - 1 == i && manaBlinkHalfNotches % 2 == 1;
boolean overflowNotch = i < overflowNotches;
boolean overflowNotchIsHalf = overflowNotch && overflowNotches - 1 == i && overflowHalfNotches % 2 == 1;
boolean overflowBlinkNotch = i < overflowBlinkNotches;
boolean overflowBlinkNotchIsHalf = overflowBlinkNotch && overflowBlinkNotches - 1 == i && overflowBlinkHalfNotches % 2 == 1;

drawNotch(context, top, right, column, row, NotchType.CONTAINER, false, blinking);
if (manaNotches > 0) { // There is normal mana left, display normal mana
if (overflowNotch) drawNotch(context, top, right, column, row, NotchType.OVERFLOW_DARK, overflowNotchIsHalf, blinking);
if (manaBlinkNotch && blinking) drawNotch(context, top, right, column, row, NotchType.MANA, manaBlinkNotchIsHalf, true);
if (manaNotch) drawNotch(context, top, right, column, row, NotchType.MANA, manaNotchIsHalf, false);
} else { // There is no normal mana left, display overflow mana
if (manaBlinkNotch && blinking) drawNotch(context, top, right, column, row, NotchType.MANA, manaBlinkNotchIsHalf, true);
if (overflowBlinkNotch && blinking) drawNotch(context, top, right, column, row, NotchType.OVERFLOW, overflowBlinkNotchIsHalf, true);
if (overflowNotch) drawNotch(context, top, right, column, row, NotchType.OVERFLOW, overflowNotchIsHalf, false);
}
}

return true;
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@

"skyblocker.config.uiAndVisuals.bars": "Health, Mana, Defense, Speed & XP Bars",
"skyblocker.config.uiAndVisuals.bars.enableBars": "Enable Bars",
"skyblocker.config.uiAndVisuals.bars.enableVanillaStyleManaBar": "Enable Vanilla Style Mana Bar",
"skyblocker.config.uiAndVisuals.bars.intelligenceDisplay": "Intelligence Display",
"skyblocker.config.uiAndVisuals.bars.intelligenceDisplay.ORIGINAL": "Original",
"skyblocker.config.uiAndVisuals.bars.intelligenceDisplay.ACCURATE": "Accurate",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.