Skip to content

Commit

Permalink
block/tnt.go: Implement ProjectileHitter
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Jan 7, 2025
1 parent 19cb9d1 commit 16b0d3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 7 additions & 0 deletions server/block/tnt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ type TNT struct {
solid
}

// ProjectileHit ...
func (t TNT) ProjectileHit(pos cube.Pos, tx *world.Tx, e world.Entity, _ cube.Face) {
if f, ok := e.(flammableEntity); ok && f.OnFireDuration() > 0 {
t.Ignite(pos, tx, nil)
}
}

// Activate ...
func (t TNT) Activate(pos cube.Pos, _ cube.Face, tx *world.Tx, u item.User, ctx *item.UseContext) bool {
held, _ := u.HeldItems()
Expand Down
3 changes: 0 additions & 3 deletions server/entity/projectile.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ func (lt *ProjectileBehaviour) Tick(e *Ent, tx *world.Tx) *Movement {
}
case trace.BlockResult:
bpos := r.BlockPosition()
if t, ok := tx.Block(bpos).(block.TNT); ok && e.OnFireDuration() > 0 {
t.Ignite(bpos, tx, nil)
}
if h, ok := tx.Block(bpos).(block.ProjectileHitter); ok {
h.ProjectileHit(bpos, tx, e, r.Face())
}
Expand Down

0 comments on commit 16b0d3e

Please sign in to comment.