Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ChestAura): outdated BlockState #4793

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,14 @@ object FeatureChestAura : ToggleableConfigurable(ModuleChestStealer, "Aura", tru
}

val targetBlockPos = currentTargetBlock ?: return@tickHandler
val targetState = targetBlockPos.getState() ?: return@tickHandler
val currentPlayerRotation = RotationManager.serverRotation

// Trace a ray from the player to the target block position
val rayTraceResult = raytraceBlock(
interactionRange.toDouble(),
currentPlayerRotation,
targetBlockPos,
targetState
targetBlockPos.getState() ?: return@tickHandler
)

// Verify if the block is hit and is the correct target
Expand Down Expand Up @@ -192,7 +191,7 @@ object FeatureChestAura : ToggleableConfigurable(ModuleChestStealer, "Aura", tru
}
} else {
interactedBlocksSet.add(targetBlockPos)
targetBlockPos.recordAnotherChestPart(targetState)
targetBlockPos.recordAnotherChestPart(targetBlockPos.getState())
currentTargetBlock = null
wasInteractionSuccessful = true

Expand All @@ -203,16 +202,16 @@ object FeatureChestAura : ToggleableConfigurable(ModuleChestStealer, "Aura", tru
// Update interacted block set and reset target if successful or exceeded retries
if (wasInteractionSuccessful || interactionAttempts >= AwaitContainerSettings.maxInteractionRetries) {
interactedBlocksSet.add(targetBlockPos)
targetBlockPos.recordAnotherChestPart(targetState)
targetBlockPos.recordAnotherChestPart(targetBlockPos.getState())
currentTargetBlock = null
} else {
interactionAttempts++
}
}
}

private fun BlockPos.recordAnotherChestPart(state: BlockState) {
if (state.block !is ChestBlock) {
private fun BlockPos.recordAnotherChestPart(state: BlockState?) {
if (state?.block !is ChestBlock) {
return
}

Expand Down
Loading