effect

package
Version: v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 7 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ID

func ID(e Type) (int, bool)

ID attempts to return the ID an effect was registered with. If found, the id is returned and the bool true.

func Register

func Register(id int, e Type)

Register registers an Effect with a specific ID to translate from and to on disk and network. An Effect instance may be created by creating a struct instance in this package like effect.Regeneration{}.

func ResultingColour

func ResultingColour(effects []Effect) (color.RGBA, bool)

ResultingColour calculates the resulting colour of the effects passed and returns a bool specifying if the effects were ambient effects, which will cause their particles to display less frequently.

Types

type Absorption

type Absorption struct {
	// contains filtered or unexported fields
}

Absorption is a lasting effect that increases the health of an entity over the maximum. Once this extra health is lost, it will not regenerate.

func (Absorption) Apply

func (Absorption) Apply(world.Entity, int, time.Duration)

func (Absorption) End

func (Absorption) End(e world.Entity, _ int)

End ...

func (Absorption) RGBA

func (Absorption) RGBA() color.RGBA

RGBA ...

func (Absorption) Start

func (Absorption) Start(e world.Entity, lvl int)

Start ...

type Blindness

type Blindness struct {
	// contains filtered or unexported fields
}

Blindness is a lasting effect that greatly reduces the vision range of the entity affected.

func (Blindness) Apply

func (Blindness) Apply(world.Entity, int, time.Duration)

func (Blindness) End

func (Blindness) End(world.Entity, int)

func (Blindness) RGBA

func (Blindness) RGBA() color.RGBA

RGBA ...

func (Blindness) Start

func (Blindness) Start(world.Entity, int)

type ConduitPower

type ConduitPower struct {
	// contains filtered or unexported fields
}

ConduitPower is a lasting effect that grants the affected entity the ability to breathe underwater and allows the entity to break faster when underwater or in the rain. (Similarly to haste.)

func (ConduitPower) Apply

func (ConduitPower) Apply(world.Entity, int, time.Duration)

func (ConduitPower) End

func (ConduitPower) End(world.Entity, int)

func (ConduitPower) Multiplier

func (ConduitPower) Multiplier(lvl int) float64

Multiplier returns the mining speed multiplier from this effect.

func (ConduitPower) RGBA

func (ConduitPower) RGBA() color.RGBA

RGBA ...

func (ConduitPower) Start

func (ConduitPower) Start(world.Entity, int)

type Effect

type Effect struct {
	// contains filtered or unexported fields
}

Effect is an effect that can be added to an entity. Effects are either instant (applying the effect only once) or lasting (applying the effect every tick).

func New added in v0.3.0

func New(t LastingType, lvl int, d time.Duration) Effect

New creates a new Effect using a LastingType passed. Once added to an entity, the time.Duration passed will be ticked down by the entity until it reaches a duration of 0.

func NewAmbient added in v0.3.0

func NewAmbient(t LastingType, lvl int, d time.Duration) Effect

NewAmbient creates a new ambient (reduced particles, as when using a beacon) Effect using a LastingType passed. Once added to an entity, the time.Duration passed will be ticked down by the entity until it reaches a duration of 0.

func NewInstant added in v0.3.0

func NewInstant(t Type, lvl int) Effect

NewInstant returns a new instant Effect using the Type passed. The effect will be applied to an entity once and will expire immediately after.

func (Effect) Ambient added in v0.3.0

func (e Effect) Ambient() bool

Ambient returns whether the Effect is an ambient effect, leading to reduced particles shown to the client. False is always returned if the Effect was created using New or NewInstant.

func (Effect) Duration

func (e Effect) Duration() time.Duration

Duration returns the leftover duration of the Effect. The duration returned is always 0 if NewInstant was used to create the effect.

func (Effect) Level

func (e Effect) Level() int

Level returns the level of the Effect.

func (Effect) ParticlesHidden added in v0.3.0

func (e Effect) ParticlesHidden() bool

ParticlesHidden returns true if the Effect had its particles hidden by calling WithoutParticles.

