diff options
| author | Empa <42304516+ItsEmpa@users.noreply.github.com> | 2024-10-11 19:01:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-11 19:01:42 +0200 |
| commit | 9a2286ac3070e1ba0023445dc8243e618989e86e (patch) | |
| tree | 6c4ad95a8df2ce6fff17e5ea96f8df09c4e5ea07 /src/main/java | |
| parent | 8c54be95700b224c2f93b549465dbe06bf3bbe86 (diff) | |
| download | skyhanni-9a2286ac3070e1ba0023445dc8243e618989e86e.tar.gz skyhanni-9a2286ac3070e1ba0023445dc8243e618989e86e.tar.bz2 skyhanni-9a2286ac3070e1ba0023445dc8243e618989e86e.zip | |
Backend: LorenzVec up/down and drawLineToEye (#2056)
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>
Diffstat (limited to 'src/main/java')
41 files changed, 180 insertions, 185 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt index 69b0b85a8..d9cb34ed2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt @@ -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) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt index 7d51994c0..a4c4dcf8d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt @@ -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 @@ -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, ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/CosmeticFollowingLine.kt b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/CosmeticFollowingLine.kt index 34e962890..54ef80f77 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/CosmeticFollowingLine.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/CosmeticFollowingLine.kt @@ -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) @@ -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 diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt index 4d494567d..ca9dd8c1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt @@ -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) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt index 9cc4b8a10..2a8595af9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -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 @@ -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 diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index aa58c3c0f..57cc77df5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -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 @@ -281,34 +280,32 @@ 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) { @@ -316,7 +313,7 @@ object GriffinBurrowHelper { 3 } else 2 if (currentWarp == null) { - event.draw3DLine(player, renderLocation, color.toColor(), lineWidth, false) + event.drawLineToEye(renderLocation, color.toColor(), lineWidth, false) } } @@ -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) } } @@ -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) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt index 896220842..13c530112 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt @@ -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) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt index e5425af34..bef61bfbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt @@ -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 @@ -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) } } } @@ -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) } } } @@ -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) } } } @@ -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() diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt index 04b4fc748..514d330a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt @@ -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) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt index d1220d7e3..b84ee2970 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt @@ -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 @@ -47,7 +46,6 @@ 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() @@ -55,10 +53,10 @@ object ThunderSparksHighlight { 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) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 9896580c6..079f1cc63 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -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 diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt index 8dc32fae6..ba422d0f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt @@ -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 @@ -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 } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt index d07e55816..6056c054e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt @@ -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 @@ -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, ) } |
