Skip to content

Commit 6d40644

Browse files
committed
use isEmpty over isAir to account for waterloggable blocks
1 parent 52428ee commit 6d40644

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ import com.lambda.interaction.request.breaking.BreakManager.activeRequest
3737
import com.lambda.interaction.request.breaking.BreakManager.processRequest
3838
import com.lambda.interaction.request.breaking.BreakType.Primary
3939
import com.lambda.interaction.request.breaking.BreakType.ReBreak
40-
import com.lambda.interaction.request.breaking.BrokenBlockHandler.brokenState
4140
import com.lambda.interaction.request.breaking.BrokenBlockHandler.destroyBlock
42-
import com.lambda.interaction.request.breaking.BrokenBlockHandler.isBroken
4341
import com.lambda.interaction.request.breaking.BrokenBlockHandler.pendingBreaks
4442
import com.lambda.interaction.request.breaking.BrokenBlockHandler.setPendingConfigs
4543
import com.lambda.interaction.request.breaking.BrokenBlockHandler.startPending
4644
import com.lambda.interaction.request.placing.PlaceManager
4745
import com.lambda.interaction.request.rotation.RotationRequest
4846
import com.lambda.threading.runSafe
4947
import com.lambda.util.BlockUtils.blockState
48+
import com.lambda.util.BlockUtils.brokenState
5049
import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta
50+
import com.lambda.util.BlockUtils.isBroken
51+
import com.lambda.util.BlockUtils.isEmpty
5152
import com.lambda.util.Communication.warn
5253
import com.lambda.util.item.ItemUtils.block
5354
import com.lambda.util.player.gamemode
@@ -309,7 +310,7 @@ object BreakManager : RequestHandler<BreakRequest>(
309310
}
310311
}
311312

312-
return !blockState(ctx.expectedPos).isAir
313+
return !blockState(ctx.expectedPos).isEmpty
313314
}
314315

315316
/**
@@ -553,7 +554,7 @@ object BreakManager : RequestHandler<BreakRequest>(
553554
}
554555

555556
val blockState = blockState(ctx.expectedPos)
556-
if (blockState.isAir) {
557+
if (blockState.isEmpty) {
557558
info.nullify()
558559
info.internalOnCancel()
559560
return false
@@ -644,13 +645,13 @@ object BreakManager : RequestHandler<BreakRequest>(
644645
lastPosStarted = ctx.expectedPos
645646

646647
val blockState = blockState(ctx.expectedPos)
647-
val notAir = !blockState.isAir
648-
if (notAir && info.breakingTicks == 0) {
648+
val notEmpty = !blockState.isEmpty
649+
if (notEmpty && info.breakingTicks == 0) {
649650
blockState.onBlockBreakStart(world, ctx.expectedPos, player)
650651
}
651652

652653
val breakDelta = blockState.calcBlockBreakingDelta(player, world, ctx.expectedPos)
653-
if (notAir && breakDelta >= info.getBreakThreshold()) {
654+
if (notEmpty && breakDelta >= info.getBreakThreshold()) {
654655
onBlockBreak(info)
655656
} else {
656657
info.apply {

common/src/main/kotlin/com/lambda/interaction/request/breaking/BrokenBlockHandler.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ import com.lambda.interaction.request.breaking.BreakManager.lastPosStarted
2929
import com.lambda.interaction.request.breaking.BreakManager.matchesBlockItem
3030
import com.lambda.interaction.request.breaking.ReBreakManager.reBreak
3131
import com.lambda.module.modules.client.TaskFlowModule
32+
import com.lambda.util.BlockUtils.brokenState
3233
import com.lambda.util.BlockUtils.fluidState
34+
import com.lambda.util.BlockUtils.isBroken
3335
import com.lambda.util.BlockUtils.matches
3436
import com.lambda.util.Communication.info
3537
import com.lambda.util.Communication.warn
@@ -184,8 +186,4 @@ object BrokenBlockHandler {
184186

185187
return setState
186188
}
187-
188-
val BlockState.isEmpty get() = matches(fluidState.blockState)
189-
val BlockState.brokenState: BlockState get() = fluidState.blockState
190-
fun isBroken(oldState: BlockState, newState: BlockState) = !oldState.isEmpty && oldState.brokenState.matches(newState)
191189
}

common/src/main/kotlin/com/lambda/interaction/request/breaking/ReBreakManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import com.lambda.event.listener.SafeListener.Companion.listen
2323
import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe
2424
import com.lambda.interaction.construction.context.BreakContext
2525
import com.lambda.interaction.request.breaking.BrokenBlockHandler.destroyBlock
26-
import com.lambda.interaction.request.breaking.BrokenBlockHandler.isEmpty
2726
import com.lambda.threading.runSafe
27+
import com.lambda.util.BlockUtils.isEmpty
2828
import com.lambda.util.player.swingHand
2929
import net.minecraft.util.Hand
3030

common/src/main/kotlin/com/lambda/util/BlockUtils.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,8 @@ object BlockUtils {
309309

310310
return speedMultiplier
311311
}
312+
313+
val BlockState.isEmpty get() = matches(fluidState.blockState)
314+
val BlockState.brokenState: BlockState get() = fluidState.blockState
315+
fun isBroken(oldState: BlockState, newState: BlockState) = !oldState.isEmpty && oldState.brokenState.matches(newState)
312316
}

0 commit comments

Comments
 (0)