Skip to content

Commit 6c9993a

Browse files
committed
Remove deprecated rotation fix and fix wrong hit check
1 parent 478dd20 commit 6c9993a

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import com.lambda.interaction.material.container.ContainerManager.findBestAvaila
3131
import com.lambda.interaction.request.rotation.Rotation.Companion.rotation
3232
import com.lambda.interaction.request.rotation.Rotation.Companion.rotationTo
3333
import com.lambda.interaction.request.rotation.RotationRequest
34-
import com.lambda.interaction.request.rotation.visibilty.RequestedHit
3534
import com.lambda.interaction.request.rotation.visibilty.VisibilityChecker.CheckedHit
3635
import com.lambda.interaction.request.rotation.visibilty.VisibilityChecker.getVisibleSurfaces
3736
import com.lambda.interaction.request.rotation.visibilty.VisibilityChecker.scanSurfaces
@@ -55,7 +54,6 @@ import net.minecraft.item.ItemUsageContext
5554
import net.minecraft.registry.RegistryKeys
5655
import net.minecraft.state.property.Properties
5756
import net.minecraft.util.Hand
58-
import net.minecraft.util.hit.HitResult
5957
import net.minecraft.util.math.BlockPos
6058
import net.minecraft.util.math.Box
6159
import net.minecraft.util.math.Direction
@@ -152,7 +150,7 @@ object BuildSimulator {
152150
hit.blockResult?.blockPos == hitPos && hit.blockResult?.side == hitSide
153151
}
154152

155-
val checkedHits = mutableListOf<CheckedHit>()
153+
val validHits = mutableListOf<CheckedHit>()
156154
val misses = mutableSetOf<Vec3d>()
157155
val reachSq = reach.pow(2)
158156

@@ -175,11 +173,11 @@ object BuildSimulator {
175173
val checked = CheckedHit(hit, newRotation, reach)
176174
if (!checked.verify()) return@scanSurfaces
177175

178-
checkedHits.add(checked)
176+
validHits.add(checked)
179177
}
180178
}
181179

182-
if (checkedHits.isEmpty()) {
180+
if (validHits.isEmpty()) {
183181
if (misses.isNotEmpty()) {
184182
acc.add(BuildResult.OutOfReach(pos, eye, misses))
185183
return@forEach
@@ -189,7 +187,7 @@ object BuildSimulator {
189187
return@forEach
190188
}
191189

192-
interact.pointSelection.select(checkedHits)?.let { checkedHit ->
190+
interact.pointSelection.select(validHits)?.let { checkedHit ->
193191
val optimalStack = target.getStack(world, pos)
194192

195193
// ToDo: For each hand and sneak or not?
@@ -379,7 +377,6 @@ object BuildSimulator {
379377
hit.blockResult?.blockPos == pos
380378
}
381379

382-
val checkedHits = mutableListOf<CheckedHit>()
383380
/* the player is buried inside the block */
384381
if (boxes.any { it.contains(eye) }) {
385382
currentCast?.blockResult?.let { blockHit ->
@@ -400,7 +397,7 @@ object BuildSimulator {
400397
}
401398
}
402399

403-
val validHits = mutableMapOf<Vec3d, HitResult>()
400+
val validHits = mutableListOf<CheckedHit>()
404401
val misses = mutableSetOf<Vec3d>()
405402
val reachSq = reach.pow(2)
406403

@@ -417,7 +414,7 @@ object BuildSimulator {
417414
val checked = CheckedHit(hit, newRotation, reach)
418415
if (!checked.verify()) return@scanSurfaces
419416

420-
checkedHits.add(checked)
417+
validHits.add(checked)
421418
}
422419
}
423420

@@ -427,7 +424,7 @@ object BuildSimulator {
427424
return acc
428425
}
429426

430-
interact.pointSelection.select(checkedHits)?.let { checkedHit ->
427+
interact.pointSelection.select(validHits)?.let { checkedHit ->
431428
val blockHit = checkedHit.hit.blockResult ?: return@let
432429

433430
val breakContext = BreakContext(

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,6 @@ object TaskFlowModule : Module(
4242
val build = BuildSettings(this) { page == Page.BUILD }
4343
val rotation = RotationSettings(this) { page == Page.ROTATION }
4444
val interact = InteractionSettings(this, InteractionMask.BOTH) { page == Page.INTERACTION }
45-
46-
// ToDo: remove
47-
// might be useless since grim has ping compensation things and shit
48-
// its better to make sure the interactions are 100% matching the minecraft's ones
49-
private val pingTimeout by setting("Ping Timeout", false, "Timeout on high ping") { page == Page.INTERACTION }
50-
private val inScopeThreshold by setting("Constant Timeout", 1, 0..20, 1, "How many ticks to wait after target box is in rotation scope"," ticks") {
51-
page == Page.INTERACTION && !pingTimeout
52-
}
53-
54-
val scopeThreshold: Int
55-
get() =
56-
if (pingTimeout) PingManager.lastPing.toInt() / 50
57-
else inScopeThreshold
58-
5945
val inventory = InventorySettings(this) { page == Page.INVENTORY }
6046

6147
val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree") { page == Page.DEBUG }

common/src/main/kotlin/com/lambda/task/tasks/OpenContainer.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ class OpenContainer @Ta5kBuilder constructor(
8686
val target = lookAtBlock(blockPos, sides, interact)
8787
if (rotate && !target.requestBy(rotation).done) return@listen
8888

89-
if (inScope++ >= TaskFlowModule.scopeThreshold) {
90-
val hitResult = target.hit?.hitIfValid()?.blockResult ?: return@listen
91-
interaction.interactBlock(player, Hand.MAIN_HAND, hitResult)
89+
val hitResult = target.hit?.hitIfValid()?.blockResult ?: return@listen
90+
interaction.interactBlock(player, Hand.MAIN_HAND, hitResult)
9291

93-
state = State.OPENING
94-
}
92+
state = State.OPENING
9593
}
9694
}
9795
}

0 commit comments

Comments
 (0)