func (Effect) TickDuration added in v0.3.0

func (e Effect) TickDuration() Effect

TickDuration ticks the effect duration, subtracting time.Second/20 from the leftover time and returning the resulting Effect.

func (Effect) Type added in v0.3.0

func (e Effect) Type() Type

Type returns the underlying type of the Effect. It is either of the type Type or LastingType, depending on whether it was created using New or NewAmbient, or NewInstant.

func (Effect) WithoutParticles added in v0.3.0

func (e Effect) WithoutParticles() Effect

WithoutParticles returns the same Effect with particles disabled. Adding the effect to players will not display the particles around the player.

type FatalPoison

type FatalPoison struct {
	// contains filtered or unexported fields
}

FatalPoison is a lasting effect that causes the affected entity to lose health gradually. FatalPoison, unlike Poison, can kill the entity it is applied to.

func (FatalPoison) Apply

func (FatalPoison) Apply(e world.Entity, lvl int, d time.Duration)

Apply ...

func (FatalPoison) End

func (FatalPoison) End(world.Entity, int)

func (FatalPoison) RGBA

func (FatalPoison) RGBA() color.RGBA

RGBA ...

func (FatalPoison) Start

func (FatalPoison) Start(world.Entity, int)

type FireResistance

type FireResistance struct {
	// contains filtered or unexported fields
}

FireResistance is a lasting effect that grants immunity to fire & lava damage.

func (FireResistance) Apply

func (FireResistance) Apply(world.Entity, int, time.Duration)

func (FireResistance) End

func (FireResistance) End(world.Entity, int)

func (FireResistance) RGBA

func (FireResistance) RGBA() color.RGBA

RGBA ...

func (FireResistance) Start

func (FireResistance) Start(world.Entity, int)

type Haste

type Haste struct {
	// contains filtered or unexported fields
}

Haste is a lasting effect that increases the mining speed of a player by 20% for each level of the effect.

func (Haste) Apply

func (Haste) Apply(world.Entity, int, time.Duration)

func (Haste) End

func (Haste) End(world.Entity, int)

func (Haste) Multiplier

func (Haste) Multiplier(lvl int) float64

Multiplier returns the mining speed multiplier from this effect.

func (Haste) RGBA

func (Haste) RGBA() color.RGBA

RGBA ...

func (Haste) Start

func (Haste) Start(world.Entity, int)

type HealthBoost

type HealthBoost struct {
	// contains filtered or unexported fields
}

HealthBoost causes the affected entity to have its maximum health changed for a specific duration.

func (HealthBoost) Apply

func (HealthBoost) Apply(world.Entity, int, time.Duration)

func (HealthBoost) End

func (HealthBoost) End(e world.Entity, lvl int)

End ...

func (HealthBoost) RGBA

func (HealthBoost) RGBA() color.RGBA

RGBA ...

func (HealthBoost) Start

func (HealthBoost) Start(e world.Entity, lvl int)

Start ...

type Hunger

type Hunger struct {
	// contains filtered or unexported fields
}

Hunger is a lasting effect that causes an affected player to gradually lose saturation and food.

func (Hunger) Apply

func (Hunger) Apply(e world.Entity, lvl int, _ time.Duration)

Apply ...

func (Hunger) End

func (Hunger) End(world.Entity, int)

func (Hunger) RGBA

func (Hunger) RGBA() color.RGBA

RGBA ...

func (Hunger) Start

func (Hunger) Start(world.Entity, int)

type InstantDamage

type InstantDamage struct {
	// Potency specifies the potency of the instant damage. By default, this value is 1, which means 100% of
	// the instant damage will be applied to an entity. A lingering damage potion, for example, has a potency
	// of 0.5: It deals 1.5 hearts damage (per tick) instead of 3.
	Potency float64
}

InstantDamage is an instant effect that causes a living entity to immediately take some damage, depending on the level and the potency of the effect.

func (InstantDamage) Apply

func (i InstantDamage) Apply(e world.Entity, lvl int, _ time.Duration)

Apply ...

func (InstantDamage) RGBA

