Entity damage from explosions is ray-casted from incorrect position #48

Closed
opened 2021-05-01 16:56:29 +02:00 by ryvnf · 6 comments
Owner

Entity damage from explosions is calculated by casting rays from random points in the entities bounding box to the explosion. This is working correctly. The bounding box the rays originate from is however twice as large as it should be in all directions which makes the entity damage slightly incorrect. This bug has existed for as long as the mcl_explosions mod.

I have a solution for this and will make a PR shortly.

How to reproduce

An easy way to illustrate how this becomes a problem is the attached picture. Put a player (or any other entity of the same height) into the spot where the armor stand is and pull the lever.

The expected behavior is that the player/entity should take 1/2 heart damage (1 damage point) because there is a wall between the entity and the explosion. Because this bug exists the entity/player will take considerably more damage than that.

Entity damage from explosions is calculated by casting rays from random points in the entities bounding box to the explosion. This is working correctly. The bounding box the rays originate from is however twice as large as it should be in all directions which makes the entity damage slightly incorrect. This bug has existed for as long as the mcl_explosions mod. I have a solution for this and will make a PR shortly. ## How to reproduce An easy way to illustrate how this becomes a problem is the attached picture. Put a player (or any other entity of the same height) into the spot where the armor stand is and pull the lever. The expected behavior is that the player/entity should take 1/2 heart damage (1 damage point) because there is a wall between the entity and the explosion. Because this bug exists the entity/player will take considerably more damage than that.
ryvnf added the
bug
label 2021-05-01 17:00:57 +02:00
ryvnf added the
confirmed
label 2021-05-01 17:12:41 +02:00
ryvnf self-assigned this 2021-05-01 17:15:25 +02:00
ryvnf removed the
confirmed
label 2021-05-01 17:34:51 +02:00
ryvnf added the
unconfirmed
label 2021-05-01 17:36:08 +02:00
Author
Owner

I think I was wrong assuming this is a bug. What made me think of this was when I read my own code:

local x1 = collisionbox[1] * 2
local y1 = collisionbox[2] * 2
local z1 = collisionbox[3] * 2
local x2 = collisionbox[4] * 2
local y2 = collisionbox[5] * 2
local z2 = collisionbox[6] * 2

But then I looked at the Minecraft Wiki which I used as a reference when implementing the mcl_explosions mod. It says:

  1. The entity's bounding box is divided into a [2×width+1] by [2×height+1] by [2×depth+1] grid of unequally spaced points.

So this is probably what happens in Minecraft too. I will leave this issue open for a few days in case someone have access to Minecraft and can confirm that it behaves the same. Otherwise I will close this issue as it is probably the expected behaviour.

I think I was wrong assuming this is a bug. What made me think of this was when I read my own code: ```lua local x1 = collisionbox[1] * 2 local y1 = collisionbox[2] * 2 local z1 = collisionbox[3] * 2 local x2 = collisionbox[4] * 2 local y2 = collisionbox[5] * 2 local z2 = collisionbox[6] * 2 ``` But then I looked at the [Minecraft Wiki](https://minecraft.fandom.com/wiki/Explosion#Calculation_of_explosion_exposure) which I used as a reference when implementing the mcl_explosions mod. It says: > 1. The entity's bounding box is divided into a [2×width+1] by [2×height+1] by [2×depth+1] grid of unequally spaced points. So this is probably what happens in Minecraft too. I will leave this issue open for a few days in case someone have access to Minecraft and can confirm that it behaves the same. Otherwise I will close this issue as it is probably the expected behaviour.
ryvnf closed this issue 2021-05-01 17:37:42 +02:00
ryvnf reopened this issue 2021-05-01 17:42:26 +02:00
ryvnf removed their assignment 2021-05-01 17:43:10 +02:00
Author
Owner

Either way. I think something is slightly incorrect with the current code.

The fact that the size of the bounding box is multiplied by two means that part of it will clip into a roof. This results in you taking less damage if you have a roof over your head when there is direct exposure from you and the explosion.

Either way. I think something is slightly incorrect with the current code. The fact that the size of the bounding box is multiplied by two means that part of it will clip into a roof. This results in you taking less damage if you have a roof over your head when there is direct exposure from you and the explosion.
Owner

@n_to you have the original minecraft as far as I know – could you test this scenario?

@n_to you have the original minecraft as far as I know – could you test this scenario?
Author
Owner

I am confident this is a bug because a player will take less damage from TNT if a player is surrounded by blocks. Like in the following picture. If a player stands were the armor stand is they will take more damage if the obsidian roof is removed.

I am quite sure I misinterpreted how the explosion entity damage algorithm works. I will make a PR adjusting it so it will only calculate the exposure from the entity collisionbox.

I am confident this is a bug because a player will take less damage from TNT if a player is surrounded by blocks. Like in the following picture. If a player stands were the armor stand is they will take more damage if the obsidian roof is removed. I am quite sure I misinterpreted how the explosion entity damage algorithm works. I will make a PR adjusting it so it will only calculate the exposure from the entity collisionbox.
Owner

@ryvnf thank you for your efforts.

@ryvnf thank you for your efforts.
ryvnf removed the
unconfirmed
label 2021-05-09 14:44:04 +02:00
ryvnf was assigned by e 2021-05-14 21:22:49 +02:00
ryvnf added this to the First Release milestone 2021-05-16 22:49:18 +02:00
Author
Owner

Closing after merging #62.

Closing after merging #62.
ryvnf closed this issue 2021-05-19 13:06:57 +02:00
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
2 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Mineclonia/Mineclonia#48
No description provided.