Skip to content

Commit 25c3b8d

Browse files
committed
move checkPostProcessResults invoke to the simulate function
1 parent 14c8cd1 commit 25c3b8d

File tree

1 file changed

+10
-17
lines changed
  • common/src/main/kotlin/com/lambda/interaction/construction/simulation

1 file changed

+10
-17
lines changed

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ object BuildSimulator {
9898
) = runSafe {
9999
structure.entries.flatMap { (pos, target) ->
100100
val preProcessing = target.getProcessingInfo()
101-
checkRequirements(pos, eye, preProcessing, target, build, interact, rotation, inventory).let {
101+
checkRequirements(pos, preProcessing, target, build).let {
102+
if (it.isEmpty()) return@let
103+
return@flatMap it
104+
}
105+
checkPostProcessResults(pos, eye, preProcessing, target, interact, build.placing, rotation, inventory).let {
102106
if (it.isEmpty()) return@let
103107
return@flatMap it
104108
}
@@ -117,13 +121,9 @@ object BuildSimulator {
117121

118122
private fun SafeContext.checkRequirements(
119123
pos: BlockPos,
120-
eye: Vec3d,
121124
preProcessing: PreProcessingInfo,
122125
target: TargetState,
123-
build: BuildConfig,
124-
interact: InteractionConfig,
125-
rotation: RotationConfig,
126-
inventory: InventoryConfig
126+
build: BuildConfig
127127
): Set<BuildResult> {
128128
val acc = mutableSetOf<BuildResult>()
129129

@@ -165,16 +165,6 @@ object BuildSimulator {
165165
return acc
166166
}
167167

168-
/* the state requires post-processing */
169-
if (target.matches(state, pos, world, ignoredProperties = preProcessing.ignore)) {
170-
checkPostProcessResults(pos, eye, preProcessing, state, target, interact, build.placing, rotation, inventory).let { postProcessResults ->
171-
if (postProcessResults.isNotEmpty()) {
172-
acc.addAll(postProcessResults)
173-
return acc
174-
}
175-
}
176-
}
177-
178168
/* block is unbreakable, so it cant be broken or replaced */
179169
if (state.getHardness(world, pos) < 0 && !gamemode.isCreative) {
180170
acc.add(BuildResult.Unbreakable(pos, state))
@@ -283,7 +273,6 @@ object BuildSimulator {
283273
pos: BlockPos,
284274
eye: Vec3d,
285275
preProcessing: PreProcessingInfo,
286-
state: BlockState,
287276
targetState: TargetState,
288277
interact: InteractionConfig,
289278
place: PlaceConfig,
@@ -294,6 +283,10 @@ object BuildSimulator {
294283

295284
val acc = mutableSetOf<BuildResult>()
296285

286+
val state = blockState(pos)
287+
if (!targetState.matches(state, pos, world, preProcessing.ignore))
288+
return acc
289+
297290
val interactBlock: (BlockState, Set<Direction>?, Item?, Boolean) -> Unit =
298291
{ expectedState, side, item, placing ->
299292
interactWithBlock(

0 commit comments

Comments
 (0)