Skip to content

Commit 25f1c9b

Browse files
committed
cleanup
1 parent aee1d80 commit 25f1c9b

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

src/main/kotlin/com/lambda/interaction/construction/result/results/GenericResult.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import com.lambda.interaction.material.container.MaterialContainer
3232
import com.lambda.interaction.material.container.containers.MainHandContainer
3333
import net.minecraft.item.ItemStack
3434
import net.minecraft.util.math.BlockPos
35-
import net.minecraft.util.math.Direction
3635
import net.minecraft.util.math.Vec3d
3736
import java.awt.Color
3837

@@ -45,8 +44,7 @@ sealed class GenericResult : BuildResult() {
4544
data class NotVisible(
4645
override val pos: BlockPos,
4746
val hitPos: BlockPos,
48-
val side: Direction,
49-
val distance: Double,
47+
val distance: Double
5048
) : Drawable, GenericResult() {
5149
override val name: String get() = "Not visible at $pos."
5250
override val rank = Rank.NotVisible

src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakChecker.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import com.lambda.util.BlockUtils.instantBreakable
5353
import com.lambda.util.BlockUtils.isEmpty
5454
import com.lambda.util.item.ItemStackUtils.inventoryIndexOrSelected
5555
import com.lambda.util.math.distSq
56+
import com.lambda.util.math.vec3d
5657
import com.lambda.util.world.raycast.RayCastUtils.blockResult
5758
import io.ktor.util.collections.*
5859
import kotlinx.coroutines.Dispatchers
@@ -187,9 +188,10 @@ class BreakChecker @SimCheckerDsl private constructor(simInfo: SimInfo)
187188
withContext(Dispatchers.Default) {
188189
boxes.map { box ->
189190
launch {
190-
val sides = if (buildConfig.checkSideVisibility) {
191-
box.getVisibleSurfaces(eye).intersect(Direction.entries)
192-
} else Direction.entries.toSet()
191+
val sides = if (buildConfig.checkSideVisibility)
192+
box.getVisibleSurfaces(eye)
193+
else Direction.entries.toSet()
194+
193195
scanSurfaces(box, sides, buildConfig.resolution) { side, vec ->
194196
if (eye distSq vec > reachSq) {
195197
misses.add(vec)
@@ -215,8 +217,12 @@ class BreakChecker @SimCheckerDsl private constructor(simInfo: SimInfo)
215217
}
216218

217219
if (validHits.isEmpty()) {
218-
// ToDo: If we can only mine exposed surfaces we need to add not visible result here
219-
result(GenericResult.OutOfReach(pos, eye, misses))
220+
if (misses.isNotEmpty()) {
221+
result(GenericResult.OutOfReach(pos, eye, misses))
222+
return true
223+
}
224+
225+
result(GenericResult.NotVisible(pos, pos, eye.distanceTo(pos.vec3d)))
220226
return true
221227
}
222228

src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PlaceChecker.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import com.lambda.util.math.vec3d
5555
import com.lambda.util.player.MovementUtils.sneaking
5656
import com.lambda.util.player.copyPlayer
5757
import com.lambda.util.world.raycast.RayCastUtils.blockResult
58+
import io.ktor.util.collections.*
5859
import kotlinx.coroutines.CoroutineScope
5960
import kotlinx.coroutines.Dispatchers
6061
import kotlinx.coroutines.cancel
@@ -146,8 +147,8 @@ class PlaceChecker @SimCheckerDsl private constructor(simInfo: SimInfo)
146147

147148
val boxes = voxelShape.boundingBoxes.map { it.offset(pos) }
148149

149-
val validHits = mutableListOf<CheckedHit>()
150-
val misses = mutableSetOf<Vec3d>()
150+
val validHits = ConcurrentSet<CheckedHit>()
151+
val misses = ConcurrentSet<Vec3d>()
151152
val reachSq = buildConfig.interactReach.pow(2)
152153

153154
// ToDo: For each hand
@@ -198,7 +199,7 @@ class PlaceChecker @SimCheckerDsl private constructor(simInfo: SimInfo)
198199
return
199200
}
200201

201-
result(GenericResult.NotVisible(pos, pos, side, eye.distanceTo(pos.offset(side).vec3d)))
202+
result(GenericResult.NotVisible(pos, pos, eye.distanceTo(pos.offset(side).vec3d)))
202203
return
203204
}
204205

@@ -210,7 +211,7 @@ class PlaceChecker @SimCheckerDsl private constructor(simInfo: SimInfo)
210211
} else selectHitPos(validHits, fakePlayer)
211212
}
212213

213-
private fun AutomatedSafeContext.selectHitPos(validHits: List<CheckedHit>, fakePlayer: ClientPlayerEntity) {
214+
private fun AutomatedSafeContext.selectHitPos(validHits: Collection<CheckedHit>, fakePlayer: ClientPlayerEntity) {
214215
buildConfig.pointSelection.select(validHits)?.let { checkedHit ->
215216
val hitResult = checkedHit.hit.blockResult ?: return
216217

src/main/kotlin/com/lambda/interaction/construction/simulation/checks/PostProcessingChecker.kt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,11 @@ class PostProcessingChecker @SimCheckerDsl private constructor(simInfo: SimInfo)
178178
if (validHits.isEmpty()) {
179179
if (misses.isNotEmpty()) {
180180
result(GenericResult.OutOfReach(pos, eye, misses))
181-
} else {
182-
//ToDo: Must clean up surface scan usage / renders. Added temporary direction until changes are made
183-
result(
184-
GenericResult.NotVisible(
185-
pos,
186-
pos,
187-
Direction.UP,
188-
eye.distanceTo(pos.offset(Direction.UP).vec3d)
189-
)
190-
)
181+
return
191182
}
183+
184+
//ToDo: Must clean up surface scan usage / renders. Added temporary direction until changes are made
185+
result(GenericResult.NotVisible(pos, pos, eye.distanceTo(pos.vec3d)))
192186
return
193187
}
194188

0 commit comments

Comments
 (0)