diff options
author | bowser0000 <bowser0000@gmail.com> | 2020-08-08 21:52:21 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2020-08-08 21:52:21 -0400 |
commit | 91aa2e90f5d802bb88b17f6a818e948823888e7b (patch) | |
tree | 4c619853c42abafb0212a8fc38499bda19294541 /me/Danker/utils | |
parent | c4636d1916860d77f9c42c9c49f80cc042e7fd0c (diff) | |
download | SkyblockMod-91aa2e90f5d802bb88b17f6a818e948823888e7b.tar.gz SkyblockMod-91aa2e90f5d802bb88b17f6a818e948823888e7b.tar.bz2 SkyblockMod-91aa2e90f5d802bb88b17f6a818e948823888e7b.zip |
Add alerts for RNGesus dropsv1.6.1
Had so much trouble with centering the alert text... when all I had to do was not divide by the scale...
Diffstat (limited to 'me/Danker/utils')
-rw-r--r-- | me/Danker/utils/Utils.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/me/Danker/utils/Utils.java b/me/Danker/utils/Utils.java index 409e0b6..4749305 100644 --- a/me/Danker/utils/Utils.java +++ b/me/Danker/utils/Utils.java @@ -5,10 +5,13 @@ import java.util.List; import java.util.regex.Matcher; import me.Danker.TheMod; +import me.Danker.handlers.TextRenderer; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.StringUtils; public class Utils { @@ -57,4 +60,29 @@ public class Utils { return matchingPlayers; } + public static void createTitle(String text, int seconds) { + Minecraft.getMinecraft().thePlayer.playSound("random.orb", 1, (float) 0.5); + TheMod.titleTimer = seconds * 20; + TheMod.showTitle = true; + TheMod.titleText = text; + } + + public static void drawTitle(String text) { + Minecraft mc = Minecraft.getMinecraft(); + ScaledResolution scaledResolution = new ScaledResolution(mc); + + int height = scaledResolution.getScaledHeight(); + int width = scaledResolution.getScaledWidth(); + int textLength = mc.fontRendererObj.getStringWidth(text); + + double scale = 4; + if (textLength * scale > (width * 0.9F)) { + scale = (width * 0.9F) / (float) textLength; + } + + int titleX = (int) ((width / 2) - (textLength * scale / 2)); + int titleY = (int) ((height * 0.45) / scale); + new TextRenderer(mc, text, titleX, titleY, scale); + } + } |