Skip to content

Commit

Permalink
Highwaybot gui and other features
Browse files Browse the repository at this point in the history
  • Loading branch information
toasterbirb committed Apr 27, 2021
1 parent 5a9e51a commit eff78c7
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ abstract class AbstractHudElement(
COMBAT("Combat"),
PLAYER("Player"),
WORLD("World"),
MISC("Misc")
MISC("Misc"),
HIGHWAY("Highway")
}

protected companion object {
Expand Down
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()}")
}
}
}
}
5 changes: 3 additions & 2 deletions src/main/kotlin/org/kamiblue/client/module/Category.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ enum class Category(override val displayName: String) : DisplayEnum {
MISC("Misc"),
MOVEMENT("Movement"),
PLAYER("Player"),
RENDER("Render");
RENDER("Render"),
HIGHWAY("Highway");

override fun toString() = displayName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal object CustomChat : Module(
}

private enum class TextMode {
NAME, ON_TOP, WEBSITE, JAPANESE, CUSTOM
NAME, ON_TOP, JAPANESE, CUSTOM
}

private val timer = TickTimer(TimeUnit.SECONDS)
Expand All @@ -55,10 +55,9 @@ internal object CustomChat : Module(
}

private fun getText() = when (textMode) {
TextMode.NAME -> "ᴋᴀᴍɪ ʙʟᴜᴇ"
TextMode.ON_TOP -> "ᴋᴀᴍɪ ʙʟᴜᴇ ᴏɴ ᴛᴏᴘ"
TextMode.WEBSITE -> "kamiblue.org"
TextMode.JAPANESE -> "上にカミブルー"
TextMode.NAME -> "ᴷᴬᴹᴵ ᴿᴱᴰ"
TextMode.ON_TOP -> "ᴷᴬᴹᴵ ᴿᴱᴰ ᴼᴺ ᵀᴼᴾ"
TextMode.JAPANESE -> "上にカミ赤"
TextMode.CUSTOM -> customText
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ internal object Capes : Module(
) {
private val capeUsers = HashMap<UUID, Cape>().synchronized()

var updated = false; private set
var isPremium = false; private set
var updated = true; private set
var isPremium = true; private set

private val gson = Gson()
private val type = TypeToken.getArray(CapeUser::class.java).type
Expand Down Expand Up @@ -266,4 +266,4 @@ internal object Capes : Module(
TEXT_ICON(ResourceLocation("kamiblue/textures/capes/text_icon.png"))
}

}
}
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")
}
}

0 comments on commit eff78c7

Please sign in to comment.