Skip to content

reduce allocations in explosion damage calculations - #6655

Closed
xpncvr wants to merge 1 commit into
MeteorDevelopment:masterfrom
xpncvr:damage-utils-allocations
Closed

reduce allocations in explosion damage calculations#6655
xpncvr wants to merge 1 commit into
MeteorDevelopment:masterfrom
xpncvr:damage-utils-allocations

Conversation

@xpncvr

@xpncvr xpncvr commented Sep 12, 2026

Copy link
Copy Markdown

Type of change

  • Bug fix
  • New feature
  • Optimization

Description

Reduced allocation overhead in DamageUtils:

  • getExposure reuses a single Vec3 and ExposureRaycastContext instead of creating both per ray
  • protectionReduction hoists its map allocation out of the armor slot loop. No clear() is needed because Utils.getEnchantments already clears the map

This drops every crystalDamage / bedDamage / anchorDamage call from 94 temporary objects to 3 for a standing player hitbox.

Related issues

None

How Has This Been Tested?

Verified that rendered crystal damage is still the same in game

Checklist:

  • My code follows the style guidelines of this project.
  • I have added comments to my code in more complex areas.
  • I have tested the code in both development and production environments.

@crosby-moe

crosby-moe commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

the choice to allocate a Vec3 rather than using IVec3 was intentional, i think if we could entirely eliminate the IVec3 interface and restore Vec3’s immutability, it would be optimal

though if it can be profiled/benchmarked to significantly improve performance this way i will concede

@xpncvr

xpncvr commented Sep 12, 2026

Copy link
Copy Markdown
Author

Yeah fair enough its not worth it then, the difference is negligible I profiled it.

@xpncvr xpncvr closed this Sep 12, 2026
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.

2 participants