aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt20
2 files changed, 31 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index a4482247f..b9b11479f 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -6,7 +6,9 @@ import com.google.gson.GsonBuilder
import com.google.gson.JsonObject
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraft.init.Items
import net.minecraft.item.ItemStack
+import net.minecraftforge.common.util.Constants
import java.util.*
object ItemUtils {
@@ -87,7 +89,6 @@ object ItemUtils {
}
}
}
-
return list
}
@@ -181,4 +182,13 @@ object ItemUtils {
return internalName
}
+
+ fun ItemStack.getSkullTexture(): String? {
+ if (item != Items.skull) return null
+ if (tagCompound == null) return null
+ val nbt = tagCompound
+ if (!nbt.hasKey("SkullOwner")) return null
+ return nbt.getCompoundTag("SkullOwner").getCompoundTag("Properties")
+ .getTagList("textures", Constants.NBT.TAG_COMPOUND).getCompoundTagAt(0).getString("Value")
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
new file mode 100644
index 000000000..eee60ea02
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
@@ -0,0 +1,20 @@
+package at.hannibal2.skyhanni.utils
+
+import net.minecraft.client.Minecraft
+
+object LocationUtils {
+
+ fun canSee(a: LorenzVec, b: LorenzVec): Boolean {
+ return Minecraft.getMinecraft().theWorld.rayTraceBlocks(a.toVec3(), b.toVec3()) == null
+ }
+
+ fun playerLocation(): LorenzVec {
+ return Minecraft.getMinecraft().thePlayer.getLorenzVec()
+ }
+
+ fun playerEyeLocation(): LorenzVec {
+ val player = Minecraft.getMinecraft().thePlayer
+ val vec = player.getLorenzVec()
+ return vec.add(0.0, 0.0 + player.getEyeHeight(), 0.0)
+ }
+} \ No newline at end of file