diff options
author | Sychic <47618543+Sychic@users.noreply.github.com> | 2020-12-26 16:16:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-26 16:16:25 -0500 |
commit | 3917028d62623f56428784f039af241bf5750a14 (patch) | |
tree | 0cb34d0fa5104990df8bcd4f72816bf252a6c4da /src/main/java/me/Danker/utils | |
parent | 3e4b6728eaee4daae95dfb8c40ed46510e9ea280 (diff) | |
parent | e00e8cc6b29b8c6826459c7d39e40b265640d22d (diff) | |
download | SkyblockMod-3917028d62623f56428784f039af241bf5750a14.tar.gz SkyblockMod-3917028d62623f56428784f039af241bf5750a14.tar.bz2 SkyblockMod-3917028d62623f56428784f039af241bf5750a14.zip |
Merge branch 'development' into development
Diffstat (limited to 'src/main/java/me/Danker/utils')
-rw-r--r-- | src/main/java/me/Danker/utils/Utils.java | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java index e4f7873..abda6a3 100644 --- a/src/main/java/me/Danker/utils/Utils.java +++ b/src/main/java/me/Danker/utils/Utils.java @@ -20,13 +20,14 @@ import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.util.*; import org.lwjgl.opengl.GL11; import java.awt.*; -import java.util.ArrayList; -import java.util.Collection; +import java.util.*; import java.util.List; import java.util.regex.Matcher; @@ -119,7 +120,15 @@ public class Utils { drawHeight += mc.fontRendererObj.FONT_HEIGHT; } } - + + public static boolean isOnHypixel () { + Minecraft mc = Minecraft.getMinecraft(); + if (mc != null && mc.theWorld != null && !mc.isSingleplayer()) { + return mc.getCurrentServerData().serverIP.toLowerCase().contains("hypixel"); + } + return false; + } + public static void checkForSkyblock() { Minecraft mc = Minecraft.getMinecraft(); if (mc != null && mc.theWorld != null && !mc.isSingleplayer()) { @@ -263,7 +272,40 @@ public class Utils { public static String getColouredBoolean(boolean bool) { return bool ? EnumChatFormatting.GREEN + "On" : EnumChatFormatting.RED + "Off"; } - + + //Taken from SkyblockAddons + public static List<String> getItemLore(ItemStack itemStack) { + final int NBT_INTEGER = 3; + final int NBT_STRING = 8; + final int NBT_LIST = 9; + final int NBT_COMPOUND = 10; + + if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("display", NBT_COMPOUND)) { + NBTTagCompound display = itemStack.getTagCompound().getCompoundTag("display"); + + if (display.hasKey("Lore", NBT_LIST)) { + NBTTagList lore = display.getTagList("Lore", NBT_STRING); + + List<String> loreAsList = new ArrayList<>(); + for (int lineNumber = 0; lineNumber < lore.tagCount(); lineNumber++) { + loreAsList.add(lore.getStringTagAt(lineNumber)); + } + + return Collections.unmodifiableList(loreAsList); + } + } + + return Collections.emptyList(); + } + + public static boolean hasRightClickAbility(ItemStack itemStack) { + return Utils.getItemLore(itemStack).stream().anyMatch(line->{ + String stripped = StringUtils.stripControlCodes(line); + return stripped.startsWith("Item Ability:") && stripped.endsWith("RIGHT CLICK"); + }); + } + + public static void draw3DLine(Vec3 pos1, Vec3 pos2, int colourInt, float partialTicks) { Entity render = Minecraft.getMinecraft().getRenderViewEntity(); WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); |