github.com/df-mc/dragonfly@v0.9.13/server/entity/effect/wither.go (about)

     1  package effect
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/world"
     5  	"image/color"
     6  	"time"
     7  )
     8  
     9  // Wither is a lasting effect that causes an entity to take continuous damage that is capable of killing an
    10  // entity.
    11  type Wither struct {
    12  	nopLasting
    13  }
    14  
    15  // Apply ...
    16  func (Wither) Apply(e world.Entity, lvl int, d time.Duration) {
    17  	interval := 80 >> (lvl - 1)
    18  	if interval < 1 {
    19  		interval = 1
    20  	}
    21  	if tickDuration(d)%interval == 0 {
    22  		if l, ok := e.(living); ok {
    23  			l.Hurt(1, WitherDamageSource{})
    24  		}
    25  	}
    26  }
    27  
    28  // RGBA ...
    29  func (Wither) RGBA() color.RGBA {
    30  	return color.RGBA{R: 0x35, G: 0x2a, B: 0x27, A: 0xff}
    31  }
    32  
    33  // WitherDamageSource is used for damage caused by an effect.Wither applied
    34  // to an entity.
    35  type WitherDamageSource struct{}
    36  
    37  func (WitherDamageSource) ReducedByResistance() bool { return true }
    38  func (WitherDamageSource) ReducedByArmour() bool     { return false }
    39  func (WitherDamageSource) Fire() bool                { return false }