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

Blasting Highlight Event Visual Bug? #8240

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

alegian
Copy link
Contributor

@alegian alegian commented Sep 28, 2024

This is my first time trying to contribute something to someone else's repo, please be kind.

Problem

I was looking at the RenderHighlightEvent code for the AoE blasting, and I noticed that you are calling recursive RenderHighlightEvents for each block affected, so that they may have a chance to cancel themselves.

However, when creating those recursive events, you pass the original rayTraceResult as parameter. I believe this means that instead of simulating one event for each block in the AoE, you actually simulate the origin-block's event many times over.

Changes proposed in this pull request:

Create a seperate BlockHitResult for each blastingTarget blockPos. For its parameters, I essentially cloned the original BlockHitResult, changing only the blockPos. So for example if the original block was 'hit' at the top left, every AoE block is going to simulate a top left hit aswell.

Copy link
Member

@pupnewfster pupnewfster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and I am sorry for taking a while to get to reviewing this. Only a minor cleanup related comment.

@@ -385,7 +385,9 @@ public void onBlockHover(RenderHighlightEvent.Block event) {
Lazy<VertexConsumer> lineConsumer = Lazy.of(() -> renderer.getBuffer(RenderType.lines()));
for (Entry<BlockPos, BlockState> block : blocks.entrySet()) {
BlockPos blastingTarget = block.getKey();
if (!pos.equals(blastingTarget) && !ClientHooks.onDrawHighlight(levelRenderer, info, rayTraceResult, event.getDeltaTracker(), matrix, renderer)) {
// simulate ray tracing results for all block positions
BlockHitResult currResult = new BlockHitResult(rayTraceResult.getLocation(), rayTraceResult.getDirection(), blastingTarget, rayTraceResult.isInside());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this can be rayTraceResult.withPosition(blastingTarget). We can also jjust inline it in the call to ClientHooks#onDrawHighlight so that we don't have to construct the new object for if the position is already the blasting target.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did you know that helper exists 😮

@pupnewfster pupnewfster merged commit bcf3e14 into mekanism:1.21.x Nov 13, 2024
@pupnewfster pupnewfster added this to the 10.7.6 milestone Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants