aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/utils
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2020-08-08 23:07:53 -0400
committerbowser0000 <bowser0000@gmail.com>2020-08-08 23:07:53 -0400
commitfddf14fd04c50e02704c946d8893a3604f1abb11 (patch)
treea0dbf80dc346a460c865e97e79cd4ce15af361bf /src/main/java/me/Danker/utils
parent91aa2e90f5d802bb88b17f6a818e948823888e7b (diff)
downloadSkyblockMod-fddf14fd04c50e02704c946d8893a3604f1abb11.tar.gz
SkyblockMod-fddf14fd04c50e02704c946d8893a3604f1abb11.tar.bz2
SkyblockMod-fddf14fd04c50e02704c946d8893a3604f1abb11.zip
v1.6.1
Add all build files
Diffstat (limited to 'src/main/java/me/Danker/utils')
-rw-r--r--src/main/java/me/Danker/utils/Utils.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java
new file mode 100644
index 0000000..4749305
--- /dev/null
+++ b/src/main/java/me/Danker/utils/Utils.java
@@ -0,0 +1,88 @@
+package me.Danker.utils;
+
+import java.util.ArrayList;
+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 {
+
+ public static int getItems(String item) {
+ Minecraft mc = Minecraft.getMinecraft();
+ EntityPlayer player = mc.thePlayer;
+
+ double x = player.posX;
+ double y = player.posY;
+ double z = player.posZ;
+ AxisAlignedBB scan = new AxisAlignedBB(x - 6, y - 6, z - 6, x + 6, y + 6, z + 6);
+ List<EntityItem> items = mc.theWorld.getEntitiesWithinAABB(EntityItem.class, scan);
+
+ for (EntityItem i : items) {
+ String itemName = StringUtils.stripControlCodes(i.getEntityItem().getDisplayName());
+ if (itemName.equals(item)) return i.getEntityItem().stackSize;
+ }
+ // No items found
+ return 0;
+ }
+
+ public static String returnGoldenEnchants(String line) {
+ Matcher matcher = TheMod.pattern.matcher(line);
+ StringBuffer out = new StringBuffer();
+
+ while (matcher.find()) {
+ matcher.appendReplacement(out, TheMod.t6Enchants.get(matcher.group(1)));
+ }
+ matcher.appendTail(out);
+
+ return out.toString();
+ }
+
+ public static List<String> getMatchingPlayers(String arg) {
+ List<String> matchingPlayers = new ArrayList<>();
+ List<EntityPlayer> players = Minecraft.getMinecraft().theWorld.playerEntities;
+
+ for (EntityPlayer player : players) {
+ String playerName = player.getName();
+ if (playerName.toLowerCase().startsWith(arg.toLowerCase())) {
+ matchingPlayers.add(playerName);
+ }
+ }
+
+ 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);
+ }
+
+}