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

     1  package effect
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/world"
     5  	"image/color"
     6  	"time"
     7  )
     8  
     9  // FatalPoison is a lasting effect that causes the affected entity to lose health gradually. FatalPoison,
    10  // unlike Poison, can kill the entity it is applied to.
    11  type FatalPoison struct {
    12  	nopLasting
    13  }
    14  
    15  // Apply ...
    16  func (FatalPoison) Apply(e world.Entity, lvl int, d time.Duration) {
    17  	interval := 50 >> (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, PoisonDamageSource{Fatal: true})
    24  		}
    25  	}
    26  }
    27  
    28  // RGBA ...
    29  func (FatalPoison) RGBA() color.RGBA {
    30  	return color.RGBA{R: 0x4e, G: 0x93, B: 0x31, A: 0xff}
    31  }