Compare commits

...

3 Commits

Author SHA1 Message Date
1eb2e5ee6c No idea what this is 2025-04-22 00:15:58 -06:00
b6c4223da5 Update build 2025-04-22 00:15:04 -06:00
e10f66a0c0 Try to get things working 2025-04-22 00:12:59 -06:00
3 changed files with 59 additions and 14 deletions

10
CHANGELOG.md Normal file
View File

@ -0,0 +1,10 @@
## [1.4.0] - 2024-07-23
### Chore
- Remove comments
### Feat
- *(chestesp)* Add initial implementation, halfway done

View File

@ -1,8 +1,8 @@
#Sun Apr 06 20:00:32 MDT 2025 #Sat Apr 19 14:54:37 MDT 2025
versionBase=1.5.0 versionBase=1.5.0
loom.platform=forge loom.platform=forge
baseGroup=com.github.itzilly.sbt baseGroup=com.github.itzilly.sbt
mcVersion=1.8.9 mcVersion=1.8.9
org.gradle.jvmargs=-Xmx2g org.gradle.jvmargs=-Xmx2g
buildNumber=106 buildNumber=107
modid=sbt modid=sbt

View File

@ -13,36 +13,71 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
object CaneMacroer { object CaneMacroer {
var isMacroToggled: Boolean = false var isMacroToggled: Boolean = false
val mc = Minecraft.getMinecraft() val mc = Minecraft.getMinecraft()
var activeKeys: MutableList<KeyBindingAccessor> = mutableListOf() val allowedScreens = listOf(GuiChat::class.java)
@SubscribeEvent @SubscribeEvent
fun onTick(event: ClientTickEvent) { fun onTick(event: ClientTickEvent) {
if (event.phase != TickEvent.Phase.END) return if (event.phase != TickEvent.Phase.END) return
if (!isMacroToggled) return if (!isMacroToggled) return
val canRunMacro = mc.currentScreen == null || mc.currentScreen is GuiChat val currentScreen = mc.currentScreen
if (!canRunMacro) {
isMacroToggled = false if (currentScreen != null && allowedScreens.none { it.isInstance(currentScreen) }) {
Chatterbox.say("Disabled macro!") Chatterbox.say("Macro stopped: Invalid screen")
stop() stop()
return
}
val mop = mc.objectMouseOver
if (mop == null || mop.typeOfHit?.name != "BLOCK") return
val blockPos = mop.blockPos
val facing = mop.sideHit
val player = mc.thePlayer
val blockCenter = blockPos.add(0.5, 0.5, 0.5)
val distanceSq = player.getDistanceSq(blockCenter.x.toDouble(), blockCenter.y.toDouble(), blockCenter.z.toDouble())
if (distanceSq > 25) {
Chatterbox.say("Macro stopped: Too far from block")
stop()
return
}
if (isEntityBlockingView()) {
Chatterbox.say("Macro stopped: Entity in the way")
stop()
return
} }
val myKey = mc.gameSettings.keyBindForward as KeyBindingAccessor
pressKey(mc.gameSettings.keyBindForward.keyCode) pressKey(mc.gameSettings.keyBindForward.keyCode)
mc.playerController.onPlayerDamageBlock(blockPos, facing)
player.swingItem()
} }
fun stop() { fun stop() {
KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.keyCode, false) KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.keyCode, false)
KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.keyCode, false) KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.keyCode, false)
isMacroToggled = false
} }
// private fun pressKey(key: KeyBindingAccessor) {
// key.setPressed(true)
// activeKeys.add(key)
// }
private fun pressKey(keyCode: Int) { private fun pressKey(keyCode: Int) {
KeyBinding.setKeyBindState(keyCode, true) KeyBinding.setKeyBindState(keyCode, true)
} }
private fun isEntityBlockingView(): Boolean {
val lookVec = mc.thePlayer.lookVec
val eyePos = mc.thePlayer.getPositionEyes(1f)
val entities = mc.theWorld.getEntitiesWithinAABBExcludingEntity(
mc.thePlayer,
mc.thePlayer.entityBoundingBox.expand(lookVec.xCoord * 5, lookVec.yCoord * 5, lookVec.zCoord * 5)
)
return entities.any {
it.canBeCollidedWith() &&
it.entityBoundingBox.isVecInside(eyePos)
}
}
} }