aboutsummaryrefslogtreecommitdiff
path: root/me/Danker/utils/Utils.java
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2020-08-03 17:29:44 -0400
committerbowser0000 <bowser0000@gmail.com>2020-08-03 17:29:44 -0400
commit92b0a7959090b56ab313f77143ffd07a1483ea71 (patch)
treeb21d11bba974978d3ab03c18120c4d17c794da93 /me/Danker/utils/Utils.java
parent0243a46401f7654be2b61457880681fb027271bf (diff)
downloadSkyblockMod-92b0a7959090b56ab313f77143ffd07a1483ea71.tar.gz
SkyblockMod-92b0a7959090b56ab313f77143ffd07a1483ea71.tar.bz2
SkyblockMod-92b0a7959090b56ab313f77143ffd07a1483ea71.zip
Add session option for every tracker
Session tracker counts loot from current Minecraft session. CommandUtils has been renamed to Utils.
Diffstat (limited to 'me/Danker/utils/Utils.java')
-rw-r--r--me/Danker/utils/Utils.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/me/Danker/utils/Utils.java b/me/Danker/utils/Utils.java
new file mode 100644
index 0000000..409e0b6
--- /dev/null
+++ b/me/Danker/utils/Utils.java
@@ -0,0 +1,60 @@
+package me.Danker.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+
+import me.Danker.TheMod;
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.AxisAlignedBB;
+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;
+ }
+
+}