aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/misc/SummoningSoulsName.kt135
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt20
7 files changed, 183 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 55f668e42..abc6b978b 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -85,6 +85,7 @@ public class SkyHanniMod {
registerEvent(new SeaCreatureMessageShortener());
// registerEvent(new GriffinBurrowFinder());
registerEvent(new AshfangFreezeCooldown());
+ registerEvent(new SummoningSoulsName());
Commands.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 2ca4b690d..a98f91a3e 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -29,6 +29,11 @@ public class Misc {
public boolean hideExpBottles = false;
@Expose
+ @ConfigOption(name = "Summon Soul Display", desc = "Shows the name above summoning souls that ready to pick up. §cNot working in Dungeon if Skytils' 'Hide Non-Starred Mobs Nametags' feature is enabled!")
+ @ConfigEditorBoolean
+ public boolean summonSoulDisplay = false;
+
+ @Expose
@ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.")
@ConfigEditorBoolean
public boolean configButtonOnPause = true;
diff --git a/src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt b/src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt
index 9cbabfa2f..bdbda2e50 100644
--- a/src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/diana/GriffinBurrowFinder.kt
@@ -51,7 +51,7 @@ class GriffinBurrowFinder {
fun onWorldRender(event: RenderWorldLastEvent) {
if (lastArrowLine != null) {
var start = lastArrowLine!!.start
- val y = (Minecraft.getMinecraft().thePlayer.position.y - 1).toDouble()
+ val y = (LocationUtils.playerLocation().y - 1)
start = LorenzVec(start.x, y, start.z)
val direction = lastArrowLine!!.direction
@@ -74,7 +74,7 @@ class GriffinBurrowFinder {
val x = packet.xCoordinate
val y = packet.yCoordinate
val z = packet.zCoordinate
- val distance = LorenzVec(x, y, z).distance(Minecraft.getMinecraft().thePlayer.getLorenzVec())
+ val distance = LorenzVec(x, y, z).distance(LocationUtils.playerLocation())
if (distance < 20) {
// LorenzDebug.log("")
// LorenzDebug.log("S2APacketParticles close")
@@ -93,7 +93,7 @@ class GriffinBurrowFinder {
val x = packet.x
val y = packet.y
val z = packet.z
- val distance = LorenzVec(x, y, z).distance(Minecraft.getMinecraft().thePlayer.getLorenzVec())
+ val distance = LorenzVec(x, y, z).distance(LocationUtils.playerLocation())
if (distance < 20) {
val soundName = packet.soundName
val pitch = packet.pitch
@@ -135,7 +135,7 @@ class GriffinBurrowFinder {
}
private fun checkEntities() {
- val playerLocation = Minecraft.getMinecraft().thePlayer.position.toLorenzVec()
+ val playerLocation = LocationUtils.playerLocation()
for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
if (list.contains(entity.uniqueID)) continue
if (entity !is EntityArmorStand) continue
diff --git a/src/main/java/at/hannibal2/skyhanni/misc/SummoningSoulsName.kt b/src/main/java/at/hannibal2/skyhanni/misc/SummoningSoulsName.kt
new file mode 100644
index 000000000..4cb1a90ae
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/misc/SummoningSoulsName.kt
@@ -0,0 +1,135 @@
+package at.hannibal2.skyhanni.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.damageindicator.hasNameTagWith
+import at.hannibal2.skyhanni.test.GriffinJavaUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
+import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.RenderUtils.drawString
+import at.hannibal2.skyhanni.utils.getLorenzVec
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.EntityLiving
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+import java.util.concurrent.atomic.AtomicReference
+
+class SummoningSoulsName {
+
+ var tick = 0
+ val texture =
+ "ewogICJ0aW1lc3RhbXAiIDogMTYwMTQ3OTI2NjczMywKICAicHJvZmlsZUlkIiA6ICJmMzA1ZjA5NDI0NTg0ZjU" +
+ "4YmEyYjY0ZjAyZDcyNDYyYyIsCiAgInByb2ZpbGVOYW1lIiA6ICJqcm9ja2EzMyIsCiAgInNpZ25hdH" +
+ "VyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgI" +
+ "nVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS81YWY0MDM1ZWMwZGMx" +
+ "NjkxNzc4ZDVlOTU4NDAxNzAyMjdlYjllM2UyOTQzYmVhODUzOTI5Y2U5MjNjNTk4OWFkIgogICAgfQogIH0KfQ"
+
+ val souls = mutableMapOf<EntityArmorStand, String>()
+ val mobsLastLocation = mutableMapOf<EntityLiving, LorenzVec>()
+ val mobsName = mutableMapOf<EntityLiving, String>()
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!isEnabled()) return
+
+ tick++
+ //TODO use packets instead of this
+ if (tick % 1 == 0) {
+ check()
+ }
+ }
+
+ private fun check() {
+ val minecraft = Minecraft.getMinecraft()
+ val world = minecraft.theWorld
+ for (entity in world.loadedEntityList) {
+ if (souls.contains(entity)) continue
+
+ if (entity is EntityArmorStand) {
+ if (isSoul(entity)) {
+ val soulLocation = entity.getLorenzVec()
+
+ val map = mutableMapOf<EntityLiving, Double>()
+ for ((mob, loc) in mobsLastLocation) {
+ val distance = loc.distance(soulLocation)
+ map[mob] = distance
+ }
+
+ val nearestMob = GriffinJavaUtils.sortByValueAsc(map).firstNotNullOfOrNull { it.key }
+ if (nearestMob != null) {
+// val mobDistance = nearestMob.getLorenzVec().add(0.0, -1.4375, 0.0)
+// val distance = mobDistance.distance(soulLocation)
+// val diff = mobDistance.add(soulLocation.multiply(-1))
+
+// println(" ")
+// println("mobDistance: $mobDistance")
+// println("soulLocation: $soulLocation")
+// println("diff: $diff")
+// LorenzUtils.chat("distance: $distance")
+ val name = mobsName[nearestMob]!!
+// LorenzUtils.chat("maybe its $name")
+ souls[entity] = name
+ }
+
+ }
+ }
+ }
+
+ for (entity in world.loadedEntityList) {
+
+ if (entity is EntityLiving) {
+ val boo = AtomicReference<String>()
+ if (entity.hasNameTagWith(2, "§c❤", consumer = {
+ if (!it.name.contains("§e0")) {
+ boo.set(it.name)
+ }
+ })) {
+ val name = boo.get()
+ if (name != null) {
+ mobsLastLocation[entity] = entity.getLorenzVec()
+ mobsName[entity] = name
+ }
+ }
+ }
+ }
+
+ souls.keys.removeIf { it !in world.loadedEntityList }
+ //TODO fix overhead!
+// mobs.keys.removeIf { it !in world.loadedEntityList }
+ }
+
+ @SubscribeEvent
+ fun onWorldRender(event: RenderWorldLastEvent) {
+ if (!isEnabled()) return
+
+ val playerLocation = LocationUtils.playerEyeLocation()
+ for ((entity, name) in souls) {
+ val vec = entity.getLorenzVec()
+ if (LocationUtils.canSee(playerLocation, vec.add(0.0, 2.0, 0.0))) {
+ event.drawString(vec.add(0.0, 2.5, 0.0), name, true)
+ }
+ }
+ }
+
+ private fun isSoul(entity: EntityArmorStand): Boolean {
+ for (stack in entity.inventory) {
+ if (stack != null) {
+ val skullTexture = stack.getSkullTexture()
+ if (skullTexture != null) {
+ if (skullTexture == texture) {
+ return true
+ }
+ }
+ }
+ }
+
+ return false
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyblock && SkyHanniMod.feature.misc.summonSoulDisplay
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt
index c8126e05d..164e22755 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/CopyNearbyEntitiesCommand.kt
@@ -2,6 +2,8 @@ package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.config.gui.utils.Utils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
+import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
+import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.toLorenzVec
@@ -21,7 +23,7 @@ class CopyNearbyEntitiesCommand {
}
val minecraft = Minecraft.getMinecraft()
- val start = minecraft.thePlayer.position.toLorenzVec()
+ val start = LocationUtils.playerLocation()
val world = minecraft.theWorld
val resultList = mutableListOf<String>()
@@ -61,6 +63,10 @@ class CopyNearbyEntitiesCommand {
for ((id, stack) in entity.inventory.withIndex()) {
resultList.add("id $id = $stack")
if (stack != null) {
+ val skullTexture = stack.getSkullTexture()
+ if (skullTexture != null) {
+ resultList.add("skullTexture: $skullTexture")
+ }
val cleanName = stack.cleanName()
val type = stack.javaClass.name
resultList.add("cleanName: $cleanName")
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