Skip to content

Commit 7a77cc8

Browse files
committed
Sneak when placing onto interaction blocks
1 parent 6ff5083 commit 7a77cc8

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

common/src/main/kotlin/com/lambda/task/Task.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ abstract class Task<Result> : Nameable {
198198
if (state == State.CANCELLED) return
199199

200200
cancelSubTasks()
201-
state = State.CANCELLED
201+
if (this !is RootTask) state = State.CANCELLED
202202
stopListening()
203203
runSafe { onCancel() }
204204
LOG.info("$identifier was cancelled")

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package com.lambda.task.tasks
33
import com.lambda.Lambda.LOG
44
import com.lambda.config.groups.InteractionConfig
55
import com.lambda.context.SafeContext
6+
import com.lambda.event.events.MovementEvent
67
import com.lambda.event.events.RotationEvent
78
import com.lambda.event.events.TickEvent
89
import com.lambda.event.events.WorldEvent
910
import com.lambda.event.listener.SafeListener.Companion.listener
1011
import com.lambda.interaction.construction.context.PlaceContext
1112
import com.lambda.module.modules.client.TaskFlow
1213
import com.lambda.task.Task
14+
import com.lambda.util.BlockUtils
1315
import com.lambda.util.BlockUtils.blockState
1416
import com.lambda.util.Communication.warn
1517
import net.minecraft.block.BlockState
@@ -68,6 +70,14 @@ class PlaceBlock @Ta5kBuilder constructor(
6870
findOutIfNeeded = true
6971
}
7072

73+
listener<MovementEvent.InputUpdate> {
74+
if (state != State.PLACING) return@listener
75+
val hitBlock = ctx.result.blockPos.blockState(world).block
76+
if (hitBlock in BlockUtils.interactionBlacklist) {
77+
it.input.sneaking = true
78+
}
79+
}
80+
7181
listener<WorldEvent.BlockUpdate> {
7282
if (it.pos != ctx.resultingPos) return@listener
7383

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ object BlockUtils {
4141
Blocks.SOUL_CAMPFIRE,
4242
Blocks.JUKEBOX,
4343
Blocks.NOTE_BLOCK,
44+
Blocks.STRUCTURE_BLOCK,
45+
Blocks.COMMAND_BLOCK,
4446
).apply { addAll(shulkerBlocks) }
4547

4648
val signs = setOf(

0 commit comments

Comments
 (0)