@@ -8,11 +8,9 @@ import com.lambda.event.listener.SafeListener.Companion.listener
88import com.lambda.interaction.InteractionConfig
99import com.lambda.interaction.construction.context.BreakContext
1010import com.lambda.interaction.rotation.IRotationConfig
11- import com.lambda.interaction.visibilty.VisibilityChecker.getVisibleSurfaces
1211import com.lambda.interaction.visibilty.VisibilityChecker.lookAtBlock
1312import com.lambda.module.modules.client.TaskFlow
1413import com.lambda.task.Task
15- import com.lambda.util.BlockUtils.instantBreakable
1614import com.lambda.util.BlockUtils.blockState
1715import com.lambda.util.world.raycast.RayCastUtils.blockResult
1816import net.minecraft.block.BlockState
@@ -26,12 +24,13 @@ class BreakBlock @Ta5kBuilder constructor(
2624 private val interactionConfig : InteractionConfig = TaskFlow .interactionSettings,
2725 private val sides : Set <Direction > = emptySet(),
2826 private val collectDrop : Boolean = false ,
29- private val noRotationForInstant : Boolean = true ,
27+ private val dontRotate : Boolean = true ,
28+ private val swingHand : Boolean = true ,
29+ private val particles : Boolean = true ,
3030) : Task<ItemEntity?>() {
3131 val blockPos: BlockPos get() = ctx.result.blockPos
3232 private var beginState: BlockState ? = null
3333 val SafeContext .state: BlockState get() = blockPos.blockState(world)
34- val SafeContext .instant: Boolean get() = instantBreakable(state, blockPos) && noRotationForInstant
3534
3635 override fun SafeContext.onStart () {
3736 if (state.isAir && ! collectDrop) {
@@ -43,12 +42,12 @@ class BreakBlock @Ta5kBuilder constructor(
4342
4443 init {
4544 listener<RotationEvent .Pre > { event ->
46- if (instant ) return @listener
45+ if (dontRotate ) return @listener
4746 event.context = lookAtBlock(blockPos, rotationConfig, interactionConfig, sides)
4847 }
4948
5049 listener<RotationEvent .Post > {
51- if (instant ) return @listener
50+ if (dontRotate ) return @listener
5251 if (! it.context.isValid) return @listener
5352 val hitResult = it.context.hitResult?.blockResult ? : return @listener
5453
@@ -61,18 +60,9 @@ class BreakBlock @Ta5kBuilder constructor(
6160 return @listener
6261 }
6362
64- if (! instant ) return @listener
63+ if (! dontRotate ) return @listener
6564
66- val shape = state.getOutlineShape(world, blockPos)
67- if (shape.isEmpty) {
68- failure(" ${blockPos.toShortString()} in state $state has no outline shape" )
69- return @listener
70- }
71-
72- shape.boundingBox
73- .getVisibleSurfaces(player.eyePos).firstOrNull()?.let { side ->
74- breakBlock(side)
75- }
65+ breakBlock(ctx.result.side)
7666 }
7767
7868 listener<TickEvent .Post > {
@@ -89,10 +79,8 @@ class BreakBlock @Ta5kBuilder constructor(
8979
9080 private fun SafeContext.breakBlock (side : Direction ) {
9181 if (interaction.updateBlockBreakingProgress(blockPos, side)) {
92- mc.particleManager.addBlockBreakingParticles(blockPos, side)
93- if (! instant) {
94- player.swingHand(ctx.hand)
95- }
82+ if (particles) mc.particleManager.addBlockBreakingParticles(blockPos, side)
83+ if (swingHand) player.swingHand(ctx.hand)
9684 }
9785 }
9886
0 commit comments