func (InstantDamage) RGBA() color.RGBA

RGBA ...

func (InstantDamage) WithPotency added in v0.5.0

func (i InstantDamage) WithPotency(potency float64) Type

WithPotency ...

type InstantHealth

type InstantHealth struct {
	// Potency specifies the potency of the instant health. By default, this value is 1, which means 100% of
	// the instant health will be applied to an entity. A lingering health potion, for example, has a potency
	// of 0.5: It heals 1 heart (per tick) instead of 2.
	Potency float64
}

InstantHealth is an instant effect that causes the player that it is applied to immediately regain some health. The amount of health regained depends on the effect level and potency.

func (InstantHealth) Apply

func (i InstantHealth) Apply(e world.Entity, lvl int, _ time.Duration)

Apply instantly heals the world.Entity passed for a bit of health, depending on the effect level and potency.

func (InstantHealth) RGBA

func (InstantHealth) RGBA() color.RGBA

RGBA ...

func (InstantHealth) WithPotency added in v0.5.0

func (i InstantHealth) WithPotency(potency float64) Type

WithPotency ...

type Invisibility

type Invisibility struct {
	// contains filtered or unexported fields
}

Invisibility is a lasting effect that causes the affected entity to turn invisible. While invisible, the entity's armour is still visible and effect particles will still be displayed.

func (Invisibility) Apply

func (Invisibility) Apply(world.Entity, int, time.Duration)

func (Invisibility) End

func (Invisibility) End(e world.Entity, _ int)

End ...

func (Invisibility) RGBA

func (Invisibility) RGBA() color.RGBA

RGBA ...

func (Invisibility) Start

func (Invisibility) Start(e world.Entity, _ int)

Start ...

type JumpBoost

type JumpBoost struct {
	// contains filtered or unexported fields
}

JumpBoost is a lasting effect that causes the affected entity to be able to jump much higher, depending on the level of the effect.

func (JumpBoost) Apply

func (JumpBoost) Apply(world.Entity, int, time.Duration)

func (JumpBoost) End

func (JumpBoost) End(world.Entity, int)

func (JumpBoost) RGBA

func (JumpBoost) RGBA() color.RGBA

RGBA ...

func (JumpBoost) Start

func (JumpBoost) Start(world.Entity, int)

type LastingType added in v0.3.0

type LastingType interface {
	Type
	// Start is called for lasting effects when they are initially added to an entity.
	Start(e world.Entity, lvl int)
	// End is called for lasting effects when they are removed from an entity.
	End(e world.Entity, lvl int)
}

LastingType represents an effect type that can have a duration. An effect can be made using it by calling effect.New with the LastingType.

type Levitation

type Levitation struct {
	// contains filtered or unexported fields
}

Levitation is a lasting effect that causes the affected entity to slowly levitate upwards. It is roughly the opposite of the SlowFalling effect.

func (Levitation) Apply

func (Levitation) Apply(world.Entity, int, time.Duration)

func (Levitation) End

func (Levitation) End(world.Entity, int)

func (Levitation) RGBA

func (Levitation) RGBA() color.RGBA

RGBA ...

func (Levitation) Start

func (Levitation) Start(world.Entity, int)

type MiningFatigue

type MiningFatigue struct {
	// contains filtered or unexported fields
}

MiningFatigue is a lasting effect that decreases the mining speed of a player by 10% for each level of the effect.

func (MiningFatigue) Apply

func (MiningFatigue) Apply(world.Entity, int, time.Duration)

func (MiningFatigue) End

func (MiningFatigue) End(world.Entity, int)

func (MiningFatigue) Multiplier

func (MiningFatigue) Multiplier(lvl int) float64

Multiplier returns the mining speed multiplier from this effect.

func (MiningFatigue) RGBA

func (MiningFatigue) RGBA() color.RGBA

RGBA ...

func (MiningFatigue) Start

func (MiningFatigue) Start(world.Entity, int)

type Nausea

type Nausea struct {
	// contains filtered or unexported fields
}

Nausea is a lasting effect that causes the screen to warp, similarly to when entering a nether portal.

