forked from kami-blue/client
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
toasterbirb
committed
Apr 27, 2021
1 parent
5a9e51a
commit eff78c7
Showing
6 changed files
with
178 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
src/main/kotlin/org/kamiblue/client/gui/hudgui/elements/highway/Highwayspeed.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package org.kamiblue.client.gui.hudgui.elements.highway | ||
|
||
import net.minecraft.util.math.Vec3d | ||
import org.kamiblue.client.event.SafeClientEvent | ||
import org.kamiblue.client.gui.hudgui.LabelHud | ||
import org.kamiblue.client.util.BaritoneUtils | ||
import java.util.* | ||
import kotlin.math.pow | ||
import kotlin.math.roundToInt | ||
import kotlin.math.sqrt | ||
|
||
internal object HighwaySpeed : LabelHud( | ||
name = "HighwaySpeed", | ||
category = Category.HIGHWAY, | ||
description = "Highway building speed" | ||
) { | ||
private val showDistance by setting("Show distance", true) | ||
private val showDistanceLeft by setting("Show distance left", true) | ||
private val showTime by setting("Show elapsed time", true) | ||
private val showTimeLeft by setting("Show time left", true) | ||
private val showBlocksPlaced by setting("Show placed blocks", true) | ||
private val showBlocksLeft by setting("Show blocks left", true) | ||
|
||
private var building = false | ||
private var startPos = Vec3d(0.00, 0.00, 0.00) | ||
private var startTime = Calendar.getInstance().timeInMillis | ||
|
||
private var targetPos = Vec3d(30000000.00, 100.00, -30000000.00) | ||
|
||
|
||
|
||
override fun SafeClientEvent.updateText() { | ||
val entity = mc.renderViewEntity ?: player | ||
val pos = entity.positionVector | ||
|
||
if (!building) | ||
{ | ||
val process = BaritoneUtils.primary?.pathingControlManager?.mostRecentInControl()?.orElse(null) ?: return | ||
|
||
if (process.displayName() == "Building highway") | ||
{ | ||
startPos = pos | ||
startTime = Calendar.getInstance().timeInMillis | ||
building = true | ||
} | ||
} | ||
|
||
// Check if building highway | ||
if (building) | ||
{ | ||
// Delta for walked distance | ||
val deltaX = pos.x - startPos.x | ||
val deltaZ = pos.z - startPos.z | ||
|
||
// Delta for distance left | ||
val deltaLeftX = targetPos.x - pos.x | ||
val deltaLeftZ = targetPos.z - pos.z | ||
|
||
val distance = sqrt((deltaX.pow(2) + deltaZ.pow(2))).roundToInt() | ||
val distanceLeft = sqrt((deltaLeftX.pow(2) + deltaLeftZ.pow(2))).roundToInt() | ||
val elapsedTime = (Calendar.getInstance().timeInMillis - startTime) / 1000 | ||
var elapsedTimeString = "n/a" | ||
|
||
if (elapsedTime > 3600) | ||
{ | ||
elapsedTimeString = "${elapsedTime / 3600} hours" | ||
} | ||
else if (elapsedTime > 60) | ||
{ | ||
elapsedTimeString = "${elapsedTime / 60} minutes" | ||
} | ||
else | ||
{ | ||
elapsedTimeString = "$elapsedTime seconds" | ||
} | ||
|
||
var timeLeft: Long = 0 | ||
var timeLeftString = "" | ||
|
||
if (distance > 0 && elapsedTime > 0) | ||
{ | ||
timeLeft = distanceLeft / distance * elapsedTime / 60 / 60 | ||
|
||
if (timeLeft / 24 > 365) | ||
{ | ||
val years: Float = timeLeft / 24f / 365f | ||
timeLeftString = "$timeLeft hours ($years years)" | ||
} | ||
else | ||
{ | ||
timeLeftString = "$timeLeft hours (${timeLeft / 24} days)" | ||
} | ||
} | ||
|
||
if (showDistance) | ||
{ | ||
displayText.add("Distance moved:", secondaryColor) | ||
displayText.addLine("$distance") | ||
} | ||
|
||
if (showDistanceLeft) | ||
{ | ||
displayText.add("Distance left:", secondaryColor) | ||
displayText.addLine("$distanceLeft") | ||
} | ||
|
||
if (showTime) | ||
{ | ||
displayText.add("Time:", secondaryColor) | ||
displayText.addLine("$elapsedTimeString") | ||
} | ||
|
||
if (showTimeLeft) | ||
{ | ||
displayText.add("Time left:", secondaryColor) | ||
displayText.addLine("$timeLeftString") | ||
} | ||
|
||
if (showBlocksPlaced) | ||
{ | ||
displayText.add("Blocks placed:", secondaryColor) | ||
displayText.addLine("${(deltaX * 5).roundToInt()}") | ||
} | ||
|
||
if (showBlocksLeft) | ||
{ | ||
displayText.add("Missing blocks:", secondaryColor) | ||
displayText.addLine("${(deltaLeftX * 5).roundToInt()}") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/org/kamiblue/client/module/modules/highway/Highwaybot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.kamiblue.client.module.modules.render | ||
|
||
import org.kamiblue.client.command.CommandManager | ||
import org.kamiblue.client.event.events.BaritoneCommandEvent | ||
import org.kamiblue.client.event.events.ConnectionEvent | ||
import org.kamiblue.client.module.Category | ||
import org.kamiblue.client.module.Module | ||
import org.kamiblue.client.util.BaritoneUtils | ||
import org.kamiblue.client.util.text.MessageSendHelper | ||
|
||
internal object Highwaybot : Module( | ||
name = "HighwayBot", | ||
description = "Starts building the highway NE gang style", | ||
category = Category.HIGHWAY | ||
) { | ||
init { | ||
onEnable { | ||
Start() | ||
} | ||
|
||
onDisable { | ||
Stop() | ||
BaritoneUtils.cancelEverything() | ||
} | ||
} | ||
|
||
private fun Start() { | ||
MessageSendHelper.sendBaritoneCommand("highwaybuild") | ||
} | ||
|
||
private fun Stop() { | ||
MessageSendHelper.sendBaritoneCommand("highwaystop") | ||
} | ||
} |