Skip to content

Commit 6ff5083

Browse files
committed
Ignore unobtainable block properties
1 parent 94efb70 commit 6ff5083

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

common/src/main/kotlin/com/lambda/interaction/construction/result/PlaceResult.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ sealed class PlaceResult : BuildResult() {
6262
data class NoIntegrity(
6363
override val blockPos: BlockPos,
6464
val expected: BlockState,
65-
val simulated: ItemPlacementContext
65+
val simulated: ItemPlacementContext,
66+
val actual: BlockState? = null
6667
) : Drawable, PlaceResult() {
6768
override val rank = Rank.PLACE_NO_INTEGRITY
6869
private val color = Color(252, 3, 3, 100)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object BuildSimulator {
9494
}
9595

9696
/* block is unbreakable, so it cant be broken or replaced */
97-
if (state.getHardness(world, pos) < 0) {
97+
if (state.getHardness(world, pos) < 0 && !player.isCreative) {
9898
return BuildResult.Unbreakable(pos, state)
9999
}
100100

@@ -222,7 +222,9 @@ object BuildSimulator {
222222
}
223223

224224
if (!target.matches(resultState, pos, world)) {
225-
acc.add(PlaceResult.NoIntegrity(pos, resultState, context))
225+
acc.add(PlaceResult.NoIntegrity(
226+
pos, resultState, context, (target as? TargetState.State)?.blockState)
227+
)
226228
return@forEach
227229
}
228230

common/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import net.minecraft.block.BlockState
88
import net.minecraft.client.world.ClientWorld
99
import net.minecraft.item.ItemStack
1010
import net.minecraft.item.Items
11+
import net.minecraft.state.property.Properties
1112
import net.minecraft.util.math.BlockPos
1213
import net.minecraft.util.math.Direction
1314

@@ -46,7 +47,9 @@ sealed class TargetState(val type: Type) : StateMatcher {
4647

4748
data class State(val blockState: BlockState) : TargetState(Type.STATE) {
4849
override fun matches(state: BlockState, pos: BlockPos, world: ClientWorld) =
49-
state == blockState
50+
state.block == blockState.block && state.properties.all {
51+
it in TaskFlow.defaultIgnoreTags || state[it] == blockState[it]
52+
}
5053
override fun getStack(world: ClientWorld, pos: BlockPos): ItemStack =
5154
blockState.block.getPickStack(world, pos, blockState)
5255
}

common/src/main/kotlin/com/lambda/module/modules/client/TaskFlow.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.lambda.module.Module
77
import com.lambda.module.tag.ModuleTag
88
import com.lambda.util.BlockUtils.allSigns
99
import com.lambda.util.item.ItemUtils
10+
import net.minecraft.state.property.Properties
1011

1112
object TaskFlow : Module(
1213
name = "TaskFlow",
@@ -32,4 +33,11 @@ object TaskFlow : Module(
3233
}
3334
val disposables by setting("Disposables", ItemUtils.defaultDisposables)
3435
val ignoredBlocks by setting("Ignored Blocks", allSigns)
36+
val defaultIgnoreTags = setOf(
37+
Properties.DISTANCE_1_7,
38+
Properties.PERSISTENT,
39+
Properties.WATERLOGGED,
40+
Properties.STAIR_SHAPE
41+
)
42+
// val ignoredTags by setting("Ignored Tags", defaultIgnoreTags)
3543
}

0 commit comments

Comments
 (0)