func (Nausea) Apply

func (Nausea) Apply(world.Entity, int, time.Duration)

func (Nausea) End

func (Nausea) End(world.Entity, int)

func (Nausea) RGBA

func (Nausea) RGBA() color.RGBA

RGBA ...

func (Nausea) Start

func (Nausea) Start(world.Entity, int)

type NightVision

type NightVision struct {
	// contains filtered or unexported fields
}

NightVision is a lasting effect that causes the affected entity to see in dark places as though they were fully lit up.

func (NightVision) Apply

func (NightVision) Apply(world.Entity, int, time.Duration)

func (NightVision) End

func (NightVision) End(world.Entity, int)

func (NightVision) RGBA

func (NightVision) RGBA() color.RGBA

RGBA ...

func (NightVision) Start

func (NightVision) Start(world.Entity, int)

type Poison

type Poison struct {
	// contains filtered or unexported fields
}

Poison is a lasting effect that causes the affected entity to lose health gradually. Poison cannot kill, unlike FatalPoison.

func (Poison) Apply

func (Poison) Apply(e world.Entity, lvl int, d time.Duration)

Apply ...

func (Poison) End

func (Poison) End(world.Entity, int)

func (Poison) RGBA

func (Poison) RGBA() color.RGBA

RGBA ...

func (Poison) Start

func (Poison) Start(world.Entity, int)

type PotentType added in v0.5.0

type PotentType interface {
	Type
	// WithPotency updates the potency of the type with the one given and returns it.
	WithPotency(potency float64) Type
}

PotentType represents an effect type which can have its potency changed.

type Regeneration

type Regeneration struct {
	// contains filtered or unexported fields
}

Regeneration is an effect that causes the entity that it is added to slowly regenerate health. The level of the effect influences the speed with which the entity regenerates.

func (Regeneration) Apply

func (Regeneration) Apply(e world.Entity, lvl int, d time.Duration)

Apply applies health to the world.Entity passed if the duration of the effect is at the right tick.

func (Regeneration) End

func (Regeneration) End(world.Entity, int)

func (Regeneration) RGBA

func (Regeneration) RGBA() color.RGBA

RGBA ...

func (Regeneration) Start

func (Regeneration) Start(world.Entity, int)

type Resistance

type Resistance struct {
	// contains filtered or unexported fields
}

Resistance is a lasting effect that reduces the damage taken from any sources except for void damage or custom damage.

func (Resistance) Apply

func (Resistance) Apply(world.Entity, int, time.Duration)

func (Resistance) End

func (Resistance) End(world.Entity, int)

func (Resistance) Multiplier

func (Resistance) Multiplier(e damage.Source, lvl int) float64

Multiplier returns a damage multiplier for the damage source passed.

func (Resistance) RGBA

func (Resistance) RGBA() color.RGBA

RGBA ...

func (Resistance) Start

func (Resistance) Start(world.Entity, int)

type Saturation

type Saturation struct {
	// contains filtered or unexported fields
}

Saturation is a lasting effect that causes the affected player to regain food and saturation.

func (Saturation) Apply

func (Saturation) Apply(e world.Entity, lvl int, _ time.Duration)

Apply ...

func (Saturation) End

func (Saturation) End(world.Entity, int)

func (Saturation) RGBA

func (Saturation) RGBA() color.RGBA

RGBA ...

func (Saturation) Start

func (Saturation) Start(world.Entity, int)

type SlowFalling

type SlowFalling struct {
	// contains filtered or unexported fields
}

SlowFalling is a lasting effect that causes the affected entity to fall very slowly.

func (SlowFalling) Apply

func (SlowFalling) Apply(world.Entity, int, time.Duration)

func (SlowFalling) End

func (SlowFalling) End(world.Entity, int)

func (SlowFalling) RGBA

func (SlowFalling) RGBA() color.RGBA

RGBA ...

func (SlowFalling) Start

func (SlowFalling) Start(world.Entity, int)

type Slowness

type Slowness struct {
	// contains filtered or unexported fields
}

