Skip to content

Optimize block iteration to prevent memory leaks#119

Open
LetMePractice wants to merge 2 commits intoclickcrystals-development:mainfrom
LetMePractice:main
Open

Optimize block iteration to prevent memory leaks#119
LetMePractice wants to merge 2 commits intoclickcrystals-development:mainfrom
LetMePractice:main

Conversation

@LetMePractice
Copy link
Contributor

@LetMePractice LetMePractice commented Feb 27, 2026

Type of change

  • Bug fix
  • New feature

Description

Fixes long-session black screen caused by heavy usage of block_in_range and block_in_fov.

These commands were performing large cubic block scans per call. Under high-frequency script usage, this resulted in excessive iteration and sustained performance pressure over time.

Changes include:

  • Replacing the 65×65×65 volume scan in ConditionalBlockInFov with a 3×3 raycast grid.
  • Switching nearest-block lookups to a spiral search pattern with early exit.
  • Reducing overhead in boxIterator() by using integer coordinates.

This significantly lowers the amount of work per evaluation and improves long-session stability under aggressive scripting.

Related issues

Addresses black screen issues reported during extended use of block_in_range and block_in_fov.

Checklist:

  • My code follows the style guidelines of ItziSpyder(ImproperIssues).
  • I have added comments to my code in more complex areas.
  • I have tested the code in both development and production environments.
  • I have joined the ClickCrystals Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant