Skip to content

Commit

Permalink
fix(ChestAura): outdated BlockState (#4793)
Browse files Browse the repository at this point in the history
  • Loading branch information
MukjepScarlet authored Dec 5, 2024
1 parent 52d7f7d commit d38219e
Showing 1 changed file with 5 additions and 6 deletions.
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

0 comments on commit d38219e

Please sign in to comment.