Skip to content

Commit

Permalink
Merge pull request #703 from f3shqt/master
Browse files Browse the repository at this point in the history
Glacite Overlay (Oops)
  • Loading branch information
kevinthegreat1 authored May 24, 2024
2 parents b6da8de + b659adf commit 813df61
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/de/hysky/skyblocker/SkyblockerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public void onInitializeClient() {
BackpackPreview.init();
ItemCooldowns.init();
TabHud.init();
GlaciteColdOverlay.init();
DwarvenHud.init();
CommissionLabels.init();
CrystalsHud.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Glacite Tunnels
.group(OptionGroup.createBuilder()
.name(Text.translatable("skyblocker.config.mining.glacite"))
.collapsed(false)
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.mining.glacite.coldOverlay"))
.description(OptionDescription.of(Text.translatable("skyblocker.config.mining.glacite.coldOverlay@Tooltip")))
.binding(defaults.mining.glacite.coldOverlay,
() -> config.mining.glacite.coldOverlay,
newValue -> config.mining.glacite.coldOverlay = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.build())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class MiningConfig {
@SerialEntry
public CommissionWaypoints commissionWaypoints = new CommissionWaypoints();

@SerialEntry
public Glacite glacite = new Glacite();

public static class DwarvenMines {
@SerialEntry
public boolean solveFetchur = true;
Expand Down Expand Up @@ -119,6 +122,11 @@ public String toString() {
}
}

public static class Glacite {
@SerialEntry
public boolean coldOverlay = true;
}

public enum DwarvenHudStyle {
SIMPLE, FANCY, CLASSIC;

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.events.HudRenderEvents;
import de.hysky.skyblocker.skyblock.dwarven.GlaciteColdOverlay;
import de.hysky.skyblocker.skyblock.fancybars.FancyStatusBars;
import de.hysky.skyblocker.skyblock.item.HotbarSlotLock;
import de.hysky.skyblocker.skyblock.item.ItemCooldowns;
Expand Down Expand Up @@ -114,6 +115,11 @@ public abstract class InGameHudMixin {
if (Utils.isOnSkyblock() && SkyblockerConfigManager.get().uiAndVisuals.hideStatusEffectOverlay) ci.cancel();
}

@Inject(method = "renderMiscOverlays", at = @At("TAIL"))
private void skyblocker$afterMiscOverlays(CallbackInfo ci, @Local(argsOnly = true) DrawContext context) {
GlaciteColdOverlay.render(context);
}

@ModifyExpressionValue(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttackCooldownProgress(F)F"))
private float skyblocker$modifyAttackIndicatorCooldown(float cooldownProgress) {
if (Utils.isOnSkyblock() && client.player != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package de.hysky.skyblocker.skyblock.dwarven;

import com.mojang.blaze3d.systems.RenderSystem;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.scheduler.Scheduler;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class GlaciteColdOverlay {
private static final Identifier POWDER_SNOW_OUTLINE = new Identifier("textures/misc/powder_snow_outline.png");
private static final Pattern COLD_PATTERN = Pattern.compile("Cold: -(\\d+)❄");
private static int cold = 0;
private static long resetTime = System.currentTimeMillis();

public static void init() {
Scheduler.INSTANCE.scheduleCyclic(GlaciteColdOverlay::update, 20);
ClientReceiveMessageEvents.GAME.register(GlaciteColdOverlay::coldReset);
}

private static void coldReset(Text text, boolean b) {
if (!Utils.isInDwarvenMines() || b) {
return;
}
String message = text.getString();
if (message.equals("The warmth of the campfire reduced your ❄ Cold to 0!")) {
cold = 0;
resetTime = System.currentTimeMillis();
}
}

private static void update() {
if (!Utils.isInDwarvenMines() || System.currentTimeMillis() - resetTime < 3000 || !SkyblockerConfigManager.get().mining.glacite.coldOverlay) {
cold = 0;
return;
}
for (String line : Utils.STRING_SCOREBOARD) {
Matcher coldMatcher = COLD_PATTERN.matcher(line);
if (coldMatcher.matches()) {
String value = coldMatcher.group(1);
cold = Integer.parseInt(value);
return;
}
}
cold = 0;
}

private static void renderOverlay(DrawContext context, Identifier texture, float opacity) {
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
RenderSystem.enableBlend();
context.setShaderColor(1.0f, 1.0f, 1.0f, opacity);
context.drawTexture(texture, 0, 0, -90, 0.0f, 0.0f, context.getScaledWindowWidth(), context.getScaledWindowHeight(), context.getScaledWindowWidth(), context.getScaledWindowHeight());
RenderSystem.disableBlend();
RenderSystem.depthMask(true);
RenderSystem.enableDepthTest();
context.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
}

public static void render(DrawContext context) {
if (Utils.isInDwarvenMines() && SkyblockerConfigManager.get().mining.glacite.coldOverlay) {
renderOverlay(context, POWDER_SNOW_OUTLINE, cold / 100f);
}
}
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@

"skyblocker.config.mining.enableDrillFuel": "Enable Drill Fuel",

"skyblocker.config.mining.glacite": "Glacite Tunnels",
"skyblocker.config.mining.glacite.coldOverlay": "Cold Overlay",
"skyblocker.config.mining.glacite.coldOverlay@Tooltip": "Shows a frosty overlay in the Glacite mines that gets stronger as you get colder.",

"skyblocker.config.misc": "Misc",

"skyblocker.config.misc.richPresence": "Discord RPC",
Expand Down

0 comments on commit 813df61

Please sign in to comment.