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

Fix explosion damage on players #869

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Flonja
Copy link
Contributor

@Flonja Flonja commented May 4, 2024

Calculations taken from decompiled java edition, but it seems to match bedrock values
(Edited slightly to make the original code easier to read)

                float d = this.radius * 2.0F;
                double dist = entity.distanceTo(vec3d); // Same as `entity.Sub(vec3d).Len()`

                if (dist / d <= 1.0D) {
//                    double d8 = entity.getX() - this.x;
//                    double d9 = (entity instanceof EntityTNTPrimed ? entity.getY() : entity.getEyeY()) - this.y;
//                    double d10 = entity.getZ() - this.z;
//                    double d11 = Math.sqrt(d8 * d8 + d9 * d9 + d10 * d10); // Same as `dist`

                    if (dist != 0.0D) {
                        double exposure = (double) getSeenPercent(vec3d, entity); // Same as `exposure(vec3d, entity)`
                        double impact = (1.0D - dist) * exposure;
                        entity.hurt(this.getDamageSource(), (float) ((int) ((impact * impact + impact) / 2.0D * 7.0D * (double) d + 1.0D)));

server/block/explosion.go Outdated Show resolved Hide resolved
@Flonja Flonja requested a review from T14Raptor May 5, 2024 22:22
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