@@ -4,7 +4,6 @@ import baritone.api.pathing.goals.Goal
4
4
import baritone.api.pathing.goals.GoalNear
5
5
import com.lambda.client.event.SafeClientEvent
6
6
import com.lambda.client.event.events.BlockBreakEvent
7
- import com.lambda.client.event.events.PacketEvent
8
7
import com.lambda.client.event.events.RenderWorldEvent
9
8
import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket
10
9
import com.lambda.client.module.Category
@@ -23,10 +22,12 @@ import com.lambda.client.util.math.RotationUtils.getRotationTo
23
22
import com.lambda.client.util.math.VectorUtils
24
23
import com.lambda.client.util.math.VectorUtils.toVec3dCenter
25
24
import com.lambda.client.util.text.MessageSendHelper
26
- import com.lambda.client.util.threads.*
25
+ import com.lambda.client.util.threads.defaultScope
26
+ import com.lambda.client.util.threads.onMainThread
27
+ import com.lambda.client.util.threads.onMainThreadSafe
28
+ import com.lambda.client.util.threads.safeListener
27
29
import com.lambda.client.util.world.*
28
30
import com.lambda.commons.interfaces.DisplayEnum
29
- import com.lambda.event.listener.asyncListener
30
31
import com.lambda.event.listener.listener
31
32
import kotlinx.coroutines.delay
32
33
import kotlinx.coroutines.launch
@@ -43,10 +44,10 @@ import net.minecraft.init.Items
43
44
import net.minecraft.init.SoundEvents
44
45
import net.minecraft.inventory.ClickType
45
46
import net.minecraft.item.ItemShulkerBox
47
+ import net.minecraft.network.play.client.CPacketAnimation
46
48
import net.minecraft.network.play.client.CPacketEntityAction
47
49
import net.minecraft.network.play.client.CPacketPlayerDigging
48
50
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock
49
- import net.minecraft.network.play.server.SPacketBlockChange
50
51
import net.minecraft.util.EnumFacing
51
52
import net.minecraft.util.EnumHand
52
53
import net.minecraft.util.math.BlockPos
@@ -56,6 +57,7 @@ import net.minecraft.world.EnumDifficulty
56
57
import net.minecraftforge.fml.common.gameevent.TickEvent
57
58
import kotlin.math.ceil
58
59
60
+
59
61
object AutoObsidian : Module(
60
62
name = " AutoObsidian" ,
61
63
category = Category .MISC ,
@@ -66,8 +68,6 @@ object AutoObsidian : Module(
66
68
private val searchShulker by setting(" Search Shulker" , false )
67
69
private val leaveEmptyShulkers by setting(" Leave Empty Shulkers" , true , { searchShulker })
68
70
private val autoRefill by setting(" Auto Refill" , false , { fillMode != FillMode .INFINITE })
69
- private val instantMining by setting(" Instant Mining" , true )
70
- private val instantMiningDelay by setting(" Instant Mining Delay" , 10 , 1 .. 20 , 1 , { instantMining })
71
71
private val threshold by setting(" Refill Threshold" , 32 , 1 .. 64 , 1 , { autoRefill && fillMode != FillMode .INFINITE })
72
72
private val targetStacks by setting(" Target Stacks" , 1 , 1 .. 20 , 1 , { fillMode == FillMode .TARGET_STACKS })
73
73
private val delayTicks by setting(" Delay Ticks" , 4 , 1 .. 10 , 1 )
@@ -120,7 +120,6 @@ object AutoObsidian : Module(
120
120
private val rotateTimer = TickTimer (TimeUnit .TICKS )
121
121
private val shulkerOpenTimer = TickTimer (TimeUnit .TICKS )
122
122
private val miningTimer = TickTimer (TimeUnit .TICKS )
123
- private val miningTimeoutTimer = TickTimer (TimeUnit .SECONDS )
124
123
125
124
private val miningMap = HashMap <BlockPos , Pair <Int , Long >>() // <BlockPos, <Breaker ID, Last Update Time>>
126
125
@@ -145,30 +144,6 @@ object AutoObsidian : Module(
145
144
}
146
145
}
147
146
148
- asyncListener<PacketEvent .PostSend > {
149
- if (! instantMining || it.packet !is CPacketPlayerDigging ) return @asyncListener
150
-
151
- if (it.packet.position != placingPos || it.packet.facing != lastMiningSide) {
152
- canInstantMine = false
153
- }
154
- }
155
-
156
- safeAsyncListener<PacketEvent .Receive > {
157
- if (! instantMining || it.packet !is SPacketBlockChange ) return @safeAsyncListener
158
- if (it.packet.blockPosition != placingPos) return @safeAsyncListener
159
-
160
- val prevBlock = world.getBlockState(it.packet.blockPosition).block
161
- val newBlock = it.packet.blockState.block
162
-
163
- if (prevBlock != newBlock) {
164
- if (prevBlock != Blocks .AIR && newBlock == Blocks .AIR ) {
165
- canInstantMine = true
166
- }
167
- miningTimer.reset()
168
- miningTimeoutTimer.reset()
169
- }
170
- }
171
-
172
147
listener<RenderWorldEvent > {
173
148
if (state != State .DONE ) renderer.render(clear = false , cull = true )
174
149
}
@@ -585,34 +560,26 @@ object AutoObsidian : Module(
585
560
val center = pos.toVec3dCenter()
586
561
val diff = player.getPositionEyes(1.0f ).subtract(center)
587
562
val normalizedVec = diff.normalize()
588
- var side = EnumFacing .getFacingFromVector(normalizedVec.x.toFloat(), normalizedVec.y.toFloat(), normalizedVec.z.toFloat())
563
+ val blockState = world.getBlockState(pos)
564
+
565
+ val ticksNeeded = ceil((1 / (blockState.getPlayerRelativeBlockHardness(player, world, pos)))).toInt()
566
+ val side = EnumFacing .getFacingFromVector(normalizedVec.x.toFloat(), normalizedVec.y.toFloat(), normalizedVec.z.toFloat())
589
567
590
568
lastHitVec = center
591
569
rotateTimer.reset()
592
570
593
- if (instantMining && canInstantMine) {
594
- if (! miningTimer.tick(instantMiningDelay.toLong(), false )) return
595
-
596
- if (! miningTimeoutTimer.tick(2L , false )) {
597
- side = side.opposite
598
- } else {
599
- canInstantMine = false
600
- }
571
+ if (pre) {
572
+ connection.sendPacket(CPacketPlayerDigging (CPacketPlayerDigging .Action .START_DESTROY_BLOCK , pos, side))
573
+ if (state != State .SEARCHING ) state = State .MINING else searchingState = SearchingState .MINING
601
574
}
602
575
603
- defaultScope.launch {
604
- delay(20L )
605
- onMainThreadSafe {
606
- if (pre || miningTimeoutTimer.tick(8L )) {
607
- connection.sendPacket(CPacketPlayerDigging (CPacketPlayerDigging .Action .START_DESTROY_BLOCK , pos, side))
608
- if (state != State .SEARCHING ) state = State .MINING else searchingState = SearchingState .MINING
609
- } else {
610
- connection.sendPacket(CPacketPlayerDigging (CPacketPlayerDigging .Action .STOP_DESTROY_BLOCK , pos, side))
611
- }
612
- player.swingArm(EnumHand .MAIN_HAND )
613
- lastMiningSide = side
614
- }
576
+ if (miningTimer.tick(ticksNeeded, true )) {
577
+ connection.sendPacket(CPacketPlayerDigging (CPacketPlayerDigging .Action .STOP_DESTROY_BLOCK , pos, side))
615
578
}
579
+
580
+ connection.sendPacket(CPacketAnimation (EnumHand .MAIN_HAND ))
581
+ player.swingArm(EnumHand .MAIN_HAND )
582
+ lastMiningSide = side
616
583
}
617
584
618
585
/* *
0 commit comments