Skip to content

Commit

Permalink
feat(client): reset keybindings if pose was updated from the server
Browse files Browse the repository at this point in the history
  • Loading branch information
rvbsm committed Apr 18, 2024
1 parent c658a60 commit c19653c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.rvbsm.fsit.client.network
import dev.rvbsm.fsit.client.FSitModClient
import dev.rvbsm.fsit.client.config.RestrictionList
import dev.rvbsm.fsit.client.network.FSitClientNetworking.receive
import dev.rvbsm.fsit.client.option.FSitKeyBindings
import dev.rvbsm.fsit.network.packet.PoseUpdateS2CPayload
import dev.rvbsm.fsit.network.packet.RidingRequestS2CPayload
import dev.rvbsm.fsit.network.packet.RidingResponseC2SPayload
Expand All @@ -19,7 +20,10 @@ object FSitClientNetworking {
}

internal fun PoseUpdateS2CPayload.receive(player: ClientPlayerEntity) {
player.setPose(pose)
if (player.pose() != pose) {
player.setPose(pose)
FSitKeyBindings.reset()
}
}

internal fun RidingRequestS2CPayload.receive() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ object FSitKeyBindings : ClientTickEvents.EndTick {
if (currentPose == Pose.Standing && (player.hasVehicle() || !canSitMidAir)) return

if ((sitKey.isPressed && crawlKey.isPressed) || player.abilities.flying || player.isSneaking) {
sitKey.isPressed = sitKey.isPressed && FSitModClient.sitKeyMode.value.isSticky(holdTicks)
crawlKey.isPressed = crawlKey.isPressed && FSitModClient.crawlKeyMode.value.isSticky(holdTicks)
reset()
}

val pose = when {
Expand All @@ -56,4 +55,9 @@ object FSitKeyBindings : ClientTickEvents.EndTick {
FSitModClient.sendIfPossible(PoseRequestC2SPayload(pose))
}
}

fun reset() {
sitKey.isPressed = sitKey.isPressed && FSitModClient.sitKeyMode.value.isSticky(holdTicks)
crawlKey.isPressed = crawlKey.isPressed && FSitModClient.crawlKeyMode.value.isSticky(holdTicks)
}
}

0 comments on commit c19653c

Please sign in to comment.