aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-10-13 20:41:14 +0200
committerGitHub <noreply@github.com>2024-10-13 20:41:14 +0200
commit6609f21c83093fbb48c6e30fcc3316fc04ae575f (patch)
tree1d91b03de913ef8f8446bd61365644771313c015 /src/main/java
parentc31bef70141a99e3202850a7bba1447e47993ea1 (diff)
downloadskyhanni-6609f21c83093fbb48c6e30fcc3316fc04ae575f.tar.gz
skyhanni-6609f21c83093fbb48c6e30fcc3316fc04ae575f.tar.bz2
skyhanni-6609f21c83093fbb48c6e30fcc3316fc04ae575f.zip
Improvement: Line to goblin (#2717)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/mob/LineToMobHandler.kt44
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt15
5 files changed, 72 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
index f6a5a83ba..e2599e94f 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
@@ -103,6 +103,10 @@ public class MiningConfig {
public boolean highlightYourGoldenGoblin = true;
@Expose
+ @ConfigOption(name = "Line to your Golden Goblin", desc = "Also makes a line to your goblin. §eNeeds the option above to work.")
+ @ConfigEditorBoolean
+ public boolean lineToYourGoldenGoblin = false;
+
@ConfigOption(name = "Precision Mining Helper", desc = "Draws a box over the Precision Mining particles.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/LineToMobHandler.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/LineToMobHandler.kt
new file mode 100644
index 000000000..26313efba
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/mob/LineToMobHandler.kt
@@ -0,0 +1,44 @@
+package at.hannibal2.skyhanni.data.mob
+
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.MobEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.awt.Color
+
+@SkyHanniModule
+object LineToMobHandler {
+
+ data class LineSettings(
+ val color: Color,
+ val width: Int,
+ val depth: Boolean,
+ )
+
+ private val lines = mutableMapOf<Mob, LineSettings>()
+
+ fun register(mob: Mob, color: Color, width: Int, depth: Boolean) = register(mob, LineSettings(color, width, depth))
+
+ fun register(mob: Mob, settings: LineSettings) {
+ lines[mob] = settings
+ }
+
+ @SubscribeEvent
+ fun onMobDeSpawn(event: MobEvent.DeSpawn) {
+ lines.remove(event.mob)
+ }
+
+ @SubscribeEvent
+ fun onLorenzRenderWorld(event: LorenzRenderWorldEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (lines.isEmpty()) return
+ RenderUtils.LineDrawer.draw3D(event.partialTicks) {
+ for ((mob, settings) in lines) {
+ if (!mob.canBeSeen()) continue
+ draw3DLineFromPlayer(mob.centerCords, settings.color, settings.width, settings.depth)
+ }
+ }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt
index 062acc4b3..3d8ec3e46 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt
@@ -8,17 +8,16 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.toSingletonListOrEmpty
import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha
import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
import at.hannibal2.skyhanni.utils.EntityUtils.cleanName
-import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory
import at.hannibal2.skyhanni.utils.EntityUtils.isCorrupted
import at.hannibal2.skyhanni.utils.EntityUtils.isRunic
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LocationUtils.getCenter
import at.hannibal2.skyhanni.utils.LocationUtils.union
import at.hannibal2.skyhanni.utils.MobUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityZombie
-import net.minecraft.entity.player.EntityPlayer
import net.minecraft.util.AxisAlignedBB
import java.awt.Color
import java.util.UUID
@@ -228,6 +227,8 @@ class Mob(
internalHighlight()
}
+ val centerCords get() = boundingBox.getCenter()
+
override fun hashCode() = id.hashCode()
override fun toString(): String = "$name - ${baseEntity.entityId}"
@@ -238,4 +239,6 @@ class Mob(
return id == other.id
}
+
+ fun lineToPlayer(color: Color, lineWidth: Int = 2, depth: Boolean = true) = LineToMobHandler.register(this, color, lineWidth, depth)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt
index 1d8880cde..706af17a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt
@@ -16,11 +16,11 @@ import kotlin.time.Duration.Companion.seconds
@SkyHanniModule
object GoldenGoblinHighlight {
- private val config get() = SkyHanniMod.feature.mining.highlightYourGoldenGoblin
+ private val config get() = SkyHanniMod.feature.mining
private val goblinPattern by RepoPattern.pattern("mining.mob.golden.goblin", "Golden Goblin|Diamond Goblin")
- private fun isEnabled() = LorenzUtils.inMiningIsland() && config
+ private fun isEnabled() = LorenzUtils.inMiningIsland() && config.highlightYourGoldenGoblin
private val timeOut = 10.seconds
@@ -48,10 +48,16 @@ object GoldenGoblinHighlight {
}
private fun handle() {
+ // TODO merge the two time objects into one
if (lastChatMessage.passedSince() > timeOut || lastGoblinSpawn.passedSince() > timeOut) return
lastChatMessage = SimpleTimeMark.farPast()
lastGoblinSpawn = SimpleTimeMark.farPast()
- lastGoblin?.highlight(LorenzColor.GREEN.toColor())
+
+ val goblin = lastGoblin ?: return
+ goblin.highlight(LorenzColor.GREEN.toColor())
+ if (config.lineToYourGoldenGoblin) {
+ goblin.lineToPlayer(LorenzColor.GREEN.toColor())
+ }
lastGoblin = null
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 47bdb3976..224d9269e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -1335,8 +1335,10 @@ object RenderUtils {
}
}
- class LineDrawer @PublishedApi internal constructor(val tessellator: Tessellator) {
+ class LineDrawer @PublishedApi internal constructor(val tessellator: Tessellator, val inverseView: LorenzVec) {
+
val worldRenderer = tessellator.worldRenderer
+
fun drawPath(path: List<LorenzVec>, color: Color, lineWidth: Int, depth: Boolean, bezierPoint: Double = 1.0) {
if (bezierPoint < 0) {
path.zipWithNext().forEach {
@@ -1380,6 +1382,9 @@ object RenderUtils {
}
}
+ fun draw3DLineFromPlayer(lorenzVec: LorenzVec, color: Color, lineWidth: Int, depth: Boolean) =
+ draw3DLine(inverseView.add(y = Minecraft.getMinecraft().thePlayer.eyeHeight.toDouble()), lorenzVec, color, lineWidth, depth)
+
fun drawBezier2(
p1: LorenzVec,
p2: LorenzVec,
@@ -1426,7 +1431,7 @@ object RenderUtils {
companion object {
inline fun draw3D(
partialTicks: Float = 0F,
- crossinline quads: LineDrawer.() -> Unit,
+ crossinline draws: LineDrawer.() -> Unit,
) {
GlStateManager.enableBlend()
@@ -1439,10 +1444,10 @@ object RenderUtils {
val tessellator = Tessellator.getInstance()
GlStateManager.pushMatrix()
- RenderUtils.translate(getViewerPos(partialTicks).negated())
- getViewerPos(partialTicks)
+ val inverseView = getViewerPos(partialTicks)
+ RenderUtils.translate(inverseView.negated())
- quads.invoke(LineDrawer(Tessellator.getInstance()))
+ draws.invoke(LineDrawer(Tessellator.getInstance(), inverseView))
GlStateManager.popMatrix()