Skip to content

Commit d8de058

Browse files
committed
fluid check to prevent placing when not necessary
1 parent 98561c2 commit d8de058

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import com.lambda.threading.runSafe
5858
import com.lambda.util.BlockUtils
5959
import com.lambda.util.BlockUtils.blockState
6060
import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta
61+
import com.lambda.util.BlockUtils.hasFluid
6162
import com.lambda.util.BlockUtils.instantBreakable
6263
import com.lambda.util.BlockUtils.isEmpty
6364
import com.lambda.util.BlockUtils.isNotEmpty
@@ -345,7 +346,8 @@ object BuildSimulator {
345346
val statePromoting = currentState.block is SlabBlock && targetState.matches(currentState, pos, world, preProcessing.ignore)
346347
// If the target state is air then the only possible blocks it could place are to remove liquids so we use the Solid TargetState
347348
val nextTargetState = if (targetState is TargetState.Air) {
348-
TargetState.Solid
349+
if (currentState.hasFluid) TargetState.Solid
350+
else return acc
349351
} else if (targetState.isEmpty()) {
350352
// Otherwise if the target state is empty, there's no situation where placement would be required so we can return
351353
return acc

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ object BlockUtils {
313313

314314
val BlockState.isEmpty get() = matches(emptyState)
315315
val BlockState.isNotEmpty get() = !isEmpty
316+
val BlockState.hasFluid get() = !fluidState.isEmpty
316317
val BlockState.emptyState: BlockState get() = fluidState.blockState
317318
fun isBroken(oldState: BlockState, newState: BlockState) = oldState.isNotEmpty && oldState.emptyState.matches(newState)
318319
fun isNotBroken(oldState: BlockState, newState: BlockState) = !isBroken(oldState, newState)

0 commit comments

Comments
 (0)