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

Replacing String with ID in Block type comparison #1187

Closed
KawaiiNahida opened this issue Apr 5, 2023 · 0 comments
Closed

Replacing String with ID in Block type comparison #1187

KawaiiNahida opened this issue Apr 5, 2023 · 0 comments

Comments

@KawaiiNahida
Copy link
Member

KawaiiNahida commented Apr 5, 2023

Is your feature request related to a problem? Please describe.

To improve code efficiency and reduce potential errors, it is recommended to replace the code like ev.mTargetBlockInstance.getBlock()->getName() == "minecraft:air" with an ID comparison.

Describe the solution you'd like

This can be achieved by retrieving the block ID of the "minecraft:air" block using a block registry, and comparing it directly with the block ID of ev.mTargetBlockInstance.getBlock(). By using an ID comparison, the code can avoid the overhead of string comparison to improve performance. Additionally, it can reduce the risk of errors caused by misspelling or variations in block name strings.

OEOTYAN added a commit that referenced this issue Apr 7, 2023
@OEOTYAN OEOTYAN closed this as completed Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants