aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-27 15:01:43 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-27 15:01:43 +0200
commit63a44abbdc1f245d81d873744c3de1a02e4e5037 (patch)
tree298f8ec34ef1d8f6ca45b81ae59b0a454ad49246
parent3a950dcbc451697ee4ef3eaa4b1df6195b865786 (diff)
downloadskyhanni-63a44abbdc1f245d81d873744c3de1a02e4e5037.tar.gz
skyhanni-63a44abbdc1f245d81d873744c3de1a02e4e5037.tar.bz2
skyhanni-63a44abbdc1f245d81d873744c3de1a02e4e5037.zip
Replacing 'Piggy' with 'Purse' in the Scoreboard.
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinGuiIngame.java10
3 files changed, 36 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 23a9824a9..b9a79ce0d 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -303,6 +303,11 @@ public class Misc {
public boolean hideScoreboardNumbers = false;
@Expose
+ @ConfigOption(name = "Hide Piggy", desc = "Replacing 'Piggy' with 'Purse' in the Scoreboard.")
+ @ConfigEditorBoolean
+ public boolean hidePiggyScoreboard = true;
+
+ @Expose
@ConfigOption(name = "Explosions Hider", desc = "Hide explosions.")
@ConfigEditorBoolean
public boolean hideExplosions = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt
new file mode 100644
index 000000000..424c3659f
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt
@@ -0,0 +1,29 @@
+package at.hannibal2.skyhanni.mixins.hooks
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import net.minecraft.client.gui.FontRenderer
+
+private val piggyPattern = "Piggy: (?<coins>.*)".toPattern()
+
+fun drawString(
+ instance: FontRenderer,
+ text: String,
+ x: Int,
+ y: Int,
+ color: Int,
+): Int {
+ if (SkyHanniMod.feature.misc.hideScoreboardNumbers) {
+ if (text.startsWith("§c") && text.length <= 4) {
+ return 0
+ }
+ }
+ if (SkyHanniMod.feature.misc.hidePiggyScoreboard) {
+ val matcher = piggyPattern.matcher(text)
+ if (matcher.matches()) {
+ val coins = matcher.group("coins")
+ return instance.drawString("Purse: $coins", x, y, color)
+ }
+ }
+
+ return instance.drawString(text, x, y, color)
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinGuiIngame.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinGuiIngame.java
index 6a40eb2cf..6dece8c10 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinGuiIngame.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinGuiIngame.java
@@ -1,6 +1,6 @@
package at.hannibal2.skyhanni.mixins.transformers;
-import at.hannibal2.skyhanni.SkyHanniMod;
+import at.hannibal2.skyhanni.mixins.hooks.GuiIngameHookKt;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiIngame;
import org.spongepowered.asm.mixin.Mixin;
@@ -12,12 +12,6 @@ public class MixinGuiIngame {
@Redirect(method = "renderScoreboard", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawString(Ljava/lang/String;III)I"))
private int renderItemOverlayPost(FontRenderer instance, String text, int x, int y, int color) {
- if (SkyHanniMod.feature.misc.hideScoreboardNumbers) {
- if (text.startsWith("§c") && text.length() <= 4) {
- return 0;
- }
- }
-
- return instance.drawString(text, x, y, color);
+ return GuiIngameHookKt.drawString(instance, text, x, y, color);
}
}