Skip to content

Commit 93abcbc

Browse files
committed
fixed PlaceBlock action result swing issue
1 parent f3ede42 commit 93abcbc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.lambda.task.Task
3030
import com.lambda.util.BlockUtils.blockState
3131
import com.lambda.util.Communication.warn
3232
import net.minecraft.block.BlockState
33+
import net.minecraft.util.ActionResult
3334

3435
class PlaceBlock @Ta5kBuilder constructor(
3536
private val ctx: PlaceContext,
@@ -96,19 +97,20 @@ class PlaceBlock @Ta5kBuilder constructor(
9697
}
9798

9899
private fun SafeContext.placeBlock() {
100+
val stack = player.getStackInHand(ctx.hand)
101+
val stackCount = stack.count
99102
val actionResult = interaction.interactBlock(
100103
player,
101104
ctx.hand,
102105
ctx.result
103106
)
104107

105-
if (actionResult.isAccepted) {
106-
if (interact.swingHand) {
108+
if (actionResult is ActionResult.Success) {
109+
if (actionResult.swingSource() == ActionResult.SwingSource.CLIENT && interact.swingHand) {
107110
player.swingHand(ctx.hand)
108-
}
109-
110-
if (!player.getStackInHand(ctx.hand).isEmpty && interaction.hasCreativeInventory()) {
111-
mc.gameRenderer.firstPersonRenderer.resetEquipProgress(ctx.hand)
111+
if (!player.getStackInHand(ctx.hand).isEmpty && (stack.count != stackCount || interaction.hasCreativeInventory())) {
112+
mc.gameRenderer.firstPersonRenderer.resetEquipProgress(ctx.hand)
113+
}
112114
}
113115

114116
state = State.CONFIRMING

0 commit comments

Comments
 (0)