Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
odtheking committed Dec 7, 2024
1 parent f62a33e commit 5c3d22d
Show file tree
Hide file tree
Showing 33 changed files with 309 additions and 458 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,33 @@ private void drawHud(float partialTicks, long nanoTime, CallbackInfo ci) {

@Redirect(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;setAngles(FF)V"))
private void lockPlayerLooking(EntityPlayerSP instance, float x, float y) {
if (!Camera.INSTANCE.getFreelookToggled()) instance.setAngles(x, y);
if (!Camera.getFreelookToggled()) instance.setAngles(x, y);
}

@Inject(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;setAngles(FF)V", ordinal = 1), locals = LocalCapture.CAPTURE_FAILSOFT)
private void updateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci, boolean flag, float f, float f1, float f2, float f3) {
if (Camera.INSTANCE.getEnabled()) Camera.INSTANCE.updateCameraAndRender(f2, f3);
if (Camera.INSTANCE.getEnabled()) Camera.updateCameraAndRender(f2, f3);
}

@Shadow private Minecraft mc;

@Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V", ordinal = 2))
public void orientCamera(float x, float y, float z, float partialTicks){
if (Camera.INSTANCE.getFreelookToggled()) {
GlStateManager.translate(
0.0F, 0.0F, -Camera.INSTANCE.calculateCameraDistance(
RenderUtils.INSTANCE.getRenderX(mc.thePlayer),
RenderUtils.INSTANCE.getRenderY(mc.thePlayer) + VecUtilsKt.fastEyeHeight(),
RenderUtils.INSTANCE.getRenderZ(mc.thePlayer),
Camera.INSTANCE.getCameraDistance())
);
} else GlStateManager.translate(x, y, z);
if (Camera.getFreelookToggled()) GlStateManager.translate(0.0F, 0.0F, -Camera.calculateCameraDistance());
else GlStateManager.translate(x, y, z);
}

@Redirect(method = {"orientCamera"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistance:F"))
public float tweakThirdPersonDistance(EntityRenderer instance) {
return Camera.INSTANCE.getCameraDistance();
return Camera.getCameraDistance();
}

@Redirect(method = {"orientCamera"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistanceTemp:F"))
public float tweakThirdPersonDistanceTemp(EntityRenderer instance) {
return Camera.INSTANCE.getCameraDistance();
return Camera.getCameraDistance();
}

@ModifyConstant(method = "orientCamera", constant = @Constant(intValue = 8))
public int cameraClip(int constant) {
return Camera.INSTANCE.getCameraClipEnabled() ? 0: constant;
return Camera.getCameraClipEnabled() ? 0: constant;
}

@Inject(method = "hurtCameraEffect", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import me.odinmain.features.settings.impl.BooleanSetting
import me.odinmain.features.settings.impl.DropdownSetting
import me.odinmain.features.settings.impl.KeybindSetting
import me.odinmain.features.settings.impl.NumberSetting
import me.odinmain.utils.getPositionEyes
import net.minecraft.util.MathHelper
import net.minecraft.util.Vec3
import net.minecraftforge.client.event.EntityViewRenderEvent
Expand All @@ -33,6 +34,7 @@ object Camera : Module(
if (!freelookToggled && enabled) enable()
else if ((toggle || !enabled) && freelookToggled) disable()
}
@JvmStatic
var freelookToggled = false
private var cameraYaw = 0f
private var cameraPitch = 0f
Expand All @@ -50,10 +52,12 @@ object Camera : Module(
super.onDisable()
}

@JvmStatic
fun getCameraDistance(): Float {
return if (enabled) cameraDist else 4f
}

@JvmStatic
fun getCameraClipEnabled(): Boolean {
return if (enabled) cameraClip else false
}
Expand Down Expand Up @@ -90,14 +94,17 @@ object Camera : Module(
e.pitch = cameraPitch
}

@JvmStatic
fun updateCameraAndRender(f2: Float, f3: Float) {
if (!freelookToggled) return
cameraYaw += f2 / 7
cameraPitch = MathHelper.clamp_float((cameraPitch + f3 / 7), -90f, 90f)
}

fun calculateCameraDistance(d0: Double, d1: Double, d2: Double, d3: Double): Float {
var dist = d3
@JvmStatic
fun calculateCameraDistance(): Float {
val eyes = getPositionEyes()
var dist = getCameraDistance()
var f2 = cameraPitch

if (mc.gameSettings.thirdPersonView == 2) f2 += 180.0f
Expand All @@ -106,26 +113,23 @@ object Camera : Module(
val d5 = (-cos(cameraYaw / 180.0f * Math.PI.toFloat()) * cos(f2 / 180.0f * Math.PI.toFloat())).toDouble() * dist
val d6 = (-sin(f2 / 180.0f * Math.PI.toFloat())).toDouble() * dist

for (i in 0..7) {
var f3 = ((i and 1) * 2 - 1).toFloat()
var f4 = ((i shr 1 and 1) * 2 - 1).toFloat()
var f5 = ((i shr 2 and 1) * 2 - 1).toFloat()
repeat(8) {
var f3 = ((it and 1) * 2 - 1).toFloat()
var f4 = ((it shr 1 and 1) * 2 - 1).toFloat()
var f5 = ((it shr 2 and 1) * 2 - 1).toFloat()
f3 *= .1f
f4 *= .1f
f5 *= .1f
val movingObjectPosition = mc.theWorld?.rayTraceBlocks(
Vec3(d0 + f3.toDouble(), d1 + f4.toDouble(), d2 + f5.toDouble()),
Vec3(d0 - d4 + f3.toDouble() + f5.toDouble(), d1 - d6 + f4.toDouble(), d2 - d5 + f5.toDouble())
Vec3(eyes.xCoord + f3.toDouble(), eyes.yCoord + f4.toDouble(), eyes.zCoord + f5.toDouble()),
Vec3(eyes.xCoord - d4 + f3.toDouble() + f5.toDouble(), eyes.yCoord - d6 + f4.toDouble(), eyes.zCoord - d5 + f5.toDouble())
)

if (movingObjectPosition != null) {
val d7 = movingObjectPosition.hitVec.distanceTo(Vec3(d0, d1, d2))

if (d7 < dist) {
dist = d7
}
val d7 = movingObjectPosition.hitVec.distanceTo(Vec3(eyes.xCoord, eyes.yCoord, eyes.zCoord))
if (d7 < dist) dist = d7.toFloat()
}
}
return dist.toFloat()
return dist
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ object AutoHarp : Module(
val newHash = container.inventorySlots.subList(0,36).joinToString("") { it?.stack?.displayName ?: "" }.hashCode()
if (lastInv == newHash) return
lastInv = newHash
for (i in 0..6) {
val slot = container.inventorySlots[37 + i]
repeat(7) {
val slot = container.inventorySlots[37 + it]
if ((slot.stack?.item as? ItemBlock)?.block === Blocks.quartz_block) {
PlayerUtils.windowClick(slot.slotNumber, PlayerUtils.ClickType.Middle)
break
return
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ object ChocolateFactory : Module(
}
found = false
var maxValue = 0
for (i in 0 until 7) {
val worker = workers[i]
if (worker.contains("climbed as far")) continue
val index = worker.indexOfFirst { it?.contains("Cost") == true }.takeIf { it != -1 } ?: continue
val cost = worker[index + 1]?.noControlCodes?.replace(Regex("\\D"), "")?.toIntOrNull() ?: continue
val value = cost / (i + 1).toFloat()
repeat (7) {
val worker = workers[it]
if (worker.contains("climbed as far")) return
val index = worker.indexOfFirst { it?.contains("Cost") == true } ?: return
val cost = worker[index + 1]?.noControlCodes?.replace(Regex("\\D"), "")?.toIntOrNull() ?: return
val value = cost / (it + 1).toFloat()
if (value < maxValue || !found) {
bestWorker = 28 + i
bestWorker = 28 + it
maxValue = value.toInt()
bestCost = cost
found = true
Expand Down
25 changes: 10 additions & 15 deletions src/main/kotlin/me/odinmain/features/impl/dungeon/BloodCamp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ object BloodCamp : Module(

@SubscribeEvent
fun onRenderBossHealth(event: RenderGameOverlayEvent.Pre) {
if (!inDungeons || inBoss || event.type != RenderGameOverlayEvent.ElementType.BOSSHEALTH
|| !watcherBar || BossStatus.bossName.noControlCodes != "The Watcher") return
if (!watcherBar || !inDungeons || inBoss || event.type != RenderGameOverlayEvent.ElementType.BOSSHEALTH || BossStatus.bossName.noControlCodes != "The Watcher") return
val amount = 12 + DungeonUtils.floor.floorNumber
BossStatus.bossName += BossStatus.healthScale.takeIf { it >= 0.05 }?.let { " ${(amount * it).roundToInt()}/$amount" } ?: ""
}
Expand Down Expand Up @@ -108,8 +107,7 @@ object BloodCamp : Module(

private fun onPacketLookMove(packet: S17PacketEntityLookMove) {
val entity = packet.getEntity(mc.theWorld ?: return) as? EntityArmorStand ?: return
if (currentWatcherEntity?.let { it.getDistanceToEntity(entity) <= 20 } != true ||
entity.getEquipmentInSlot(4)?.item != Items.skull || getSkullValue(entity) !in allowedMobSkulls) return
if (currentWatcherEntity?.let { it.getDistanceToEntity(entity) <= 20 } != true || entity.getEquipmentInSlot(4)?.item != Items.skull || getSkullValue(entity) !in allowedMobSkulls) return

val packetVector = Vec3(
(entity.serverPosX + packet.func_149062_c()) / 32.0,
Expand All @@ -121,16 +119,14 @@ object BloodCamp : Module(
val data = entityDataMap[entity] ?: return

val timeTook = currentTickTime - data.started
val startVector = data.startVector
val time = getTime(data.firstSpawns, timeTook)

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

val time = getTime(data.firstSpawns, timeTook)

val endpoint = Vec3(
packetVector.xCoord + speedVectors.xCoord * time,
packetVector.yCoord + speedVectors.yCoord * time,
Expand Down Expand Up @@ -158,9 +154,7 @@ object BloodCamp : Module(
val (_, started, firstSpawn) = entityDataMap[entity]?.takeUnless { entity.isDead } ?: return@forEach

val (currVector, endVector, endVecUpdated, speedVectors) = renderData
val endVectorUpdated = min(currentTickTime - endVecUpdated, 100)

val endPoint = calcEndVector(endVector, renderData.lastEndVector, endVectorUpdated / 100f)
val endPoint = calcEndVector(endVector, renderData.lastEndVector, min(currentTickTime - endVecUpdated, 100) / 100f)

val pingPoint = Vec3(
entity.posX + speedVectors.xCoord * averagePing,
Expand Down Expand Up @@ -199,13 +193,14 @@ object BloodCamp : Module(
private fun getTime(firstSpawn: Boolean, timeTook: Long) = (if (firstSpawn) 2000 else 0) + (tick * 50) - timeTook + offset

private fun calcEndVector(currVector: Vec3, lastVector: Vec3?, multiplier: Float, skip: Boolean = false): Vec3 {
return if (lastVector != null && !skip) {
return if (lastVector == null || skip) currVector
else {
Vec3(
lastVector.xCoord + (currVector.xCoord - lastVector.xCoord) * multiplier,
lastVector.yCoord + (currVector.yCoord - lastVector.yCoord) * multiplier,
lastVector.zCoord + (currVector.zCoord - lastVector.zCoord) * multiplier
)
} else currVector
}
}

@SubscribeEvent
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/me/odinmain/features/impl/dungeon/Mimic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object Mimic : Module(
private val color by ColorSetting("Color", Color.RED.withAlpha(0.5f), allowAlpha = true, description = "The color of the box.").withDependency { mimicBox }
private val lineWidth by NumberSetting("Line Width", 2f, 0.1f, 10f, 0.1f, description = "The width of the box's lines.").withDependency { mimicBox }

private const val MIMIC_TEXTURE ="eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTE5YzEyNTQzYmM3NzkyNjA1ZWY2OGUxZjg3NDlhZThmMmEzODFkOTA4NWQ0ZDRiNzgwYmExMjgyZDM1OTdhMCJ9fX0K"
private const val MIMIC_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTE5YzEyNTQzYmM3NzkyNjA1ZWY2OGUxZjg3NDlhZThmMmEzODFkOTA4NWQ0ZDRiNzgwYmExMjgyZDM1OTdhMCJ9fX0K"

@SubscribeEvent
fun onEntityLeaveWorld(event: EntityLeaveWorldEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ object TerracottaTimer : Module(

@SubscribeEvent
fun onBlockPacket(event: BlockChangeEvent) {
if (!DungeonUtils.isFloor(6) || !DungeonUtils.inBoss || !event.update.block.isFlowerPot || terracottaSpawning.any { it.pos.equal(event.pos.toVec3().addVec(0.5, 1.5, 0.5)) }) return
terracottaSpawning.add(Terracotta(event.pos.toVec3().addVec(0.5, 1.5, 0.5), if (DungeonUtils.floor.isMM) 12.0 else 15.0))
if (DungeonUtils.isFloor(6) && DungeonUtils.inBoss && event.update.block.isFlowerPot && !terracottaSpawning.any { it.pos.equal(event.pos.toVec3().addVec(0.5, 1.5, 0.5)) })
terracottaSpawning.add(Terracotta(event.pos.toVec3().addVec(0.5, 1.5, 0.5), if (DungeonUtils.floor.isMM) 12.0 else 15.0))
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.google.gson.reflect.TypeToken
import me.odinmain.OdinMain.logger
import me.odinmain.events.impl.BlockChangeEvent
import me.odinmain.events.impl.RoomEnterEvent
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.beamsAlpha
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.onPuzzleComplete
import me.odinmain.ui.clickgui.util.ColorUtil.withAlpha
import me.odinmain.utils.addVec
Expand Down Expand Up @@ -55,16 +54,16 @@ object BeamsSolver {
}
}

fun onRenderWorld() {
fun onRenderWorld(beamStyle: Int, beamsTracer: Boolean, beamsAlpha: Float) {
if (DungeonUtils.currentRoomName != "Creeper Beams" || currentLanternPairs.isEmpty()) return

currentLanternPairs.entries.forEach { positions ->
val color = positions.value.second

Renderer.drawStyledBox(positions.key.toAABB(), color, depth = true, style = PuzzleSolvers.beamStyle)
Renderer.drawStyledBox(positions.value.first.toAABB(), color, depth = true, style = PuzzleSolvers.beamStyle)
Renderer.drawStyledBlock(positions.key, color, depth = true, style = beamStyle)
Renderer.drawStyledBlock(positions.value.first, color, depth = true, style = beamStyle)

if (PuzzleSolvers.beamsTracer)
if (beamsTracer)
Renderer.draw3DLine(listOf(positions.key.toVec3().addVec(0.5, 0.5, 0.5), positions.value.first.toVec3().addVec(0.5, 0.5, 0.5)), color = color.withAlpha(beamsAlpha), depth = false, lineWidth = 2f)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package me.odinmain.features.impl.dungeon.puzzlesolvers

import me.odinmain.OdinMain.mc
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.blazeHeight
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.blazeWidth
import me.odinmain.features.impl.dungeon.puzzlesolvers.PuzzleSolvers.onPuzzleComplete
import me.odinmain.utils.*
import me.odinmain.utils.render.Color
import me.odinmain.utils.render.RenderUtils.renderBoundingBox
import me.odinmain.utils.render.RenderUtils.renderVec
import me.odinmain.utils.render.Renderer
Expand Down Expand Up @@ -35,33 +34,29 @@ object BlazeSolver {
else blazes.sortBy { hpMap[it] }
}

fun onRenderWorld() {
fun onRenderWorld(blazeLineNext: Boolean, blazeLineAmount: Int, blazeStyle: Int, blazeFirstColor: Color, blazeSecondColor: Color, blazeAllColor: Color, blazeWidth: Float, blazeHeight: Float, blazeSendComplete: Boolean) {
if (!DungeonUtils.currentRoomName.equalsOneOf("Lower Blaze", "Higher Blaze")) return
if (blazes.isEmpty()) return
blazes.removeAll {
mc.theWorld?.getEntityByID(it.entityId) == null
}
blazes.removeAll { mc.theWorld?.getEntityByID(it.entityId) == null }
if (blazes.isEmpty() && lastBlazeCount == 1) {
LocationUtils.currentDungeon?.puzzles?.find { it.name == Puzzle.Blaze.name }?.status = PuzzleStatus.Completed
if (PuzzleSolvers.blazeSendComplete) partyMessage("Blaze puzzle solved!")
onPuzzleComplete("Higher Blaze")
onPuzzleComplete("Lower Blaze")
if (blazeSendComplete) partyMessage("Blaze puzzle solved!")
onPuzzleComplete(if (DungeonUtils.currentRoomName == "Higher Blaze") "Higher Blaze" else "Lower Blaze")
lastBlazeCount = 0
return
}
lastBlazeCount = blazes.size
blazes.forEachIndexed { index, entity ->
val color = when (index) {
0 -> PuzzleSolvers.blazeFirstColor
1 -> PuzzleSolvers.blazeSecondColor
else -> PuzzleSolvers.blazeAllColor
0 -> blazeFirstColor
1 -> blazeSecondColor
else -> blazeAllColor
}
val aabb = AxisAlignedBB(-blazeWidth / 2, -1 - (blazeHeight / 2), -blazeWidth / 2, blazeWidth / 2, (blazeHeight / 2) - 1, blazeWidth / 2).offset(entity.positionVector)
val aabb = AxisAlignedBB(-blazeWidth / 2.0, -1 - (blazeHeight / 2.0), -blazeWidth / 2.0, blazeWidth / 2.0, (blazeHeight / 2.0) - 1, blazeWidth / 2.0).offset(entity.positionVector)

Renderer.drawBox(aabb, color,
outlineAlpha = if (PuzzleSolvers.blazeStyle == 0) 0 else color.alpha, fillAlpha = if (PuzzleSolvers.blazeStyle == 1) 0 else color.alpha, depth = true)
Renderer.drawStyledBox(aabb, color, blazeStyle, depth = true)

if (PuzzleSolvers.blazeLineNext && index > 0 && index <= PuzzleSolvers.blazeLineAmount)
if (blazeLineNext && index > 0 && index <= blazeLineAmount)
Renderer.draw3DLine(listOf(blazes[index - 1].renderVec, entity.renderBoundingBox.middle), color = color, lineWidth = 1f, depth = true)
}
}
Expand Down
Loading

0 comments on commit 5c3d22d

Please sign in to comment.