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

     1  package effect
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/world"
     5  	"image/color"
     6  )
     7  
     8  // Resistance is a lasting effect that reduces the damage taken from any sources except for void damage or
     9  // custom damage.
    10  type Resistance struct {
    11  	nopLasting
    12  }
    13  
    14  // Multiplier returns a damage multiplier for the damage source passed.
    15  func (Resistance) Multiplier(e world.DamageSource, lvl int) float64 {
    16  	if !e.ReducedByResistance() {
    17  		return 1
    18  	}
    19  	if v := 1 - 0.2*float64(lvl); v >= 0 {
    20  		return v
    21  	}
    22  	return 0
    23  }
    24  
    25  // RGBA ...
    26  func (Resistance) RGBA() color.RGBA {
    27  	return color.RGBA{R: 0x99, G: 0x45, B: 0x3a, A: 0xff}
    28  }