Skip to content

Commit b3e21a4

Browse files
committed
Smarter falling block break
1 parent 9b18907 commit b3e21a4

File tree

1 file changed

+6
-2
lines changed
  • common/src/main/kotlin/com/lambda/interaction/construction/context

1 file changed

+6
-2
lines changed

common/src/main/kotlin/com/lambda/interaction/construction/context/BreakContext.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import com.lambda.interaction.construction.verify.TargetState
2525
import com.lambda.interaction.request.rotation.RotationRequest
2626
import com.lambda.util.world.raycast.RayCastUtils.distanceTo
2727
import net.minecraft.block.BlockState
28+
import net.minecraft.block.Blocks
29+
import net.minecraft.block.FallingBlock
2830
import net.minecraft.client.network.ClientPlayerInteractionManager
2931
import net.minecraft.client.world.ClientWorld
3032
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket
@@ -56,14 +58,16 @@ data class BreakContext(
5658

5759
fun exposedSides(ctx: SafeContext) =
5860
Direction.entries.filter {
59-
ctx.world.isAir(result.blockPos.offset(it))
61+
ctx.world.isAir(expectedPos.offset(it))
6062
}
6163

6264
override val expectedState: BlockState = checkedState.fluidState.blockState
6365

6466
override fun compareTo(other: BuildContext): Int {
6567
return when (other) {
66-
is BreakContext -> compareBy<BreakContext> {
68+
is BreakContext -> compareByDescending<BreakContext> {
69+
if (it.checkedState.block is FallingBlock) it.expectedPos.y else 0
70+
}.thenBy {
6771
it.rotation.target.angleDistance
6872
}.compare(this, other)
6973

0 commit comments

Comments
 (0)