Skip to content

Commit 3f4cdb9

Browse files
authored
block/explosion.go: Calculate damage before destroying blocks (#1133)
This matches vanilla behavior
1 parent e2a643f commit 3f4cdb9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

server/block/explosion.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ func (c ExplosionConfig) Explode(tx *world.Tx, explosionPos mgl64.Vec3) {
140140
return
141141
}
142142

143+
for _, e := range affectedEntities {
144+
if explodable, ok := e.(ExplodableEntity); ok {
145+
impact := (1 - e.Position().Sub(explosionPos).Len()/d) * exposure(tx, explosionPos, e)
146+
explodable.Explode(explosionPos, impact, c)
147+
}
148+
}
149+
143150
for _, pos := range affectedBlocks {
144151
bl := tx.Block(pos)
145152
if explodable, ok := bl.(Explodable); ok {
@@ -158,13 +165,6 @@ func (c ExplosionConfig) Explode(tx *world.Tx, explosionPos mgl64.Vec3) {
158165
}
159166
}
160167

161-
for _, e := range affectedEntities {
162-
if explodable, ok := e.(ExplodableEntity); ok {
163-
impact := (1 - e.Position().Sub(explosionPos).Len()/d) * exposure(tx, explosionPos, e)
164-
explodable.Explode(explosionPos, impact, c)
165-
}
166-
}
167-
168168
if spawnFire {
169169
for _, pos := range affectedBlocks {
170170
if r.IntN(3) == 0 {

0 commit comments

Comments
 (0)