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 69b0b85a8c10..d9cb34ed25d7 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 7d51994c029f..a4c4dcf8d09b 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 34e962890553..54ef80f77a4d 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 4d494567d4d6..ca9dd8c1f6bc 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 9cc4b8a100a2..2a8595af9e8e 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 aa58c3c0f43f..57cc77df583e 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 8962208424e4..13c5301126aa 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 e5425af34213..bef61bfbf5db 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 04b4fc7489ce..514d330a4bee 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 d1220d7e39be..b84ee2970b0d 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 9896580c6b2b..079f1cc630a6 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 8dc32fae6b4b..ba422d0f2eab 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 d07e55816732..6056c054eac9 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, ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 9fc0e7664aa1..1d5907d85284 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -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!") } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseLocator.kt index 3ea9ee4b14ec..6ec32fd2e129 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseLocator.kt @@ -59,7 +59,7 @@ object CorpseLocator { MineshaftWaypoints.waypoints.add( MineshaftWaypoint( waypointType = corpseType, - location = entity.getLorenzVec().add(y = 1), + location = entity.getLorenzVec().up(), isCorpse = true, ), ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypoints.kt index ae17e783bb16..2c05e35251ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypoints.kt @@ -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 @@ -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)) diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index 3908155724be..c7d7bb5042e6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -360,7 +360,7 @@ object MinionFeatures { val playerLocation = LocationUtils.playerLocation() val minions = minions ?: return for (minion in minions) { - val location = minion.key.add(y = 1.0) + val location = minion.key.up() if (location.distanceToPlayer() > 50) continue val lastEmptied = minion.value.lastClicked @@ -371,14 +371,14 @@ object MinionFeatures { val name = "§6" + if (config.nameOnlyTier) { displayName.split(" ").last() } else displayName - event.drawString(location.add(y = 0.65), name, true) + event.drawString(location.up(0.65), name, true) } if (config.emptiedTime.display && lastEmptied != 0L) { val passedSince = SimpleTimeMark(lastEmptied).passedSince() val format = passedSince.format(longName = true) + " ago" val text = "§eHopper Emptied: $format" - event.drawString(location.add(y = 1.15), text, true) + event.drawString(location.up(1.15), text, true) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt index 3babbc52a4af..0d300bab1e87 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt @@ -74,7 +74,7 @@ object PatcherSendCoordinates { event.drawColor(location, LorenzColor.DARK_GREEN, alpha = 1f) event.drawWaypointFilled(location, config.color.toChromaColor(), true, true) - event.drawString(location.add(0.5, 0.5, 0.5), beacon.name + " §e[${formattedDistance}m]", true, LorenzColor.DARK_BLUE.toColor()) + event.drawString(location.blockCenter(), beacon.name + " §e[${formattedDistance}m]", true, LorenzColor.DARK_BLUE.toColor()) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index 9d1a1dca24a0..6ca32d610db6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -254,10 +254,12 @@ object TrevorFeatures { var entityTrapper = EntityUtils.getEntityByID(trapperID) if (entityTrapper !is EntityLivingBase) entityTrapper = EntityUtils.getEntityByID(backupTrapperID) if (entityTrapper is EntityLivingBase && config.trapperTalkCooldown) { - RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entityTrapper, currentStatus.color) { config.trapperTalkCooldown } + RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entityTrapper, currentStatus.color) { + config.trapperTalkCooldown + } entityTrapper.getLorenzVec().let { if (it.distanceToPlayer() < 15) { - event.drawString(it.add(y = 2.23), currentLabel) + event.drawString(it.up(2.23), currentLabel) } } } @@ -273,11 +275,11 @@ object TrevorFeatures { TrevorSolver.currentMob!!.mobName } location = TrevorSolver.mobCoordinates - event.drawWaypointFilled(location.add(y = -2), LorenzColor.GREEN.toColor(), true, true) - event.drawDynamicText(location.add(y = 1), displayName, 1.5) + event.drawWaypointFilled(location.down(2), LorenzColor.GREEN.toColor(), true, true) + event.drawDynamicText(location.up(), displayName, 1.5) } else { event.drawWaypointFilled(location, LorenzColor.GOLD.toColor(), true, true) - event.drawDynamicText(location.add(y = 1), TrevorSolver.mobLocation.location, 1.5) + event.drawDynamicText(location.up(), TrevorSolver.mobLocation.location, 1.5) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt index 1d74e0b96581..7d2240d4dbdd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt @@ -62,7 +62,7 @@ object MatriarchHelper { val color = config.lineColor.toChromaColor() var prePoint = event.exactPlayerEyeLocation() for (mob in pearlList) { - val point = mob.baseEntity.getLorenzVec().add(y = 1.2) + val point = mob.baseEntity.getLorenzVec().up(1.2) event.draw3DLine(prePoint, point, color, 10, true) prePoint = point } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt index 849f9a48a0b0..de4db8f833da 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt @@ -50,7 +50,7 @@ object AshfangBlazingSouls { event.drawWaypointFilled(orbLocation.add(-0.5, 1.25, -0.5), color, extraSize = -0.15) if (orbLocation.distance(playerLocation) < 10) { // TODO find way to dynamically change color - event.drawString(orbLocation.add(y = 2.5), "§bBlazing Soul") + event.drawString(orbLocation.up(2.5), "§bBlazing Soul") } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt index 6a4b02416ed5..1eaa1dd5e921 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt @@ -52,7 +52,7 @@ object AshfangGravityOrbs { if (orbLocation.distance(playerLocation) < 15) { // TODO find way to dynamically change color - event.drawString(orbLocation.add(y = 2.5), "§cGravity Orb") + event.drawString(orbLocation.up(2.5), "§cGravity Orb") } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftAgaricusCap.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftAgaricusCap.kt index 161200fedad6..d601601a10e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftAgaricusCap.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftAgaricusCap.kt @@ -63,7 +63,7 @@ object RiftAgaricusCap { fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return - val location = location?.add(y = 0.6) ?: return + val location = location?.up(0.6) ?: return if (startTime.isFarFuture()) { event.drawDynamicText(location, "§cClick!", 1.5) diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt index 9ff96213b3fe..4ac014d3abe1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt @@ -52,7 +52,7 @@ object RiftWiltedBerberisHelper { hasFarmingToolInHand = InventoryUtils.getItemInHand()?.getInternalName() == RiftAPI.farmingTool if (Minecraft.getMinecraft().thePlayer.onGround) { - val block = LocationUtils.playerLocation().add(y = -1).getBlockAt() + val block = LorenzVec.getBlockBelowPlayer().getBlockAt() val currentY = LocationUtils.playerLocation().y isOnFarmland = block == Blocks.farmland && (currentY % 1 == 0.0) } @@ -132,7 +132,7 @@ object RiftWiltedBerberisHelper { val location = currentParticles.fixLocation(berberis) if (!moving) { event.drawFilledBoundingBox_nea(axisAlignedBB(location), Color.YELLOW, 0.7f) - event.drawDynamicText(location.add(y = 1), "§eWilted Berberis", 1.5, ignoreBlocks = false) + event.drawDynamicText(location.up(), "§eWilted Berberis", 1.5, ignoreBlocks = false) } else { event.drawFilledBoundingBox_nea(axisAlignedBB(location), Color.WHITE, 0.5f) previous?.fixLocation(berberis)?.let { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt index 6b94919eeb77..50c6593fb9d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt @@ -78,9 +78,9 @@ object VoltHighlighter { val dischargeTimeLeft = CHARGE_TIME - dischargingSince.passedSince() if (dischargeTimeLeft > Duration.ZERO) { event.drawDynamicText( - event.exactLocation(entity).add(y = 2.5), + event.exactLocation(entity).up(2.5), "§eLightning: ${dischargeTimeLeft.format(showMilliSeconds = true)}", - 2.5 + 2.5, ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt index 275ca3573ac2..dd5910b58c79 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt @@ -17,8 +17,9 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo 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.getLorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -140,18 +141,16 @@ object LivingCaveDefenseBlocks { fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return - for ((block, time) in movingBlocks) { if (block.hidden) continue if (time > System.currentTimeMillis()) { val location = block.location event.drawWaypointFilled(location, color) - event.draw3DLine( - block.entity.getLorenzVec().add(y = 0.5), - location.add(0.5, 0.5, 0.5), + event.drawLineToEye( + location.blockCenter(), color, 1, - false + false, ) } } @@ -161,8 +160,8 @@ object LivingCaveDefenseBlocks { event.drawWaypointFilled(location, color) event.draw3DLine( - block.entity.getLorenzVec().add(y = 0.5), - location.add(0.5, 0.5, 0.5), + event.exactLocation(block.entity).up(0.5), + location.blockCenter(), color, 3, true, diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt index c93932344d63..2ff0eac9931d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt @@ -27,7 +27,7 @@ object RiftUpsideDownParkour { data.locations.map { it.add(-1.0, -1.0, -1.0) }, // TODO remove offset. change repo instead data.shortCuts, platformSize = 2.0, - detectionRange = 2.0 + detectionRange = 2.0, ) updateConfig() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt index 86ae6d096226..24b254736e73 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt @@ -163,7 +163,7 @@ object EnigmaSoulWaypoints { for (soul in trackedSouls) { soulLocations[soul]?.let { event.drawWaypointFilled(it, config.color.toChromaColor(), seeThroughBlocks = true, beacon = true) - event.drawDynamicText(it.add(y = 1), "§5${soul.removeSuffix(" Soul")} Soul", 1.5) + event.drawDynamicText(it.up(), "§5${soul.removeSuffix(" Soul")} Soul", 1.5) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt index 4fc0ccbf5fce..064dbf506ef0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt @@ -87,7 +87,7 @@ object RiftMotesOrb { orb.pickedUp = true } - val location = orb.location.add(y = 0.5) + val location = orb.location.up(0.5) val sizeOffset = (5 - config.size) * -0.1 val color = if (orb.pickedUp) LorenzColor.GRAY else LorenzColor.LIGHT_PURPLE val text = color.getChatColor() + "Motes Orb" diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt index 2880d183b468..20edbf285ba2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt @@ -42,7 +42,7 @@ object SlayerItemsOnGround { 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/slayer/SlayerMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt index 4798a943257d..11a335a63afd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt @@ -14,8 +14,7 @@ import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils -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.entity.EntityCreature import net.minecraft.entity.monster.EntityBlaze @@ -63,12 +62,11 @@ object SlayerMiniBossFeatures { if (mob.isDead) continue if (mob.distanceToPlayer() > 10) continue - event.draw3DLine( - event.exactPlayerEyeLocation(), - mob.getLorenzVec().add(y = 1), + event.drawLineToEye( + mob.getLorenzVec().up(), LorenzColor.AQUA.toColor(), config.slayerMinibossLineWidth, - true + true, ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt index 57aa65e53527..df7ab69d907a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt @@ -22,12 +22,14 @@ import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsInRadiusWith import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture import at.hannibal2.skyhanni.utils.EntityUtils.isNPC import at.hannibal2.skyhanni.utils.LocationUtils +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth 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.exactLocation import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation @@ -115,15 +117,17 @@ object VampireSlayerFeatures { it.name.contains(username) } val containCoop = getAllNameTagsInRadiusWith("Spawned by").any { - coopList.isNotEmpty() && configCoopBoss.highlight && coopList.any { it2 -> - var contain = false - if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) { - val name = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex() - .find(it.name)?.groupValues?.get(1) - contain = it2 == name + coopList.isNotEmpty() && + configCoopBoss.highlight && + coopList.any { it2 -> + var contain = false + if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) { + val name = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex() + .find(it.name)?.groupValues?.get(1) + contain = it2 == name + } + contain } - contain - } } val shouldSendTitle = if (containUser && configOwnBoss.twinClawsTitle) true @@ -146,22 +150,23 @@ object VampireSlayerFeatures { for (it in getAllNameTagsInRadiusWith("Spawned by")) { val coopList = configCoopBoss.coopMembers.split(",").toList() val containUser = it.name.contains(username) - val containCoop = coopList.isNotEmpty() && coopList.any { it2 -> - var contain = false - if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) { - val name = - ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex().find(it.name)?.groupValues?.get(1) - contain = it2 == name + val containCoop = coopList.isNotEmpty() && + coopList.any { it2 -> + var contain = false + if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) { + val name = + ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex().find(it.name)?.groupValues?.get(1) + contain = it2 == name + } + contain } - contain - } val neededHealth = baseMaxHealth * 0.2f - if (containUser && taggedEntityList.contains(this.entityId)) { - taggedEntityList.remove(this.entityId) + if (containUser && taggedEntityList.contains(entityId)) { + taggedEntityList.remove(entityId) } val canUseSteak = health <= neededHealth val ownBoss = configOwnBoss.highlight && containUser && isNPC() - val otherBoss = configOtherBoss.highlight && taggedEntityList.contains(this.entityId) && isNPC() + val otherBoss = configOtherBoss.highlight && taggedEntityList.contains(entityId) && isNPC() val coopBoss = configCoopBoss.highlight && containCoop && isNPC() val shouldRender = if (ownBoss) true else if (otherBoss) true else coopBoss @@ -176,7 +181,7 @@ object VampireSlayerFeatures { val shouldSendSteakTitle = if (canUseSteak && configOwnBoss.steakAlert && containUser) true - else if (canUseSteak && configOtherBoss.steakAlert && taggedEntityList.contains(this.entityId)) true + else if (canUseSteak && configOtherBoss.steakAlert && taggedEntityList.contains(entityId)) true else canUseSteak && configCoopBoss.steakAlert && containCoop if (shouldSendSteakTitle) { @@ -191,7 +196,7 @@ object VampireSlayerFeatures { } private fun EntityOtherPlayerMP.isHighlighted(): Boolean { - return entityList.contains(this) || taggedEntityList.contains(this.entityId) + return entityList.contains(this) || taggedEntityList.contains(entityId) } private fun String.color(): Int { @@ -208,14 +213,15 @@ object VampireSlayerFeatures { val regexA = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex() val regexB = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex() for (armorStand in event.clickedEntity.getAllNameTagsInRadiusWith("Spawned by")) { - val containCoop = coopList.isNotEmpty() && coopList.any { it2 -> - var contain = false - if (regexA.matches(armorStand.name)) { - val name = regexB.find(armorStand.name)?.groupValues?.get(1) - contain = it2 == name + val containCoop = coopList.isNotEmpty() && + coopList.any { + var contain = false + if (regexA.matches(armorStand.name)) { + val name = regexB.find(armorStand.name)?.groupValues?.get(1) + contain = it == name + } + contain } - contain - } if (armorStand.name.contains(username) || containCoop) return if (!taggedEntityList.contains(event.clickedEntity.entityId)) { taggedEntityList.add(event.clickedEntity.entityId) @@ -256,27 +262,25 @@ object VampireSlayerFeatures { @SubscribeEvent fun onWorldRender(event: LorenzRenderWorldEvent) { if (!isEnabled()) return - val start = LocationUtils.playerLocation() if (config.drawLine) { for (it in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance()) { if (!it.isHighlighted()) continue val vec = event.exactLocation(it) - val distance = start.distance(vec) - if (distance > 15) continue - event.draw3DLine( - event.exactPlayerEyeLocation(), - vec.add(y = 1.54), - config.lineColor.toChromaColor(), - config.lineWidth, - true - ) + if (vec.distanceToPlayer() < 15) { + event.drawLineToEye( + vec.up(1.54), + config.lineColor.toChromaColor(), + config.lineWidth, + true, + ) + } } } if (!configBloodIchor.highlight && !configKillerSpring.highlight) return for (stand in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance()) { val vec = stand.position.toLorenzVec() - val distance = start.distance(vec) + val distance = vec.distanceToPlayer() val isIchor = stand.hasSkullTexture(BLOOD_ICHOR_TEXTURE) val isSpring = stand.hasSkullTexture(KILLER_SPRING_TEXTURE) if (!(isIchor && config.bloodIchor.highlight) && !(isSpring && config.killerSpring.highlight)) continue @@ -292,9 +296,9 @@ object VampireSlayerFeatures { (if (isIchor) configBloodIchor.linesColor else configKillerSpring.linesColor).toChromaColor() val text = if (isIchor) "§4Ichor" else "§4Spring" event.drawColor( - stand.position.toLorenzVec().add(y = 2.0), + stand.position.toLorenzVec().up(2.0), LorenzColor.DARK_RED, - alpha = 1f + alpha = 1f, ) event.drawDynamicText( stand.position.toLorenzVec().add(0.5, 2.5, 0.5), @@ -305,13 +309,13 @@ object VampireSlayerFeatures { for ((player, stand2) in standList) { if ((configBloodIchor.showLines && isIchor) || (configKillerSpring.showLines && isSpring)) event.draw3DLine( - event.exactLocation(player).add(y = 1.5), - event.exactLocation(stand2).add(y = 1.5), - // stand2.position.toLorenzVec().add(0.0, 1.5, 0.0), + event.exactPlayerEyeLocation(player), + event.exactPlayerEyeLocation(stand2), linesColorStart, 3, - true + true, ) + } } if (configBloodIchor.renderBeam && isIchor && stand.isEntityAlive) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt index dd63fdd966a3..684d06cd4ba2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt @@ -24,12 +24,11 @@ import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec -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.exactLocation -import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.getLorenzVec @@ -135,12 +134,11 @@ object EndermanSlayerFeatures { val skullLocation = event.exactLocation(skull) if (skullLocation.distanceToPlayer() > 20) continue if (!skullLocation.canBeSeen()) continue - event.draw3DLine( - event.exactPlayerEyeLocation(), - skullLocation.add(y = 1), + event.drawLineToEye( + skullLocation.up(), LorenzColor.GOLD.toColor(), 3, - true, + true ) } } @@ -156,8 +154,7 @@ object EndermanSlayerFeatures { if (beaconConfig.showLine) { val beaconLocation = event.exactLocation(beacon) - event.draw3DLine( - event.exactPlayerEyeLocation(), + event.drawLineToEye( beaconLocation.add(0.5, 1.0, 0.5), beaconConfig.lineColor.toChromaColor(), beaconConfig.lineWidth, @@ -171,8 +168,7 @@ object EndermanSlayerFeatures { for ((location, time) in sittingBeacon) { if (location.distanceToPlayer() > 20) continue if (beaconConfig.showLine) { - event.draw3DLine( - event.exactPlayerEyeLocation(), + event.drawLineToEye( location.add(0.5, 1.0, 0.5), beaconConfig.lineColor.toChromaColor(), beaconConfig.lineWidth, diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt index ef9da0261b93..da3b62cc2d5c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt @@ -83,7 +83,7 @@ object SummoningSoulsName { for ((entity, name) in souls) { val vec = entity.getLorenzVec() - event.drawString(vec.add(y = 2.5), name) + event.drawString(vec.up(2.5), name) } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt index a48294bd8e64..bdcb935bb034 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt @@ -112,19 +112,19 @@ object TrackParticlesCommand { if (value.size != 1) { event.drawDynamicText(key, "§e${value.size} particles", 0.8) - var offset = -0.2 + var offset = 0.2 value.groupBy { it.type }.forEach { (particleType, particles) -> - event.drawDynamicText(key.up(offset), "§7§l$particleType §7(§e${particles.size}§7)", 0.8) - offset -= 0.2 + event.drawDynamicText(key.down(offset), "§7§l$particleType §7(§e${particles.size}§7)", 0.8) + offset += 0.2 } } else { val particle = value.first() event.drawDynamicText(key, "§7§l${particle.type}", 0.8) event.drawDynamicText( - key.up(-0.2), + key.down(0.2), "§7C: §e${particle.count} §7S: §a${particle.speed.roundTo(2)}", - scaleMultiplier = 0.8 + scaleMultiplier = 0.8, ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt index 18cfcf786bf8..c038d8098699 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt @@ -114,10 +114,10 @@ object TrackSoundsCommand { if (value.size != 1) { event.drawDynamicText(key, "§e${value.size} sounds", 0.8) - var offset = -0.2 + var offset = 0.2 value.groupBy { it.soundName }.forEach { (soundName, sounds) -> - event.drawDynamicText(key.up(offset), "§7§l$soundName §7(§e${sounds.size}§7)", 0.8) - offset -= 0.2 + event.drawDynamicText(key.down(offset), "§7§l$soundName §7(§e${sounds.size}§7)", 0.8) + offset += 0.2 } } else { val sound = value.first() @@ -129,7 +129,7 @@ object TrackSoundsCommand { event.drawDynamicText(key, "§7§l${sound.soundName}", 0.8) event.drawDynamicText( - key.up(-0.2), + key.down(0.2), "§7P: §e${sound.pitch.roundTo(2)} §7V: $volumeColor${sound.volume.roundTo(2)}", scaleMultiplier = 0.8, ) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index 281b744d657b..59799ff3d1fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -63,7 +63,7 @@ object EntityUtils { fun EntityLivingBase.getAllNameTagsInRadiusWith( contains: String, radius: Double = 3.0, - ): List = getArmorStandsInRadius(getLorenzVec().add(y = 3), radius).filter { + ): List = getArmorStandsInRadius(getLorenzVec().up(3), radius).filter { it.getNameAsString().contains(contains) } @@ -84,7 +84,7 @@ object EntityUtils { inaccuracy: Double = 1.6, debugWrongEntity: Boolean = false, ): List { - val center = getLorenzVec().add(y = y) + val center = getLorenzVec().up(y) return getArmorStandsInRadius(center, inaccuracy).filter { val result = it.getNameAsString().contains(contains) if (debugWrongEntity && !result) { @@ -188,7 +188,7 @@ object EntityUtils { if (Minecraft.getMinecraft().isCallingFromMinecraftThread) it else it.toMutableList() }?.asSequence()?.filterNotNull() ?: emptySequence() - fun Entity.canBeSeen(radius: Double = 150.0) = getLorenzVec().add(y = 0.5).canBeSeen(radius) + fun Entity.canBeSeen(radius: Double = 150.0) = getLorenzVec().up(0.5).canBeSeen(radius) fun getEntityByID(entityId: Int) = Minecraft.getMinecraft()?.thePlayer?.entityWorld?.getEntityByID(entityId) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt index 34aa3f22f303..d2394624c8a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt @@ -35,7 +35,7 @@ object LocationUtils { fun playerEyeLocation(): LorenzVec { val player = Minecraft.getMinecraft().thePlayer val vec = player.getLorenzVec() - return vec.add(y = player.getEyeHeight().toDouble()) + return vec.up(player.getEyeHeight().toDouble()) } fun AxisAlignedBB.isInside(vec: LorenzVec) = isVecInside(vec.toVec3()) @@ -53,7 +53,7 @@ object LocationUtils { fun LorenzVec.canBeSeen(yOffsetRange: IntRange, radius: Double = 150.0): Boolean = yOffsetRange.any { offset -> - this.add(y = offset).canBeSeen(radius) + up(offset).canBeSeen(radius) } fun AxisAlignedBB.minBox() = LorenzVec(minX, minY, minZ) @@ -99,7 +99,7 @@ object LocationUtils { fun AxisAlignedBB.getCenter() = getEdgeLengths() * 0.5 + minBox() - fun AxisAlignedBB.getTopCenter() = getCenter().add(y = (maxY - minY) / 2) + fun AxisAlignedBB.getTopCenter() = getCenter().up((maxY - minY) / 2) fun AxisAlignedBB.clampTo(other: AxisAlignedBB): AxisAlignedBB { val minX = max(this.minX, other.minX) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt index 6769210ef26b..ee84731116fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt @@ -42,7 +42,7 @@ data class LorenzVec( fun distance(x: Double, y: Double, z: Double): Double = distance(LorenzVec(x, y, z)) - fun distanceChebyshevIgnoreY(other: LorenzVec) = max(abs(this.x - other.x), abs(this.z - other.z)) + fun distanceChebyshevIgnoreY(other: LorenzVec) = max(abs(x - other.x), abs(z - other.z)) fun distanceSq(other: LorenzVec): Double { val dx = other.x - x @@ -86,11 +86,11 @@ data class LorenzVec( fun dotProduct(other: LorenzVec): Double = (x * other.x) + (y * other.y) + (z * other.z) - fun angleAsCos(other: LorenzVec) = this.normalize().dotProduct(other.normalize()) + fun angleAsCos(other: LorenzVec) = normalize().dotProduct(other.normalize()) - fun angleInRad(other: LorenzVec) = acos(this.angleAsCos(other)) + fun angleInRad(other: LorenzVec) = acos(angleAsCos(other)) - fun angleInDeg(other: LorenzVec) = Math.toDegrees(this.angleInRad(other)) + fun angleInDeg(other: LorenzVec) = Math.toDegrees(angleInRad(other)) @Deprecated("Use operator fun plus instead", ReplaceWith("this + other")) fun add(other: LorenzVec) = LorenzVec(x + other.x, y + other.y, z + other.z) @@ -125,7 +125,7 @@ data class LorenzVec( fun toCleanString(separator: String = ", "): String = listOf(x, y, z).joinToString(separator) fun lengthSquared(): Double = x * x + y * y + z * z - fun length(): Double = sqrt(this.lengthSquared()) + fun length(): Double = sqrt(lengthSquared()) fun isNormalized(tolerance: Double = 0.01) = (lengthSquared() - 1.0).absoluteValue < tolerance @@ -165,13 +165,15 @@ data class LorenzVec( return LorenzVec(x, y, z) } + fun blockCenter() = roundLocationToBlock().add(0.5, 0.5, 0.5) + fun slope(other: LorenzVec, factor: Double) = this + (other - this).scale(factor) // TODO better name. dont confuse with roundTo() fun roundLocation(): LorenzVec { - val x = if (this.x < 0) x.toInt() - 1 else x.toInt() + val x = if (x < 0) x.toInt() - 1 else x.toInt() val y = y.toInt() - 1 - val z = if (this.z < 0) z.toInt() - 1 else z.toInt() + val z = if (z < 0) z.toInt() - 1 else z.toInt() return LorenzVec(x, y, z) } @@ -186,14 +188,16 @@ data class LorenzVec( fun axisAlignedTo(other: LorenzVec) = AxisAlignedBB(x, y, z, other.x, other.y, other.z) - fun up(offset: Double): LorenzVec = copy(y = y + offset) + fun up(offset: Number = 1): LorenzVec = copy(y = y + offset.toDouble()) + + fun down(offset: Number = 1): LorenzVec = copy(y = y - offset.toDouble()) fun interpolate(other: LorenzVec, factor: Double): LorenzVec { require(factor in 0.0..1.0) { "Percentage must be between 0 and 1: $factor" } - val x = (1 - factor) * this.x + factor * other.x - val y = (1 - factor) * this.y + factor * other.y - val z = (1 - factor) * this.z + factor * other.z + val x = (1 - factor) * x + factor * other.x + val y = (1 - factor) * y + factor * other.y + val z = (1 - factor) * z + factor * other.z return LorenzVec(x, y, z) } @@ -244,7 +248,7 @@ data class LorenzVec( return LorenzVec(x, y, z) } - fun getBlockBelowPlayer() = LocationUtils.playerLocation().roundLocationToBlock().add(y = -1.0) + fun getBlockBelowPlayer() = LocationUtils.playerLocation().roundLocationToBlock().down() val expandVector = LorenzVec(0.0020000000949949026, 0.0020000000949949026, 0.0020000000949949026) } @@ -268,6 +272,6 @@ fun Array.toLorenzVec(): LorenzVec { fun RenderUtils.translate(vec: LorenzVec) = GlStateManager.translate(vec.x, vec.y, vec.z) -fun AxisAlignedBB.expand(vec: LorenzVec): AxisAlignedBB = this.expand(vec.x, vec.y, vec.z) +fun AxisAlignedBB.expand(vec: LorenzVec): AxisAlignedBB = expand(vec.x, vec.y, vec.z) -fun AxisAlignedBB.expand(amount: Double): AxisAlignedBB = this.expand(amount, amount, amount) +fun AxisAlignedBB.expand(amount: Double): AxisAlignedBB = expand(amount, amount, amount) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt index 4fccbed68125..f6d52b7fc593 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt @@ -122,7 +122,7 @@ class ParkourHelper( if (outline) event.outlineTopFace(aabb, 2, Color.BLACK, depth) } if (SkyHanniMod.feature.dev.waypoint.showPlatformNumber && !isMovingPlatform) { - event.drawString(location.offsetCenter().add(y = 1), "§a§l$index", seeThroughBlocks = true) + event.drawString(location.offsetCenter().up(1), "§a§l$index", seeThroughBlocks = true) } } } catch (e: Throwable) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 39f251340a3b..14241f314a32 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -1100,6 +1100,15 @@ object RenderUtils { return exactLocation(player) + add } + fun LorenzRenderWorldEvent.exactPlayerEyeLocation(player: Entity): LorenzVec { + val add = if (player.isSneaking) LorenzVec(0.0, 1.54, 0.0) else LorenzVec(0.0, 1.62, 0.0) + return exactLocation(player) + add + } + + fun LorenzRenderWorldEvent.drawLineToEye(location: LorenzVec, color: Color, lineWidth: Int, depth: Boolean) { + draw3DLine(exactPlayerEyeLocation(), location, color, lineWidth, depth) + } + fun exactLocation(entity: Entity, partialTicks: Float): LorenzVec { if (entity.isDead) return entity.getLorenzVec() val x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks