Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
odtheking committed Oct 26, 2024
2 parents e8197c1 + 992083b commit 45f29d3
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ val devCommand = commodore("oddev") {
}
}

literal("reset") {
runs { soft: Boolean? ->
WitherDragonsEnum.reset(soft == true)
}
literal("reset").runs { soft: Boolean? ->
WitherDragonsEnum.reset(soft == true)
}

literal("status").runs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ val dungeonWaypointsCommand = commodore("dwp", "dungeonwaypoints") {
modMessage("Size changed to: ${DungeonWaypoints.size}")
}

literal("distance").runs { reach: Int ->
DungeonWaypoints.distance = reach.toDouble()
}

literal("resetsecrets").runs {
resetSecrets()
modMessage("§aSecrets have been reset!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ val PosMsgCommand = commodore("posmsg") {
val saveData = "x: ${x}, y: ${y}, z: ${z}, delay: ${delay}, distance: ${distance}, message: \"${message}\""
if (posMessageStrings.contains(saveData)) return@runs modMessage("This message already exists!")
modMessage("Message \"${message}\" added at $x, $y, $z, with ${delay}ms delay, triggered up to $distance blocks away.")
parsedStrings.add(PosMessages.PosMessage(x, y, z, null, null, null, delay, distance, message.string))
posMessageStrings.add(saveData)
Config.save()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.CopyOnWriteArraySet
import kotlin.math.roundToInt

object BloodCamp : Module(
Expand Down Expand Up @@ -90,17 +93,17 @@ object BloodCamp : Module(

private var tickTime: Long = 0

private val forRender = hashMapOf<EntityArmorStand, RenderEData>()
private val forRender = ConcurrentHashMap<EntityArmorStand, RenderEData>()
private data class RenderEData(
var currVector: Vec3, var endVector: Vec3, var endVecUpdated: Long, var speedVectors: Vec3,
var lastEndVector: Vec3? = null, var lastPingPoint: Vec3? = null, var lastEndPoint: Vec3? = null,
)

private val entityList = hashMapOf<EntityArmorStand, EntityData>()
private val entityList = ConcurrentHashMap<EntityArmorStand, EntityData>()
private data class EntityData(var startVector: Vec3, val started: Long, var firstSpawns: Boolean = true)

private var firstSpawns = true
private var watcher = mutableListOf<Entity>()
private var watcher = CopyOnWriteArrayList<Entity>()

@SubscribeEvent
fun onPostMetadata(event: PostEntityMetadata) {
Expand All @@ -114,45 +117,41 @@ object BloodCamp : Module(

private fun onPacketLookMove(packet: S17PacketEntityLookMove) {
val entity = packet.getEntity(mc.theWorld) as? EntityArmorStand ?: return
if (!watcher.any { it.getDistanceToEntity(entity) < 20 }) return

if (entity.getEquipmentInSlot(4)?.item != Items.skull || !allowedMobSkulls.contains(getSkullValue(entity))) return
if (watcher.none { it.getDistanceToEntity(entity) < 20 } || entity.getEquipmentInSlot(4)?.item != Items.skull || !allowedMobSkulls.contains(getSkullValue(entity))) return

val packetVector = Vec3(
(entity.serverPosX + packet.func_149062_c()) / 32.0,
(entity.serverPosY + packet.func_149061_d()) / 32.0,
(entity.serverPosZ + packet.func_149064_e()) / 32.0,
)

if (entity !in entityList) entityList[entity] = EntityData(startVector = packetVector, started = tickTime, firstSpawns = firstSpawns)
if (!entityList.containsKey(entity)) entityList[entity] = EntityData(startVector = packetVector, started = tickTime, firstSpawns = firstSpawns)
val data = entityList[entity] ?: return

if (watcher.none { it.getDistanceToEntity(entity) < 20 }) return
entityList[entity]?.let { data ->
val timeTook = tickTime - data.started
val startVector = data.startVector
val timeTook = tickTime - data.started
val startVector = data.startVector

val speedVectors = Vec3(
(packetVector.xCoord - startVector.xCoord) / timeTook,
(packetVector.yCoord - startVector.yCoord) / timeTook,
(packetVector.zCoord - startVector.zCoord) / timeTook,
)
val speedVectors = Vec3(
(packetVector.xCoord - startVector.xCoord) / timeTook,
(packetVector.yCoord - startVector.yCoord) / timeTook,
(packetVector.zCoord - startVector.zCoord) / timeTook,
)

val time = getTime(data.firstSpawns, timeTook)
val time = getTime(data.firstSpawns, timeTook)

val endpoint = Vec3(
packetVector.xCoord + speedVectors.xCoord * time,
packetVector.yCoord + speedVectors.yCoord * time,
packetVector.zCoord + speedVectors.zCoord * time,
)
val endpoint = Vec3(
packetVector.xCoord + speedVectors.xCoord * time,
packetVector.yCoord + speedVectors.yCoord * time,
packetVector.zCoord + speedVectors.zCoord * time,
)

if (entity !in forRender) forRender[entity] = RenderEData(packetVector, endpoint, tickTime, speedVectors)
else forRender[entity]?.let {
it.lastEndVector = it.endVector.clone()
it.currVector = packetVector
it.endVector = endpoint
it.endVecUpdated = tickTime
it.speedVectors = speedVectors
}
if (!forRender.containsKey(entity)) forRender[entity] = RenderEData(packetVector, endpoint, tickTime, speedVectors)
else forRender[entity]?.let {
it.lastEndVector = it.endVector.clone()
it.currVector = packetVector
it.endVector = endpoint
it.endVecUpdated = tickTime
it.speedVectors = speedVectors
}
}

Expand All @@ -167,15 +166,12 @@ object BloodCamp : Module(
if (!bloodHelper) return

forRender.forEach { (entity, renderData) ->
if (entity.isDead) return@forEach
val entityData = entityList[entity] ?: return@forEach
val (_, started, firstSpawn) = entityList[entity]?.takeUnless { entity.isDead } ?: return@forEach

val (currVector, endVector, endVecUpdated, speedVectors) = renderData
val lastEndVector = renderData.lastEndVector ?: return@forEach

val endVectorUpdated = min(tickTime - endVecUpdated, 100)

val endPoint = calcEndVector(endVector, lastEndVector, endVectorUpdated / 100)
val endPoint = calcEndVector(endVector, renderData.lastEndVector, endVectorUpdated / 100)

val pingPoint = Vec3(
entity.posX + speedVectors.xCoord * averagePing,
Expand All @@ -193,7 +189,7 @@ object BloodCamp : Module(
val pingAABB = AxisAlignedBB(boxSize,boxSize,boxSize, 0.0, 0.0, 0.0).offset(boxOffset + renderPingPoint)
val endAABB = AxisAlignedBB(boxSize,boxSize,boxSize, 0.0, 0.0, 0.0).offset(boxOffset + renderEndPoint)

val time = getTime(entityData.firstSpawns, tickTime - entityData.started)
val time = getTime(firstSpawn, tickTime - started)

if (averagePing < time) {
Renderer.drawBox(pingAABB, mboxColor, fillAlpha = 0f, outlineAlpha = mboxColor.alpha, depth = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ object SecretClicked : Module(
private val timeToStay by NumberSetting("Time To Stay (seconds)", 7, 1, 60, 1, description = "The time the chests should remain highlighted.").withDependency { boxesDropdown && boxes }
private val useRealSize by BooleanSetting("Use Real Size", true, description = "Whether or not to use the real size of the block.").withDependency { boxesDropdown && boxes }
private val boxInBoss by BooleanSetting("Box In Boss", false, description = "Highlight clicks in boss.").withDependency { boxesDropdown && boxes }
private val toggleItems by BooleanSetting("Item Boxes", default = true, description = "Render boxes for collected items.").withDependency { boxesDropdown && boxes }

private val chimeDropdownSetting by DropdownSetting("Secret Chime Dropdown")
private val chime by BooleanSetting("Secret Chime", true, description = "Whether or not to play a sound when a secret is clicked.").withDependency { chimeDropdownSetting }
Expand Down Expand Up @@ -65,10 +66,10 @@ object SecretClicked : Module(

@SubscribeEvent
fun onSecret(event: SecretPickupEvent) {
when (event) {
is SecretPickupEvent.Interact -> secretBox(event.blockPos)
is SecretPickupEvent.Bat -> secretBox(event.packet.positionVector.toBlockPos())
is SecretPickupEvent.Item -> secretBox(event.entity.positionVector.toBlockPos())
when {
event is SecretPickupEvent.Interact -> secretBox(event.blockPos)
event is SecretPickupEvent.Bat -> secretBox(event.packet.positionVector.toBlockPos())
event is SecretPickupEvent.Item && toggleItems -> secretBox(event.entity.positionVector.toBlockPos())
}
secretChime()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ import me.odinmain.features.settings.Setting.Companion.withDependency
import me.odinmain.features.settings.impl.*
import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha
import me.odinmain.utils.*
import me.odinmain.utils.render.Color
import me.odinmain.utils.render.RenderUtils
import me.odinmain.utils.render.*
import me.odinmain.utils.render.RenderUtils.outlineBounds
import me.odinmain.utils.render.RenderUtils.renderVec
import me.odinmain.utils.render.Renderer
import me.odinmain.utils.render.scale
import me.odinmain.utils.skyblock.*
import me.odinmain.utils.skyblock.dungeon.DungeonUtils
import me.odinmain.utils.skyblock.dungeon.DungeonUtils.getRealCoords
Expand All @@ -36,10 +33,13 @@ import net.minecraft.network.play.client.C03PacketPlayer.C06PacketPlayerPosLook
import net.minecraft.network.play.server.S08PacketPlayerPosLook
import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.BlockPos
import net.minecraft.util.MovingObjectPosition.MovingObjectType
import net.minecraft.util.Vec3
import net.minecraftforge.client.event.MouseEvent
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.sign

/**
* Custom Waypoints for Dungeons
Expand All @@ -52,8 +52,8 @@ object DungeonWaypoints : Module(
tag = TagType.NEW
) {
private var allowEdits by BooleanSetting("Allow Edits", false, description = "Allows you to edit waypoints.")
private var reachEdits by BooleanSetting("Reach Edits", false, description = "Extends the reach of edit mode.").withDependency { allowEdits }
private var reachColor by ColorSetting("Reach Color", default = Color(0, 255, 213, 0.43f), description = "Color of the reach box highlight.", allowAlpha = true).withDependency { reachEdits && allowEdits }
private var allowMidair by BooleanSetting("Allow Midair", default = false, description = "Allows waypoints to be placed midair if they reach the end of distance without hitting a block.").withDependency { allowEdits}
private var reachColor by ColorSetting("Reach Color", default = Color(0, 255, 213, 0.43f), description = "Color of the reach box highlight.", allowAlpha = true).withDependency { allowEdits }
private val allowTextEdit by BooleanSetting("Allow Text Edit", true, description = "Allows you to set the text of a waypoint while sneaking.")

var editText by BooleanSetting("Edit Text", false, description = "Displays text under your crosshair telling you when you are editing waypoints.")
Expand Down Expand Up @@ -83,6 +83,16 @@ object DungeonWaypoints : Module(
}
private val debugWaypoint by BooleanSetting("Debug Waypoint", false, description = "Shows a waypoint in the middle of every extra room.").withDependency { DevPlayers.isDev }

private val selectedColor get() = when (colorPallet) {
0 -> color
1 -> Color.CYAN
2 -> Color.MAGENTA
3 -> Color.YELLOW
4 -> Color.GREEN
5 -> Color.RED
else -> color
}

var glList = -1
var offset = BlockPos(0.0, 0.0, 0.0)

Expand Down Expand Up @@ -157,10 +167,13 @@ object DungeonWaypoints : Module(
if (!allowEdits) SecretWaypoints.onSecret(event)
}

private var reachPos: EtherWarpHelper.EtherPos? = null
var distance = 5.0
var lastEtherPos: EtherWarpHelper.EtherPos? = null
var lastEtherTime = 0L

private inline val reachPosition: BlockPos? get() =
mc.objectMouseOver?.takeUnless { it.typeOfHit == MovingObjectType.MISS || (distance <= 4.5 && allowMidair) }?.blockPos ?: EtherWarpHelper.getEtherPos(mc.thePlayer.renderVec, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, distance, allowMidair).pos

@SubscribeEvent
fun onRender(event: RenderWorldLastEvent) {
if ((DungeonUtils.inBoss || !DungeonUtils.inDungeons) && !LocationUtils.currentArea.isArea(Island.SinglePlayer)) return
Expand All @@ -181,26 +194,43 @@ object DungeonWaypoints : Module(
}
endProfile()

if (reachEdits && allowEdits) {
reachPos = EtherWarpHelper.getEtherPos(mc.thePlayer.renderVec, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch)
reachPos?.pos?.let {
if (useBlockSize) Renderer.drawStyledBlock(it, reachColor, style = if (filled) 0 else 1, 1, !throughWalls)
else Renderer.drawStyledBox(AxisAlignedBB(it.x + 0.5 - (size / 2), it.y + .5 - (size / 2), it.z + .5 - (size / 2), it.x + .5 + (size / 2), it.y + .5 + (size / 2), it.z + .5 + (size / 2)).outlineBounds(), reachColor, style = if (filled) 0 else 1, 1, !throughWalls)
}

reachPosition?.takeIf { allowEdits }?.let {
if (useBlockSize) Renderer.drawStyledBlock(it, reachColor, style = if (filled) 0 else 1, 1, !throughWalls)
else Renderer.drawStyledBox(AxisAlignedBB(it.x + 0.5, it.y + .5, it.z + .5, it.x + .5, it.y + .5, it.z + .5).outlineBounds(), reachColor, style = if (filled) 0 else 1, 1, !throughWalls)
}
}

@SubscribeEvent
fun onRenderOverlay(event: RenderGameOverlayEvent.Post) {
if (mc.currentScreen != null || event.type != RenderGameOverlayEvent.ElementType.ALL || !allowEdits || !editText) return
val sr = ScaledResolution(mc)
val stats = "type: ${WaypointType.getByInt(waypointType)}, filled: $filled, depth: $throughWalls"
val pos = reachPosition
val (text, editText) = pos?.add(offset)?.let {
val room = DungeonUtils.currentFullRoom ?: return
val vec = room.getRelativeCoords(it.add(offset).toVec3())
val waypoint = getWaypoints(room).find { it.toVec3().equal(vec) }

val text = waypoint?.let {"§fType: §5${waypoint.type?.displayName ?: "None"}${waypoint.timer?.let { "§7, §fTimer: §a${it.displayName}" } ?: ""}" }
?: "§fType: §5${WaypointType.getByInt(waypointType)?.displayName ?: "None"}§7, §r#${selectedColor.hex}§7, ${if (filled) "§2Filled" else "§3Outline"}§7, ${if (throughWalls) "§cThrough Walls§7, " else ""}${if (useBlockSize) "§2Block Size" else "§3Size: $size"}${TimerType.getType()?.let { "§7, §fTimer: §a${it.displayName}" } ?: ""}"


text to "§fEditing Waypoints §8|§f ${waypoint?.let { "Viewing" } ?: "Placing"}"
} ?: ("" to "Editing Waypoints")

scale(2f / sr.scaleFactor, 2f / sr.scaleFactor, 1f)
mc.fontRendererObj.drawString("Editing Waypoints", mc.displayWidth / 4 - mc.fontRendererObj.getStringWidth("Editing Waypoints") / 2, mc.displayHeight / 4 + 10, Color.WHITE.withAlpha(.5f).rgba)
mc.fontRendererObj.drawString(stats, mc.displayWidth / 4 - mc.fontRendererObj.getStringWidth(stats) / 2, mc.displayHeight / 4 + 20, Color.WHITE.withAlpha(.5f).rgba)
mcText(editText, mc.displayWidth / 4, mc.displayHeight / 4 + 10, 1f, Color.WHITE.withAlpha(.8f))
mcText(text,mc.displayWidth / 4, mc.displayHeight / 4 + 20, 1f, selectedColor)
scale(sr.scaleFactor / 2f, sr.scaleFactor / 2f, 1f)
}

@SubscribeEvent
fun onMouseInput(event: MouseEvent) {
if (!allowEdits || event.dwheel.sign == 0) return
distance = (distance + event.dwheel.sign).coerceIn(0.0, 100.0)
event.isCanceled = true
}

@SubscribeEvent
fun onInteract(event: ClickEvent.RightClickEvent) {
if (mc.thePlayer.usingEtherWarp) {
Expand All @@ -215,10 +245,10 @@ object DungeonWaypoints : Module(
}
}
if (!allowEdits) return
val pos = if (!reachEdits) mc.objectMouseOver?.blockPos ?: return else reachPos?.pos ?: return
val pos = reachPosition ?: return
val offsetPos = pos.add(offset)
offset = BlockPos(0.0, 0.0, 0.0)
if (isAir(offsetPos)) return
if (isAir(offsetPos) && !allowMidair) return
val room = DungeonUtils.currentFullRoom ?: return
val vec = room.getRelativeCoords(offsetPos.toVec3())
val block = getBlockAt(offsetPos)
Expand All @@ -231,20 +261,10 @@ object DungeonWaypoints : Module(
val type = WaypointType.getByInt(waypointType)
val timer = TimerType.getType()

val color = when (colorPallet) {
0 -> color
1 -> Color.CYAN
2 -> Color.MAGENTA
3 -> Color.YELLOW
4 -> Color.GREEN
5 -> Color.RED
else -> color
}

if (allowTextEdit && mc.thePlayer?.isSneaking == true) {
GuiSign.setCallback { enteredText ->
waypoints.removeIf { it.toVec3().equal(vec) }
waypoints.add(DungeonWaypoint(vec.xCoord, vec.yCoord, vec.zCoord, color.copy(), filled, !throughWalls, aabb, enteredText, type, timer))
waypoints.add(DungeonWaypoint(vec.xCoord, vec.yCoord, vec.zCoord, selectedColor.copy(), filled, !throughWalls, aabb, enteredText, type, timer))
DungeonWaypointConfig.saveConfig()
setWaypoints(room)
glList = -1
Expand All @@ -253,7 +273,7 @@ object DungeonWaypoints : Module(
} else if (waypoints.removeIf { it.toVec3().equal(vec) }) {
devMessage("Removed waypoint at $vec")
} else {
waypoints.add(DungeonWaypoint(vec.xCoord, vec.yCoord, vec.zCoord, color.copy(), filled, !throughWalls, aabb, type = type, timer = timer))
waypoints.add(DungeonWaypoint(vec.xCoord, vec.yCoord, vec.zCoord, selectedColor.copy(), filled, !throughWalls, aabb, type = type, timer = timer))
devMessage("Added waypoint at $vec")
}
DungeonWaypointConfig.saveConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ object SecretWaypoints {
}

fun resetSecrets() {
checkpoints = 0
routeTimer = null

DungeonWaypointConfig.waypoints.entries.forEach { (_, room) ->
room.forEach { it.clicked = false }
}
Expand Down
Loading

0 comments on commit 45f29d3

Please sign in to comment.