aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-23 15:52:37 +0200
committernea <nea@nea.moe>2023-07-23 15:52:46 +0200
commit162ab1f2af513e802f7cf1ccefb1c53d8bf62afd (patch)
treea8c55ce65e91c34cebac4902073ee3985c5c1c32 /src/main
parentc4fc3d5b4783a4f9cdc2079736880af55e26ca65 (diff)
downloadSkyblockHud-Death-Defied-162ab1f2af513e802f7cf1ccefb1c53d8bf62afd.tar.gz
SkyblockHud-Death-Defied-162ab1f2af513e802f7cf1ccefb1c53d8bf62afd.tar.bz2
SkyblockHud-Death-Defied-162ab1f2af513e802f7cf1ccefb1c53d8bf62afd.zip
Add rift health manager
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/location/RiftHandler.java5
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java8
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java22
3 files changed, 26 insertions, 9 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/RiftHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/RiftHandler.java
index dfd225e..5ae1407 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/location/RiftHandler.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/location/RiftHandler.java
@@ -4,10 +4,11 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class RiftHandler {
+ public static boolean isInRift = false;
+
@SubscribeEvent
public void onActionBar(ClientChatReceivedEvent event) {
if (event.type != 2) return;
- // §741m30sф Left §b160/160✎ Mana
+ isInRift = event.message.getUnformattedText().contains("ф Left");
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
index 40f3334..c561fb7 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
@@ -1,12 +1,14 @@
package com.thatgravyboat.skyblockhud.mixins;
import com.thatgravyboat.skyblockhud.SkyblockHud;
+import com.thatgravyboat.skyblockhud.overlay.RPGHud;
import com.thatgravyboat.skyblockhud.tracker.TrackerHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketThreadUtil;
+import net.minecraft.network.play.server.S06PacketUpdateHealth;
import net.minecraft.network.play.server.S2FPacketSetSlot;
import net.minecraft.network.play.server.S3EPacketTeams;
import net.minecraft.scoreboard.ScorePlayerTeam;
@@ -64,4 +66,10 @@ public class MixinNetHandlerPlayClient {
//This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things.
if (scoreplayerteam == null) ci.cancel();
}
+
+ @Inject(method = "handleUpdateHealth(Lnet/minecraft/network/play/server/S06PacketUpdateHealth;)V", at = @At(value = "TAIL"))
+ public void onHealth(S06PacketUpdateHealth packetIn, CallbackInfo ci) {
+ RPGHud.updateHealth(packetIn.getHealth(), (Minecraft.getMinecraft().thePlayer.getMaxHealth()));
+ }
+
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java
index 2a7cac9..d3a2f94 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java
@@ -4,10 +4,9 @@ import com.mojang.realmsclient.gui.ChatFormatting;
import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.core.config.Position;
import com.thatgravyboat.skyblockhud.handlers.HeldItemHandler;
+import com.thatgravyboat.skyblockhud.location.RiftHandler;
import com.thatgravyboat.skyblockhud.textures.Textures;
import com.thatgravyboat.skyblockhud.utils.Utils;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -15,10 +14,13 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
public class RPGHud extends Gui {
private static int mana, maxMana, overflow = 0;
- private static int health, maxHealth = 0;
+ private static float health, maxHealth = 0;
// private static int dominus, maxDominus = 0;
private static int defense = 0;
@@ -31,7 +33,7 @@ public class RPGHud extends Gui {
overflow = current;
}
- public static void updateHealth(int current, int max) {
+ public static void updateHealth(float current, float max) {
health = current;
maxHealth = max;
}
@@ -106,9 +108,15 @@ public class RPGHud extends Gui {
drawTexturedModalRect(rightAligned ? x + 19 : 41 + x, 33 + y, rightAligned ? 196 : 0, 88, Utils.lerp(mc.thePlayer.getAir() / 300f, 0, 60), 4);
}
- Utils.drawStringScaled("" + mc.thePlayer.experienceLevel, font, (rightAligned ? 112 : 14) + x - (font.getStringWidth("" + mc.thePlayer.experienceLevel) / 2f), 34 + y, false, 8453920, 0.75f);
-
- Utils.drawStringScaled(ChatFormatting.RED + " \u2764 " + health + ChatFormatting.AQUA + " \u270E " + mana + ChatFormatting.GREEN + " \u2748 " + defense, font, (rightAligned ? 10 : 42) + x, 8 + y, true, 0xffffff, 0.75f);
+ Utils.drawStringScaled((RiftHandler.isInRift ? "" + (mc.thePlayer.experienceLevel / 60) + ":" + (mc.thePlayer.experienceLevel % 60) : "" + mc.thePlayer.experienceLevel), font, (rightAligned ? 112 : 14) + x - (font.getStringWidth("" + mc.thePlayer.experienceLevel) / 2f), 34 + y, false, 8453920, 0.75f);
+ int doubleHealth = (int) (health * 2);
+ String healthStr;
+ if (doubleHealth % 2 == 0) {
+ healthStr = "" + (doubleHealth / 2);
+ } else {
+ healthStr = "" + (doubleHealth / 2F);
+ }
+ Utils.drawStringScaled(ChatFormatting.RED + " ❤ " + healthStr + ChatFormatting.AQUA + " \u270E " + mana + ChatFormatting.GREEN + " \u2748 " + defense, font, (rightAligned ? 10 : 42) + x, 8 + y, true, 0xffffff, 0.75f);
GlStateManager.color(255, 255, 255);
GlStateManager.disableBlend();