Compare commits
3 Commits
c3f5be60ed
...
1eb2e5ee6c
Author | SHA1 | Date | |
---|---|---|---|
1eb2e5ee6c | |||
b6c4223da5 | |||
e10f66a0c0 |
10
CHANGELOG.md
Normal file
10
CHANGELOG.md
Normal file
@ -0,0 +1,10 @@
|
||||
## [1.4.0] - 2024-07-23
|
||||
|
||||
### Chore
|
||||
|
||||
- Remove comments
|
||||
|
||||
### Feat
|
||||
|
||||
- *(chestesp)* Add initial implementation, halfway done
|
||||
|
@ -1,8 +1,8 @@
|
||||
#Sun Apr 06 20:00:32 MDT 2025
|
||||
#Sat Apr 19 14:54:37 MDT 2025
|
||||
versionBase=1.5.0
|
||||
loom.platform=forge
|
||||
baseGroup=com.github.itzilly.sbt
|
||||
mcVersion=1.8.9
|
||||
org.gradle.jvmargs=-Xmx2g
|
||||
buildNumber=106
|
||||
buildNumber=107
|
||||
modid=sbt
|
||||
|
@ -13,36 +13,71 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
|
||||
object CaneMacroer {
|
||||
var isMacroToggled: Boolean = false
|
||||
val mc = Minecraft.getMinecraft()
|
||||
var activeKeys: MutableList<KeyBindingAccessor> = mutableListOf()
|
||||
val allowedScreens = listOf(GuiChat::class.java)
|
||||
|
||||
@SubscribeEvent
|
||||
fun onTick(event: ClientTickEvent) {
|
||||
if (event.phase != TickEvent.Phase.END) return
|
||||
|
||||
if (!isMacroToggled) return
|
||||
|
||||
val canRunMacro = mc.currentScreen == null || mc.currentScreen is GuiChat
|
||||
if (!canRunMacro) {
|
||||
isMacroToggled = false
|
||||
Chatterbox.say("Disabled macro!")
|
||||
val currentScreen = mc.currentScreen
|
||||
|
||||
if (currentScreen != null && allowedScreens.none { it.isInstance(currentScreen) }) {
|
||||
Chatterbox.say("Macro stopped: Invalid screen")
|
||||
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)
|
||||
mc.playerController.onPlayerDamageBlock(blockPos, facing)
|
||||
player.swingItem()
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.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) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user