Slowness is a lasting effect that decreases the movement speed of a living entity by 15% for each level that the effect has.

func (Slowness) Apply

func (Slowness) Apply(world.Entity, int, time.Duration)

func (Slowness) End

func (Slowness) End(e world.Entity, lvl int)

End ...

func (Slowness) RGBA

func (Slowness) RGBA() color.RGBA

RGBA ...

func (Slowness) Start

func (Slowness) Start(e world.Entity, lvl int)

Start ...

type Speed

type Speed struct {
	// contains filtered or unexported fields
}

Speed is a lasting effect that increases the speed of an entity by 20% for each level that the effect has.

func (Speed) Apply

func (Speed) Apply(world.Entity, int, time.Duration)

func (Speed) End

func (Speed) End(e world.Entity, lvl int)

End ...

func (Speed) RGBA

func (Speed) RGBA() color.RGBA

RGBA ...

func (Speed) Start

func (Speed) Start(e world.Entity, lvl int)

Start ...

type Strength

type Strength struct {
	// contains filtered or unexported fields
}

Strength is a lasting effect that increases the damage dealt with melee attacks when applied to an entity.

func (Strength) Apply

func (Strength) Apply(world.Entity, int, time.Duration)

func (Strength) End

func (Strength) End(world.Entity, int)

func (Strength) Multiplier

func (Strength) Multiplier(lvl int) float64

Multiplier returns the damage multiplier of the effect.

func (Strength) RGBA

func (Strength) RGBA() color.RGBA

RGBA ...

func (Strength) Start

func (Strength) Start(world.Entity, int)

type Type added in v0.3.0

type Type interface {
	// RGBA returns the colour of the effect. If multiple effects are present, the colours will be mixed
	// together to form a new colour.
	RGBA() color.RGBA
	// Apply applies the effect to an entity. This method applies the effect to an entity once for instant effects, such
	// as healing the world.Entity for instant health.
	// Apply always has a duration of 0 passed to it for instant effect implementations. For lasting effects that
	// implement LastingType, the appropriate leftover duration is passed.
	Apply(e world.Entity, lvl int, d time.Duration)
}

Type is an effect implementation that can be applied to an entity.

func ByID

func ByID(id int) (Type, bool)

ByID attempts to return an effect by the ID it was registered with. If found, the effect found is returned and the bool true.

type WaterBreathing

type WaterBreathing struct {
	// contains filtered or unexported fields
}

WaterBreathing is a lasting effect that allows the affected entity to breath underwater until the effect expires.

func (WaterBreathing) Apply

func (WaterBreathing) Apply(world.Entity, int, time.Duration)

func (WaterBreathing) End

func (WaterBreathing) End(world.Entity, int)

func (WaterBreathing) RGBA

func (WaterBreathing) RGBA() color.RGBA

RGBA ...

func (WaterBreathing) Start

func (WaterBreathing) Start(world.Entity, int)

type Weakness

type Weakness struct {
	// contains filtered or unexported fields
}

Weakness is a lasting effect that reduces the damage dealt to other entities with melee attacks.

func (Weakness) Apply

func (Weakness) Apply(world.Entity, int, time.Duration)

func (Weakness) End

func (Weakness) End(world.Entity, int)

func (Weakness) Multiplier

func (Weakness) Multiplier(lvl int) float64

Multiplier returns the damage multiplier of the effect.

func (Weakness) RGBA

func (Weakness) RGBA() color.RGBA

RGBA ...

func (Weakness) Start

func (Weakness) Start(world.Entity, int)

type Wither

type Wither struct {
	// contains filtered or unexported fields
}

Wither is a lasting effect that causes an entity to take continuous damage that is capable of killing an entity.

func (Wither) Apply

func (Wither) Apply(e world.Entity, lvl int, d time.Duration)

Apply ...

func (Wither) End

func (Wither) End(world.Entity, int)

func (Wither) RGBA

func (Wither) RGBA() color.RGBA

RGBA ...

func (Wither) Start

func (Wither) Start(world.Entity, int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL