Skip to content

Commit

Permalink
Backend: LorenzVec up/down and drawLineToEye (#2056)
Browse files Browse the repository at this point in the history
Co-authored-by: ItsEmpa <itsempa@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 11, 2024
1 parent 8c54be9 commit 9a2286a
Show file tree
Hide file tree
Showing 41 changed files with 180 additions and 185 deletions.
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object MobDebug {
val map = filter { it.canBeSeen() && it.isNotInvisible() }
.map { it.boundingBox.getTopCenter() to it.name }
for ((location, text) in map) {
event.drawString(location.add(y = 0.5), "§5$text", seeThroughBlocks = true)
event.drawString(location.up(0.5), "§5$text", seeThroughBlocks = true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.LorenzUtils.ignoreDerpy
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.RenderUtils.drawLineToEye
import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.EntityLivingBase
Expand Down Expand Up @@ -115,12 +114,11 @@ object MobHighlight {

if (arachne.distanceToPlayer() > 10) return

event.draw3DLine(
event.exactPlayerEyeLocation(),
arachne.getLorenzVec().add(y = 1),
event.drawLineToEye(
arachne.getLorenzVec().up(),
LorenzColor.RED.toColor(),
config.lineToArachneWidth,
true
true,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object CosmeticFollowingLine {
}

private fun updateClose(event: LorenzRenderWorldEvent) {
val playerLocation = event.exactLocation(Minecraft.getMinecraft().thePlayer).add(y = 0.3)
val playerLocation = event.exactLocation(Minecraft.getMinecraft().thePlayer).up(0.3)

latestLocations = latestLocations.editCopy {
val locationSpot = LocationSpot(SimpleTimeMark.now(), Minecraft.getMinecraft().thePlayer.onGround)
Expand Down Expand Up @@ -113,7 +113,7 @@ object CosmeticFollowingLine {
}

if (event.isMod(2)) {
val playerLocation = LocationUtils.playerLocation().add(y = 0.3)
val playerLocation = LocationUtils.playerLocation().up(0.3)

locations.keys.lastOrNull()?.let {
if (it.distance(playerLocation) < 0.1) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object DungeonHighlightClickedBlocks {
blocks.forEach { (position, block) ->
event.drawColor(position, block.color)
if (config.showText) {
event.drawString(position.add(0.5, 0.5, 0.5), block.displayText, true)
event.drawString(position.blockCenter(), block.displayText, true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawLineToEye
import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
import net.minecraft.block.BlockStainedGlass
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
Expand Down Expand Up @@ -134,17 +133,16 @@ object DungeonLividFinder {
if (!config.enabled) return

val livid = getLividAlive() ?: return
val location = livid.getLorenzVec().add(-0.5, 0.0, -0.5)

val lorenzColor = color ?: return

event.drawDynamicText(location, lorenzColor.getChatColor() + "Livid", 1.5)
val location = event.exactLocation(livid)

if (location.distanceSqToPlayer() < 50) return

event.drawDynamicText(location, lorenzColor.getChatColor() + "Livid", 1.5)

val color = lorenzColor.toColor()
event.draw3DLine(event.exactPlayerEyeLocation(), location.add(0.5, 0.0, 0.5), color, 3, true)
event.drawWaypointFilled(location, color, beacon = false, seeThroughBlocks = true)
event.drawLineToEye(location, color, 3, true)
event.drawWaypointFilled(location.add(-0.5, 0.0, -0.5), color, beacon = false, seeThroughBlocks = true)
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.RenderUtils.drawLineToEye
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.TimeUtils.format
import at.hannibal2.skyhanni.utils.toLorenzVec
Expand Down Expand Up @@ -281,42 +280,40 @@ object GriffinBurrowHelper {
if (distance > 10) {
// TODO use round(1)
val formattedDistance = distance.toInt().addSeparators()
event.drawDynamicText(location.add(y = 1), "§d§lInquisitor §e${formattedDistance}m", 1.7)
event.drawDynamicText(location.up(), "§d§lInquisitor §e${formattedDistance}m", 1.7)
} else {
event.drawDynamicText(location.add(y = 1), "§d§lInquisitor", 1.7)
event.drawDynamicText(location.up(), "§d§lInquisitor", 1.7)
}
if (distance < 5) {
InquisitorWaypointShare.maybeRemove(inquis)
}
event.drawDynamicText(location.add(y = 1), "§eFrom §b${inquis.displayName}", 1.6, yOff = 9f)
event.drawDynamicText(location.up(), "§eFrom §b${inquis.displayName}", 1.6, yOff = 9f)

if (config.inquisitorSharing.showDespawnTime) {
val spawnTime = inquis.spawnTime
val format = (75.seconds - spawnTime.passedSince()).format()
event.drawDynamicText(location.add(y = 1), "§eDespawns in §b$format", 1.6, yOff = 18f)
event.drawDynamicText(location.up(), "§eDespawns in §b$format", 1.6, yOff = 18f)
}
}
}

val currentWarp = BurrowWarpHelper.currentWarp
if (config.lineToNext) {
val player = event.exactPlayerEyeLocation()

var color: LorenzColor?
val renderLocation = if (currentWarp != null) {
color = LorenzColor.AQUA
currentWarp.location
} else {
color = if (shouldFocusOnInquis) LorenzColor.LIGHT_PURPLE else LorenzColor.WHITE
targetLocation?.add(0.5, 0.5, 0.5) ?: return
targetLocation?.blockCenter() ?: return
}

val lineWidth = if (targetLocation in particleBurrows) {
color = particleBurrows[targetLocation]!!.color
3
} else 2
if (currentWarp == null) {
event.draw3DLine(player, renderLocation, color.toColor(), lineWidth, false)
event.drawLineToEye(renderLocation, color.toColor(), lineWidth, false)
}
}

Expand All @@ -330,7 +327,7 @@ object GriffinBurrowHelper {
val distance = location.distance(playerLocation)
val burrowType = burrow.value
event.drawColor(location, burrowType.color, distance > 10)
event.drawDynamicText(location.add(y = 1), burrowType.text, 1.5)
event.drawDynamicText(location.up(), burrowType.text, 1.5)
}
}

Expand All @@ -340,10 +337,10 @@ object GriffinBurrowHelper {
val distance = guessLocation.distance(playerLocation)
event.drawColor(guessLocation, LorenzColor.WHITE, distance > 10)
val color = if (currentWarp != null && targetLocation == guessLocation) "§b" else "§f"
event.drawDynamicText(guessLocation.add(y = 1), "${color}Guess", 1.5)
event.drawDynamicText(guessLocation.up(), "${color}Guess", 1.5)
if (distance > 5) {
val formattedDistance = distance.toInt().addSeparators()
event.drawDynamicText(guessLocation.add(y = 1), "§e${formattedDistance}m", 1.7, yOff = 10f)
event.drawDynamicText(guessLocation.up(), "§e${formattedDistance}m", 1.7, yOff = 10f)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ object HoppityEggLocations {
val nameColorCode = (if (name != null) LorenzColor.GREEN else LorenzColor.RED).getChatColor()

event.drawColor(location, color, false, 0.5f)
event.drawDynamicText(location.add(y = 0.5), "$nameColorCode$name", 1.2)
event.drawDynamicText(location.up(0.5), "$nameColorCode$name", 1.2)
if (location.distanceSqToPlayer() < 100) {
event.drawDynamicText(location.add(y = 0.5), location.toCleanString(), 1.0, yOff = 12f)
event.drawDynamicText(location.up(0.5), location.toCleanString(), 1.0, yOff = 12f)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RecalculatingValue
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.drawColor
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawLineToEye
import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.SimpleTimeMark
Expand Down Expand Up @@ -120,11 +120,10 @@ object HoppityEggLocator {
}

private fun LorenzRenderWorldEvent.drawGuessLocations() {
val eyeLocation = exactPlayerEyeLocation()
for ((index, eggLocation) in possibleEggLocations.withIndex()) {
drawEggWaypoint(eggLocation, "§aGuess #${index + 1}")
if (config.showLine) {
draw3DLine(eyeLocation, eggLocation.add(0.5, 0.5, 0.5), LorenzColor.GREEN.toColor(), 2, false)
drawLineToEye(eggLocation.blockCenter(), LorenzColor.GREEN.toColor(), 2, false)
}
}
}
Expand All @@ -136,7 +135,7 @@ object HoppityEggLocator {
if (dist < 10 && HoppityEggLocations.hasCollectedEgg(eggLocation)) {
val alpha = ((10 - dist) / 10).coerceAtMost(0.5).toFloat()
drawColor(eggLocation, LorenzColor.RED, false, alpha)
drawDynamicText(eggLocation.add(y = 1), "§cDuplicate Location!", 1.5)
drawDynamicText(eggLocation.up(), "§cDuplicate Location!", 1.5)
}
}
}
Expand All @@ -152,10 +151,10 @@ object HoppityEggLocator {
config.waypointColor.toChromaColor(),
seeThroughBlocks = true,
)
drawDynamicText(it.add(y = 1), "§aGuess", 1.5)
drawDynamicText(it.up(), "§aGuess", 1.5)
}
if (!drawLocations && config.showLine) {
draw3DLine(eyeLocation, it.add(0.5, 0.5, 0.5), LorenzColor.GREEN.toColor(), 2, false)
drawLineToEye(it.blockCenter(), LorenzColor.GREEN.toColor(), 2, false)
}
}
}
Expand All @@ -170,7 +169,7 @@ object HoppityEggLocator {
} else {
drawColor(location, LorenzColor.RED.toColor(), false, 0.5f)
}
drawDynamicText(location.add(y = 1), possibleDuplicateLabel, 1.5)
drawDynamicText(location.up(), possibleDuplicateLabel, 1.5)
}

private fun shouldShowAllEggs() = config.showAllWaypoints && !locatorInHotbar && HoppityEggType.eggsRemaining()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object ShowFishingItemName {
if (!isEnabled()) return

for ((item, text) in itemsOnGround) {
val location = event.exactLocation(item).add(y = 0.8)
val location = event.exactLocation(item).up(0.8)
event.drawString(location, text)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
Expand Down Expand Up @@ -47,18 +46,17 @@ object ThunderSparksHighlight {
val special = config.color
val color = Color(SpecialColor.specialToChromaRGB(special), true)

val playerLocation = LocationUtils.playerLocation()
for (spark in sparks) {
if (spark.isDead) continue
val sparkLocation = spark.getLorenzVec()
val block = sparkLocation.getBlockAt()
val seeThroughBlocks =
sparkLocation.distanceToPlayer() < 6 && (block == Blocks.flowing_lava || block == Blocks.lava)
event.drawWaypointFilled(
sparkLocation.add(-0.5, 0.0, -0.5), color, extraSize = -0.25, seeThroughBlocks = seeThroughBlocks
sparkLocation.add(-0.5, 0.0, -0.5), color, extraSize = -0.25, seeThroughBlocks = seeThroughBlocks,
)
if (sparkLocation.distance(playerLocation) < 10) {
event.drawString(sparkLocation.add(y = 1.5), "Thunder Spark", seeThroughBlocks = seeThroughBlocks)
if (sparkLocation.distanceToPlayer() < 10) {
event.drawString(sparkLocation.up(1.5), "Thunder Spark", seeThroughBlocks = seeThroughBlocks)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ object TotemOfCorruption {
// The center of the totem is the upper part of the armor stand
when (config.outlineType) {
OutlineType.FILLED -> {
event.drawSphereInWorld(color, totem.location.add(y = 1), 16f)
event.drawSphereInWorld(color, totem.location.up(), 16f)
}

OutlineType.WIREFRAME -> {
event.drawSphereWireframeInWorld(color, totem.location.add(y = 1), 16f)
event.drawSphereWireframeInWorld(color, totem.location.up(), 16f)
}

else -> return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand Down Expand Up @@ -64,7 +63,7 @@ object GardenStartLocation {
ChatUtils.chat("Auto updated your Crop Start Location for ${crop.cropName}")
}

lastFarmedLocations[crop] = LorenzVec.getBlockBelowPlayer().add(0.0, 1.0, 0.0)
lastFarmedLocations[crop] = LocationUtils.playerLocation().roundLocationToBlock()
shouldShowLastFarmedWaypoint = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayerIgnoreY
import at.hannibal2.skyhanni.utils.LocationUtils.playerLocation
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawLineToEye
import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.client.Minecraft
import net.minecraft.network.play.server.S0EPacketSpawnObject
Expand Down Expand Up @@ -145,12 +144,7 @@ object PestParticleWaypoint {

event.drawWaypointFilled(waypoint, color, beacon = true)
event.drawDynamicText(waypoint, text, 1.3)
if (config.drawLine) event.draw3DLine(
event.exactPlayerEyeLocation(),
waypoint,
color,
3,
false,
if (config.drawLine) event.drawLineToEye(waypoint, color, 3, false,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@ object GardenVisitorFeatures {
val visitor = event.visitor
val text = visitor.status.displayName
val location = event.location
event.parent.drawString(location.add(y = 2.23), text)
event.parent.drawString(location.up(2.23), text)
if (config.rewardWarning.showOverName) {
visitor.hasReward()?.let { reward ->
val name = reward.displayName

event.parent.drawString(location.add(y = 2.73), "§c!$name§c!")
event.parent.drawString(location.up(2.73), "§c!$name§c!")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object CorpseLocator {
MineshaftWaypoints.waypoints.add(
MineshaftWaypoint(
waypointType = corpseType,
location = entity.getLorenzVec().add(y = 1),
location = entity.getLorenzVec().up(),
isCorpse = true,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.SimpleTimeMark
Expand All @@ -38,7 +38,7 @@ object MineshaftWaypoints {
fun onIslandChange(event: IslandChangeEvent) {
if (event.newIsland != IslandType.MINESHAFT) return

val playerLocation = LocationUtils.playerLocation().roundTo(0).add(y = -1)
val playerLocation = LorenzVec.getBlockBelowPlayer()

if (config.mineshaftWaypoints.entranceLocation) {
waypoints.add(MineshaftWaypoint(waypointType = MineshaftWaypointType.ENTRANCE, location = playerLocation))
Expand Down
Loading

0 comments on commit 9a2286a

Please sign in to comment.