effect

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 4 Imported by: 37

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Absorption absorption

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.

View Source
var Blindness blindness

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

View Source
var ConduitPower conduitPower

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.)

View Source
var Darkness darkness

Darkness is a lasting effect that causes the player's vision to dim occasionally.

View Source
var FatalPoison fatalPoison

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.

View Source
var FireResistance fireResistance

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

View Source
var Haste haste

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

View Source
var HealthBoost healthBoost

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

View Source
var Hunger hunger

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

View Source
var InstantDamage instantDamage

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.

View Source
var InstantHealth instantHealth

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.

View Source
var Invisibility invisibility

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.

View Source
var JumpBoost jumpBoost

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

View Source
var Levitation levitation

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

View Source
var MiningFatigue miningFatigue

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

View Source
var Nausea nausea

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

View Source
var NightVision nightVision

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

View Source
var Poison poison

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

View Source
var Regeneration regeneration

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.

View Source
var Resistance resistance

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

View Source
var Saturation saturation

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

View Source
var SlowFalling slowFalling

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

View Source
var Slowness slowness

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

View Source
var Speed speed

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

View Source
var Strength strength

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

View Source
var WaterBreathing waterBreathing

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

View Source
var Weakness weakness

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

View Source
var Wither wither

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

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 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. NewInstant creates an Effect with a potency of 1.0.

func NewInstantWithPotency added in v0.10.0

func NewInstantWithPotency(t Type, lvl int, potency float64) Effect

NewInstantWithPotency returns a new instant Effect using the Type and level passed. The effect will be applied to an entity once and expire immediately after. The potency passed additionally influences the strength of the effect. A higher potency (> 1.0) increases the effect power, while a lower potency (< 1.0) reduces it.

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) Tick added in v0.10.0

func (e Effect) Tick() int

Tick returns the current tick of the Effect. This is the number of ticks that the Effect has been applied for.

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 InstantDamageSource added in v0.8.6

type InstantDamageSource struct{}

InstantDamageSource is used for damage caused by an effect.instantDamage applied to an entity.

func (InstantDamageSource) Fire added in v0.8.6

func (InstantDamageSource) Fire() bool

func (InstantDamageSource) ReducedByArmour added in v0.8.6

func (InstantDamageSource) ReducedByArmour() bool

func (InstantDamageSource) ReducedByResistance added in v0.8.6

func (InstantDamageSource) ReducedByResistance() bool

type InstantHealingSource added in v0.8.6

type InstantHealingSource struct{}

InstantHealingSource is a healing source used when an entity regains health from an effect.instantHealth.

func (InstantHealingSource) HealingSource added in v0.8.6

func (InstantHealingSource) HealingSource()

type LastingType added in v0.3.0

type LastingType interface {
	Type
	// Start is called for lasting effects when they are initially added.
	Start(e world.Entity, lvl int)
	// End is called for lasting effects when they are removed.
	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 PoisonDamageSource added in v0.8.6

type PoisonDamageSource struct {
	// Fatal specifies if the damage was caused by effect.fatalPoison and if
	// the damage could therefore kill the entity.
	Fatal bool
}

PoisonDamageSource is used for damage caused by an effect.poison or effect.fatalPoison applied to an entity.

func (PoisonDamageSource) Fire added in v0.8.6

func (PoisonDamageSource) Fire() bool

func (PoisonDamageSource) ReducedByArmour added in v0.8.6

func (PoisonDamageSource) ReducedByArmour() bool

func (PoisonDamageSource) ReducedByResistance added in v0.8.6

func (PoisonDamageSource) ReducedByResistance() bool

type RegenerationHealingSource added in v0.8.6

type RegenerationHealingSource struct{}

RegenerationHealingSource is a healing source used when an entity regenerates health from an effect.regeneration.

func (RegenerationHealingSource) HealingSource added in v0.8.6

func (RegenerationHealingSource) HealingSource()

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. Apply is called only once for
	// instant effects, such as instantHealth, while it is called every tick for
	// lasting effects. The Effect holding the Type is passed along with the
	// current tick.
	Apply(e world.Entity, eff Effect)
}

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 WitherDamageSource added in v0.8.6

type WitherDamageSource struct{}

WitherDamageSource is used for damage caused by an effect.wither applied to an entity.

func (WitherDamageSource) Fire added in v0.8.6

func (WitherDamageSource) Fire() bool

func (WitherDamageSource) ReducedByArmour added in v0.8.6

func (WitherDamageSource) ReducedByArmour() bool

func (WitherDamageSource) ReducedByResistance added in v0.8.6

func (WitherDamageSource) ReducedByResistance() bool

Jump to

Keyboard shortcuts

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