entity

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: MIT Imports: 20 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EyePosition

func EyePosition(e world.Entity) mgl64.Vec3

EyePosition returns the position of the eyes of the entity if the entity implements entity.Eyed, or the actual position if it doesn't.

Types

type AreaEffectCloud added in v0.8.0

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

AreaEffectCloud is the cloud that is created when: lingering potions are thrown; creepers with potion effects explode; dragon fireballs hit the ground.

func NewAreaEffectCloud added in v0.8.0

func NewAreaEffectCloud(pos mgl64.Vec3, t potion.Potion) *AreaEffectCloud

NewAreaEffectCloud ...

func NewAreaEffectCloudWith added in v0.8.0

func NewAreaEffectCloudWith(pos mgl64.Vec3, t potion.Potion, duration, reapplicationDelay, durationOnUse time.Duration, radius, radiusOnUse, radiusGrowth float64) *AreaEffectCloud

NewAreaEffectCloudWith ...

func (*AreaEffectCloud) Close added in v0.8.0

func (t *AreaEffectCloud) Close() error

Close closes the transform and removes the associated entity from the world.

func (*AreaEffectCloud) Duration added in v0.8.0

func (a *AreaEffectCloud) Duration() time.Duration

Duration returns the duration of the cloud.

func (*AreaEffectCloud) Effects added in v0.8.0

func (a *AreaEffectCloud) Effects() []effect.Effect

Effects returns the effects the area effect cloud provides.

func (*AreaEffectCloud) Position added in v0.8.0

func (t *AreaEffectCloud) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*AreaEffectCloud) Radius added in v0.8.0

func (a *AreaEffectCloud) Radius() (radius, radiusOnUse, radiusGrowth float64)

Radius returns information about the cloud's, radius, change rate, and growth rate.

func (*AreaEffectCloud) Rotation added in v0.8.0

func (t *AreaEffectCloud) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*AreaEffectCloud) SetVelocity added in v0.8.0

func (t *AreaEffectCloud) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*AreaEffectCloud) Tick added in v0.8.0

func (a *AreaEffectCloud) Tick(w *world.World, _ int64)

Tick ...

func (*AreaEffectCloud) Type added in v0.8.7

func (a *AreaEffectCloud) Type() world.EntityType

Type returns AreaEffectCloudType.

func (*AreaEffectCloud) Velocity added in v0.8.0

func (t *AreaEffectCloud) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*AreaEffectCloud) World added in v0.8.0

func (t *AreaEffectCloud) World() *world.World

World returns the world of the entity.

type AreaEffectCloudType added in v0.8.7

type AreaEffectCloudType struct{}

AreaEffectCloudType is a world.EntityType implementation for AreaEffectCloud.

func (AreaEffectCloudType) BBox added in v0.8.7

func (AreaEffectCloudType) DecodeNBT added in v0.8.7

func (AreaEffectCloudType) DecodeNBT(m map[string]any) world.Entity

func (AreaEffectCloudType) EncodeEntity added in v0.8.7

func (AreaEffectCloudType) EncodeEntity() string

func (AreaEffectCloudType) EncodeNBT added in v0.8.7

func (AreaEffectCloudType) EncodeNBT(e world.Entity) map[string]any

type Arrow added in v0.6.0

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

Arrow is used as ammunition for bows, crossbows, and dispensers. Arrows can be modified to imbue status effects on players and mobs.

func NewArrow added in v0.6.0

func NewArrow(pos mgl64.Vec3, yaw, pitch float64, owner world.Entity) *Arrow

NewArrow creates a new Arrow and returns it. It is equivalent to calling NewTippedArrow with `potion.Potion{}` as tip.

func NewArrowWithDamage added in v0.8.0

func NewArrowWithDamage(pos mgl64.Vec3, yaw, pitch, damage float64, owner world.Entity) *Arrow

NewArrowWithDamage creates a new Arrow with the given base damage, and returns it. It is equivalent to calling NewTippedArrowWithDamage with `potion.Potion{}` as tip.

func NewTippedArrow added in v0.6.0

func NewTippedArrow(pos mgl64.Vec3, yaw, pitch float64, owner world.Entity, tip potion.Potion) *Arrow

NewTippedArrow creates a new Arrow with a potion effect added to an entity when hit.

func NewTippedArrowWithDamage added in v0.8.0

func NewTippedArrowWithDamage(pos mgl64.Vec3, yaw, pitch, damage float64, owner world.Entity, tip potion.Potion) *Arrow

NewTippedArrowWithDamage creates a new Arrow with a potion effect added to an entity when hit and, and returns it. It uses the given damage as the base damage.

func (*Arrow) BaseDamage added in v0.6.0

func (a *Arrow) BaseDamage() float64

BaseDamage returns the base damage the arrow will deal, before accounting for velocity.

func (*Arrow) Close added in v0.6.0

func (t *Arrow) Close() error

Close closes the transform and removes the associated entity from the world.

func (*Arrow) CollisionPos added in v0.6.0

func (a *Arrow) CollisionPos() (cube.Pos, bool)

CollisionPos returns the position of the block the arrow collided with. If the arrow has not collided with any blocks, it returns false for it's second parameter.

func (*Arrow) Critical added in v0.6.0

func (a *Arrow) Critical() bool

Critical returns the critical state of the arrow, which can result in more damage and extra particles while in air.

func (*Arrow) DisallowPickup added in v0.6.0

func (a *Arrow) DisallowPickup()

DisallowPickup prevents the Arrow from being picked up by any entity.

func (*Arrow) Explode added in v0.8.0

func (a *Arrow) Explode(explosionPos mgl64.Vec3, impact float64, _ block.ExplosionConfig)

Explode ...

func (*Arrow) Extinguish added in v0.8.0

func (a *Arrow) Extinguish()

Extinguish ...

func (*Arrow) FireProof added in v0.8.0

func (a *Arrow) FireProof() bool

FireProof ...

func (*Arrow) New added in v0.6.0

func (a *Arrow) New(pos, vel mgl64.Vec3, yaw, pitch, damage float64, owner world.Entity, critical, disallowPickup, obtainArrowOnPickup bool, punchLevel int, tip potion.Potion) world.Entity

New creates and returns an Arrow with the position, velocity, yaw, and pitch provided. It doesn't spawn the Arrow by itself.

func (*Arrow) OnFireDuration added in v0.8.0

func (a *Arrow) OnFireDuration() time.Duration

OnFireDuration ...

func (*Arrow) Owner added in v0.6.0

func (a *Arrow) Owner() world.Entity

Owner returns the world.Entity that fired the Arrow, or nil if it did not have any.

func (*Arrow) Position added in v0.6.0

func (t *Arrow) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*Arrow) Rotation added in v0.6.0

func (a *Arrow) Rotation() cube.Rotation

Rotation ...

func (*Arrow) SetCritical added in v0.6.0

func (a *Arrow) SetCritical()

SetCritical sets the critical state of the arrow to true, which can result in more damage and extra particles while in air.

func (*Arrow) SetOnFire added in v0.8.0

func (a *Arrow) SetOnFire(duration time.Duration)

SetOnFire ...

func (*Arrow) SetVelocity added in v0.6.0

func (t *Arrow) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*Arrow) Tick added in v0.6.0

func (a *Arrow) Tick(w *world.World, current int64)

Tick ...

func (*Arrow) Tip added in v0.6.0

func (a *Arrow) Tip() potion.Potion

Tip returns the potion effect at the tip of the arrow, applied on impact to an entity. This also causes the arrow to show effect particles until it is removed.

func (*Arrow) Type added in v0.8.7

func (a *Arrow) Type() world.EntityType

Type returns ArrowType.

func (*Arrow) VanishOnPickup added in v0.6.0

func (a *Arrow) VanishOnPickup()

VanishOnPickup makes the Arrow vanish on pickup, giving the entity that picked it up no arrow item.

func (*Arrow) Velocity added in v0.6.0

func (t *Arrow) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*Arrow) World added in v0.6.0

func (t *Arrow) World() *world.World

World returns the world of the entity.

type ArrowShakeAction added in v0.6.0

type ArrowShakeAction struct {
	// Duration is the duration of the shake.
	Duration time.Duration
	// contains filtered or unexported fields
}

ArrowShakeAction makes an arrow entity display a shaking animation for the given duration.

func (ArrowShakeAction) EntityAction added in v0.6.0

func (ArrowShakeAction) EntityAction()

type ArrowType added in v0.8.7

type ArrowType struct{}

ArrowType is a world.EntityType implementation for Arrow.

func (ArrowType) BBox added in v0.8.7

func (ArrowType) BBox(world.Entity) cube.BBox

func (ArrowType) DecodeNBT added in v0.8.7

func (ArrowType) DecodeNBT(m map[string]any) world.Entity

func (ArrowType) EncodeEntity added in v0.8.7

func (ArrowType) EncodeEntity() string

func (ArrowType) EncodeNBT added in v0.8.7

func (ArrowType) EncodeNBT(e world.Entity) map[string]any

type AttackDamageSource added in v0.8.6

type AttackDamageSource struct {
	// Attacker holds the attacking entity. The entity may be a player or
	// any other entity.
	Attacker world.Entity
}

AttackDamageSource is used for damage caused by other entities, for example when a player attacks another player.

func (AttackDamageSource) Fire added in v0.8.6

func (AttackDamageSource) Fire() bool

func (AttackDamageSource) ReducedByArmour added in v0.8.6

func (AttackDamageSource) ReducedByArmour() bool

func (AttackDamageSource) ReducedByResistance added in v0.8.6

func (AttackDamageSource) ReducedByResistance() bool

type BottleOfEnchanting added in v0.8.0

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

BottleOfEnchanting is a bottle that releases experience orbs when thrown.

func NewBottleOfEnchanting added in v0.8.0

func NewBottleOfEnchanting(pos mgl64.Vec3, owner world.Entity) *BottleOfEnchanting

NewBottleOfEnchanting ...

func (*BottleOfEnchanting) Close added in v0.8.0

func (t *BottleOfEnchanting) Close() error

Close closes the transform and removes the associated entity from the world.

func (*BottleOfEnchanting) Glint added in v0.8.0

func (b *BottleOfEnchanting) Glint() bool

Glint returns true if the bottle should render with glint. It always returns true.

func (*BottleOfEnchanting) New added in v0.8.0

func (b *BottleOfEnchanting) New(pos, vel mgl64.Vec3, owner world.Entity) world.Entity

New creates a BottleOfEnchanting with the position, velocity, yaw, and pitch provided. It doesn't spawn the BottleOfEnchanting, only returns it.

func (*BottleOfEnchanting) Owner added in v0.8.0

func (b *BottleOfEnchanting) Owner() world.Entity

Owner ...

func (*BottleOfEnchanting) Position added in v0.8.0

func (t *BottleOfEnchanting) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*BottleOfEnchanting) Rotation added in v0.8.0

func (t *BottleOfEnchanting) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*BottleOfEnchanting) SetVelocity added in v0.8.0

func (t *BottleOfEnchanting) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*BottleOfEnchanting) Tick added in v0.8.0

func (b *BottleOfEnchanting) Tick(w *world.World, current int64)

Tick ...

func (*BottleOfEnchanting) Type added in v0.8.7

Type returns BottleOfEnchantingType.

func (*BottleOfEnchanting) Velocity added in v0.8.0

func (t *BottleOfEnchanting) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*BottleOfEnchanting) World added in v0.8.0

func (t *BottleOfEnchanting) World() *world.World

World returns the world of the entity.

type BottleOfEnchantingType added in v0.8.7

type BottleOfEnchantingType struct{}

BottleOfEnchantingType is a world.EntityType for BottleOfEnchanting.

func (BottleOfEnchantingType) BBox added in v0.8.7

func (BottleOfEnchantingType) DecodeNBT added in v0.8.7

func (BottleOfEnchantingType) DecodeNBT(m map[string]any) world.Entity

func (BottleOfEnchantingType) EncodeEntity added in v0.8.7

func (BottleOfEnchantingType) EncodeEntity() string

func (BottleOfEnchantingType) EncodeNBT added in v0.8.7

func (BottleOfEnchantingType) EncodeNBT(e world.Entity) map[string]any

type Collector

type Collector interface {
	world.Entity
	// Collect collects the stack passed. It is called if the Collector is standing near an item entity that
	// may be picked up.
	// The count of items collected from the stack n is returned.
	Collect(stack item.Stack) (n int)
	// GameMode returns the gamemode of the collector.
	GameMode() world.GameMode
}

Collector represents an entity in the world that is able to collect an item, typically an entity such as a player or a zombie.

type CriticalHitAction added in v0.6.0

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

CriticalHitAction is a world.EntityAction that makes an entity display critical hit particles. This will show stars around the entity.

func (CriticalHitAction) EntityAction added in v0.6.0

func (CriticalHitAction) EntityAction()

type DeathAction added in v0.6.0

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

DeathAction is a world.EntityAction that makes an entity display the death animation. After this animation, the entity disappears from viewers watching it.

func (DeathAction) EntityAction added in v0.6.0

func (DeathAction) EntityAction()

type DrowningDamageSource added in v0.8.6

type DrowningDamageSource struct{}

DrowningDamageSource is used for damage caused by an entity drowning in water.

func (DrowningDamageSource) Fire added in v0.8.6

func (DrowningDamageSource) Fire() bool

func (DrowningDamageSource) ReducedByArmour added in v0.8.6

func (DrowningDamageSource) ReducedByArmour() bool

func (DrowningDamageSource) ReducedByResistance added in v0.8.6

func (DrowningDamageSource) ReducedByResistance() bool

type EatAction added in v0.6.0

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

EatAction is a world.EntityAction that makes an entity display the eating particles at its mouth to viewers with the item in its hand being eaten.

func (EatAction) EntityAction added in v0.6.0

func (EatAction) EntityAction()

type EffectManager

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

EffectManager manages the effects of an entity. The effect manager will only store effects that last for a specific duration. Instant effects are applied instantly and not stored.

func NewEffectManager

func NewEffectManager() *EffectManager

NewEffectManager creates and returns a new initialised EffectManager.

func (*EffectManager) Add

func (m *EffectManager) Add(e effect.Effect, entity Living) effect.Effect

Add adds an effect to the manager. If the effect is instant, it is applied to the Living entity passed immediately. If not, the effect is added to the EffectManager and is applied to the entity every time the Tick method is called. Effect levels of 0 or below will not do anything. Effect returns the final effect it added to the entity. That might be the effect passed or an effect with a higher level/duration than the one passed. Add panics if the effect has a negative duration or level.

func (*EffectManager) Effect added in v0.5.0

func (m *EffectManager) Effect(e effect.Type) (effect.Effect, bool)

Effect returns the effect instance and true if the entity has the effect. If not found, it will return an empty effect instance and false.

func (*EffectManager) Effects

func (m *EffectManager) Effects() []effect.Effect

Effects returns a list of all effects currently present in the effect manager. This will never include effects that have expired.

func (*EffectManager) Remove

func (m *EffectManager) Remove(e effect.Type, entity Living)

Remove removes any Effect present in the EffectManager with the type of the effect passed.

func (*EffectManager) Tick

func (m *EffectManager) Tick(entity Living)

Tick ticks the EffectManager, applying all of its effects to the Living entity passed when applicable and removing expired effects.

type Egg added in v0.8.1

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

Egg is an item that can be used to craft food items, or as a throwable entity to spawn chicks.

func NewEgg added in v0.8.1

func NewEgg(pos mgl64.Vec3, owner world.Entity) *Egg

NewEgg ...

func (*Egg) Close added in v0.8.1

func (t *Egg) Close() error

Close closes the transform and removes the associated entity from the world.

func (*Egg) Explode added in v0.8.1

func (e *Egg) Explode(src mgl64.Vec3, force float64, _ block.ExplosionConfig)

Explode ...

func (*Egg) New added in v0.8.1

func (*Egg) New(pos, vel mgl64.Vec3, owner world.Entity) world.Entity

New creates a egg with the position, velocity, yaw, and pitch provided. It doesn't spawn the egg, only returns it.

func (*Egg) Owner added in v0.8.1

func (e *Egg) Owner() world.Entity

Owner ...

func (*Egg) Position added in v0.8.1

func (t *Egg) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*Egg) Rotation added in v0.8.1

func (t *Egg) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*Egg) SetVelocity added in v0.8.1

func (t *Egg) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*Egg) Tick added in v0.8.1

func (e *Egg) Tick(w *world.World, current int64)

Tick ...

func (*Egg) Type added in v0.8.7

func (e *Egg) Type() world.EntityType

Type returns EggType.

func (*Egg) Velocity added in v0.8.1

func (t *Egg) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*Egg) World added in v0.8.1

func (t *Egg) World() *world.World

World returns the world of the entity.

type EggType added in v0.8.7

type EggType struct{}

EggType is a world.EntityType implementation for Egg.

func (EggType) BBox added in v0.8.7

func (EggType) BBox(world.Entity) cube.BBox

func (EggType) DecodeNBT added in v0.8.7

func (EggType) DecodeNBT(m map[string]any) world.Entity

func (EggType) EncodeEntity added in v0.8.7

func (EggType) EncodeEntity() string

func (EggType) EncodeNBT added in v0.8.7

func (EggType) EncodeNBT(e world.Entity) map[string]any

type EnderPearl added in v0.5.0

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

EnderPearl is a smooth, greenish-blue item used to teleport and to make an eye of ender.

func NewEnderPearl added in v0.5.0

func NewEnderPearl(pos mgl64.Vec3, owner world.Entity) *EnderPearl

NewEnderPearl ...

func (*EnderPearl) Close added in v0.5.0

func (t *EnderPearl) Close() error

Close closes the transform and removes the associated entity from the world.

func (*EnderPearl) Explode added in v0.8.0

func (e *EnderPearl) Explode(explosionPos mgl64.Vec3, impact float64, _ block.ExplosionConfig)

Explode ...

func (*EnderPearl) New added in v0.5.0

func (e *EnderPearl) New(pos, vel mgl64.Vec3, owner world.Entity) world.Entity

New creates an ender pearl with the position, velocity, yaw, and pitch provided. It doesn't spawn the ender pearl, only returns it.

func (*EnderPearl) Owner added in v0.5.0

func (e *EnderPearl) Owner() world.Entity

Owner ...

func (*EnderPearl) Position added in v0.5.0

func (t *EnderPearl) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*EnderPearl) Rotation added in v0.5.0

func (t *EnderPearl) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*EnderPearl) SetVelocity added in v0.5.0

func (t *EnderPearl) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*EnderPearl) Tick added in v0.5.0

func (e *EnderPearl) Tick(w *world.World, current int64)

Tick ...

func (*EnderPearl) Type added in v0.8.7

func (e *EnderPearl) Type() world.EntityType

Type returns EnderPearlType.

func (*EnderPearl) Velocity added in v0.5.0

func (t *EnderPearl) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*EnderPearl) World added in v0.5.0

func (t *EnderPearl) World() *world.World

World returns the world of the entity.

type EnderPearlType added in v0.8.7

type EnderPearlType struct{}

EnderPearlType is a world.EntityType implementation for EnderPearl.

func (EnderPearlType) BBox added in v0.8.7

func (EnderPearlType) DecodeNBT added in v0.8.7

func (EnderPearlType) DecodeNBT(m map[string]any) world.Entity

func (EnderPearlType) EncodeEntity added in v0.8.7

func (EnderPearlType) EncodeEntity() string

func (EnderPearlType) EncodeNBT added in v0.8.7

func (EnderPearlType) EncodeNBT(e world.Entity) map[string]any

type ExperienceManager added in v0.7.0

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

ExperienceManager manages experience and levels for entities, and provides functions to add, remove, and calculate experience needed for upcoming levels.

func NewExperienceManager added in v0.7.0

func NewExperienceManager() *ExperienceManager

NewExperienceManager returns a new ExperienceManager with no experience.

func (*ExperienceManager) Add added in v0.7.0

func (e *ExperienceManager) Add(amount int) (level int, progress float64)

Add adds experience to the total experience and recalculates the level and progress if necessary. Passing a negative value is valid. If the new experience would otherwise drop below 0, it is set to 0.

func (*ExperienceManager) Experience added in v0.7.0

func (e *ExperienceManager) Experience() int

Experience returns the amount of experience the manager currently has.

func (*ExperienceManager) Level added in v0.7.0

func (e *ExperienceManager) Level() int

Level returns the current experience level.

func (*ExperienceManager) Progress added in v0.7.0

func (e *ExperienceManager) Progress() float64

Progress returns the progress towards the next level.

func (*ExperienceManager) Reset added in v0.7.0

func (e *ExperienceManager) Reset()

Reset resets the total experience, level, and progress of the manager to zero.

func (*ExperienceManager) SetLevel added in v0.7.0

func (e *ExperienceManager) SetLevel(level int)

SetLevel sets the level of the manager.

func (*ExperienceManager) SetProgress added in v0.7.0

func (e *ExperienceManager) SetProgress(progress float64)

SetProgress sets the progress of the manager.

type ExperienceOrb added in v0.7.0

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

ExperienceOrb is an entity that carries a varying amount of experience. These can be collected by nearby players, and are then added to the player's own experience.

func NewExperienceOrb added in v0.7.0

func NewExperienceOrb(pos mgl64.Vec3, xp int) *ExperienceOrb

NewExperienceOrb creates a new experience orb and returns it.

func NewExperienceOrbs added in v0.7.0

func NewExperienceOrbs(pos mgl64.Vec3, amount int) (orbs []*ExperienceOrb)

NewExperienceOrbs takes in a position and an amount and automatically splits the amount into multiple orbs, returning a slice of the created orbs.

func (*ExperienceOrb) Close added in v0.7.0

func (t *ExperienceOrb) Close() error

Close closes the transform and removes the associated entity from the world.

func (*ExperienceOrb) Experience added in v0.7.0

func (e *ExperienceOrb) Experience() int

Experience returns the amount of experience the orb carries.

func (*ExperienceOrb) Explode added in v0.8.0

Explode ...

func (*ExperienceOrb) Position added in v0.7.0

func (t *ExperienceOrb) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*ExperienceOrb) Rotation added in v0.7.0

func (t *ExperienceOrb) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*ExperienceOrb) SetVelocity added in v0.7.0

func (t *ExperienceOrb) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*ExperienceOrb) Tick added in v0.7.0

func (e *ExperienceOrb) Tick(w *world.World, current int64)

Tick ...

func (*ExperienceOrb) Type added in v0.8.7

func (*ExperienceOrb) Type() world.EntityType

Type returns ExperienceOrbType.

func (*ExperienceOrb) Velocity added in v0.7.0

func (t *ExperienceOrb) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*ExperienceOrb) World added in v0.7.0

func (t *ExperienceOrb) World() *world.World

World returns the world of the entity.

type ExperienceOrbType added in v0.8.7

type ExperienceOrbType struct{}

ExperienceOrbType is a world.EntityType implementation for ExperienceOrb.

func (ExperienceOrbType) BBox added in v0.8.7

func (ExperienceOrbType) DecodeNBT added in v0.8.7

func (ExperienceOrbType) DecodeNBT(m map[string]any) world.Entity

func (ExperienceOrbType) EncodeEntity added in v0.8.7

func (ExperienceOrbType) EncodeEntity() string

func (ExperienceOrbType) EncodeNBT added in v0.8.7

func (ExperienceOrbType) EncodeNBT(e world.Entity) map[string]any

type ExplosionDamageSource added in v0.8.6

type ExplosionDamageSource struct{}

ExplosionDamageSource is used for damage caused by an explosion.

func (ExplosionDamageSource) AffectedByEnchantment added in v0.8.6

func (ExplosionDamageSource) AffectedByEnchantment(e item.EnchantmentType) bool

func (ExplosionDamageSource) Fire added in v0.8.6

func (ExplosionDamageSource) Fire() bool

func (ExplosionDamageSource) ReducedByArmour added in v0.8.6

func (ExplosionDamageSource) ReducedByArmour() bool

func (ExplosionDamageSource) ReducedByResistance added in v0.8.6

func (ExplosionDamageSource) ReducedByResistance() bool

type Eyed

type Eyed interface {
	// EyeHeight returns the offset from their base position that the eyes of an entity are found at.
	EyeHeight() float64
}

Eyed represents an entity that has eyes.

type FallDamageSource added in v0.8.6

type FallDamageSource struct{}

FallDamageSource is used for damage caused by falling.

func (FallDamageSource) AffectedByEnchantment added in v0.8.6

func (FallDamageSource) AffectedByEnchantment(e item.EnchantmentType) bool

func (FallDamageSource) Fire added in v0.8.6

func (FallDamageSource) Fire() bool

func (FallDamageSource) ReducedByArmour added in v0.8.6

func (FallDamageSource) ReducedByArmour() bool

func (FallDamageSource) ReducedByResistance added in v0.8.6

func (FallDamageSource) ReducedByResistance() bool

type FallingBlock

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

FallingBlock is the entity form of a block that appears when a gravity-affected block loses its support.

func NewFallingBlock

func NewFallingBlock(block world.Block, pos mgl64.Vec3) *FallingBlock

NewFallingBlock creates a new FallingBlock entity.

func (*FallingBlock) Block

func (f *FallingBlock) Block() world.Block

Block ...

func (*FallingBlock) Close

func (t *FallingBlock) Close() error

Close closes the transform and removes the associated entity from the world.

func (*FallingBlock) Explode added in v0.8.0

Explode ...

func (*FallingBlock) FallDistance added in v0.7.3

func (f *FallingBlock) FallDistance() float64

FallDistance ...

func (*FallingBlock) New added in v0.8.0

func (f *FallingBlock) New(bl world.Block, pos mgl64.Vec3) world.Entity

New creates and returns an FallingBlock with the world.Block and position provided. It doesn't spawn the FallingBlock by itself.

func (*FallingBlock) Position

func (t *FallingBlock) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*FallingBlock) Rotation added in v0.1.0

func (t *FallingBlock) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*FallingBlock) SetVelocity

func (t *FallingBlock) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*FallingBlock) Tick

func (f *FallingBlock) Tick(w *world.World, _ int64)

Tick ...

func (*FallingBlock) Type added in v0.8.7

func (*FallingBlock) Type() world.EntityType

Type returns FallingBlockType.

func (*FallingBlock) Velocity

func (t *FallingBlock) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*FallingBlock) World

func (t *FallingBlock) World() *world.World

World returns the world of the entity.

type FallingBlockType added in v0.8.7

type FallingBlockType struct{}

FallingBlockType is a world.EntityType implementation for FallingBlock.

func (FallingBlockType) BBox added in v0.8.7

func (FallingBlockType) DecodeNBT added in v0.8.7

func (FallingBlockType) DecodeNBT(m map[string]any) world.Entity

func (FallingBlockType) EncodeEntity added in v0.8.7

func (FallingBlockType) EncodeEntity() string

func (FallingBlockType) EncodeNBT added in v0.8.7

func (FallingBlockType) EncodeNBT(e world.Entity) map[string]any

type Firework added in v0.8.0

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

Firework is an item (and entity) used for creating decorative explosions, boosting when flying with elytra, and loading into a crossbow as ammunition.

func NewFirework added in v0.8.0

func NewFirework(pos mgl64.Vec3, yaw, pitch float64, firework item.Firework) *Firework

NewFirework ...

func (*Firework) Attached added in v0.8.0

func (f *Firework) Attached() bool

Attached returns true if the firework is currently attached to the owner. This is mainly the case with gliding.

func (*Firework) Close added in v0.8.0

func (t *Firework) Close() error

Close closes the transform and removes the associated entity from the world.

func (*Firework) Firework added in v0.8.0

func (f *Firework) Firework() item.Firework

Firework returns the underlying item.Firework of the Firework.

func (*Firework) New added in v0.8.0

func (f *Firework) New(pos mgl64.Vec3, yaw, pitch float64, attached bool, firework item.Firework, owner world.Entity) world.Entity

New creates a firework with the position, velocity, yaw, and pitch provided. It doesn't spawn the firework, only returns it.

func (*Firework) Owner added in v0.8.0

func (f *Firework) Owner() world.Entity

Owner ...

func (*Firework) Position added in v0.8.0

func (t *Firework) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*Firework) Rotation added in v0.8.0

func (f *Firework) Rotation() cube.Rotation

Rotation ...

func (*Firework) SetVelocity added in v0.8.0

func (t *Firework) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*Firework) Tick added in v0.8.0

func (f *Firework) Tick(w *world.World, current int64)

Tick ...

func (*Firework) Type added in v0.8.7

func (f *Firework) Type() world.EntityType

Type returns FireworkType.

func (*Firework) Velocity added in v0.8.0

func (t *Firework) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*Firework) World added in v0.8.0

func (t *Firework) World() *world.World

World returns the world of the entity.

type FireworkExplosionAction added in v0.8.0

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

FireworkExplosionAction is a world.EntityAction that makes a Firework rocket display an explosion particle.

func (FireworkExplosionAction) EntityAction added in v0.8.0

func (FireworkExplosionAction) EntityAction()

type FireworkType added in v0.8.7

type FireworkType struct{}

FireworkType is a world.EntityType implementation for Firework.

func (FireworkType) BBox added in v0.8.7

func (FireworkType) DecodeNBT added in v0.8.7

func (FireworkType) DecodeNBT(m map[string]any) world.Entity

func (FireworkType) EncodeEntity added in v0.8.7

func (FireworkType) EncodeEntity() string

func (FireworkType) EncodeNBT added in v0.8.7

func (FireworkType) EncodeNBT(e world.Entity) map[string]any

type Flammable

type Flammable interface {
	// FireProof is whether the entity is currently fireproof.
	FireProof() bool
	// OnFireDuration returns duration of fire in ticks.
	OnFireDuration() time.Duration
	// SetOnFire sets the entity on fire for the specified duration.
	SetOnFire(duration time.Duration)
	// Extinguish extinguishes the entity.
	Extinguish()
}

Flammable is an interface for entities that can be set on fire.

type FoodHealingSource added in v0.8.6

type FoodHealingSource struct{}

FoodHealingSource is a healing source used for when an entity regenerates health automatically when their food bar is at least 90% filled.

func (FoodHealingSource) HealingSource added in v0.8.6

func (FoodHealingSource) HealingSource()

type GlideDamageSource added in v0.8.6

type GlideDamageSource struct{}

GlideDamageSource is used for damage caused by gliding into a block.

func (GlideDamageSource) Fire added in v0.8.6

func (GlideDamageSource) Fire() bool

func (GlideDamageSource) ReducedByArmour added in v0.8.6

func (GlideDamageSource) ReducedByArmour() bool

func (GlideDamageSource) ReducedByResistance added in v0.8.6

func (GlideDamageSource) ReducedByResistance() bool

type HealthManager

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

HealthManager handles the health of an entity.

func NewHealthManager

func NewHealthManager(health, max float64) *HealthManager

NewHealthManager returns a new health manager with the health and max health provided.

func (*HealthManager) AddHealth

func (m *HealthManager) AddHealth(health float64)

AddHealth adds a given amount of health points to the player. If the health added to the current health exceeds the max, health will be set to the max. If the health is instead negative and results in a health lower than 0, the final health will be 0.

func (*HealthManager) Health

func (m *HealthManager) Health() float64

Health returns the current health of an entity.

func (*HealthManager) MaxHealth

func (m *HealthManager) MaxHealth() float64

MaxHealth returns the maximum health of the entity.

func (*HealthManager) SetMaxHealth

func (m *HealthManager) SetMaxHealth(max float64)

SetMaxHealth changes the max health of an entity to the maximum passed. If the maximum is set to 0 or lower, SetMaxHealth will default to a value of 1.

type HurtAction added in v0.6.0

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

HurtAction is a world.EntityAction that makes an entity display the animation for being hurt. The entity will be shown as red for a short duration.

func (HurtAction) EntityAction added in v0.6.0

func (HurtAction) EntityAction()

type Item

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

Item represents an item entity which may be added to the world. Players and several humanoid entities such as zombies are able to pick up these entities so that the items are added to their inventory.

func NewItem

func NewItem(i item.Stack, pos mgl64.Vec3) *Item

NewItem creates a new item entity using the item stack passed. The item entity will be positioned at the position passed. If the stack's count exceeds its max count, the count of the stack will be changed to the maximum.

func (*Item) Close

func (t *Item) Close() error

Close closes the transform and removes the associated entity from the world.

func (*Item) Explode added in v0.8.0

func (it *Item) Explode(mgl64.Vec3, float64, block.ExplosionConfig)

Explode ...

func (*Item) Item

func (it *Item) Item() item.Stack

Item returns the item stack that the item entity holds.

func (*Item) New added in v0.8.0

func (it *Item) New(stack item.Stack, pos, vel mgl64.Vec3) world.Entity

New creates and returns an Item with the item.Stack, position, and velocity provided. It doesn't spawn the Item by itself.

func (*Item) Position

func (t *Item) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*Item) Rotation added in v0.1.0

func (t *Item) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*Item) SetPickupDelay

func (it *Item) SetPickupDelay(d time.Duration)

SetPickupDelay sets a delay passed until the item can be picked up. If d is negative or d.Seconds()*20 higher than math.MaxInt16, the item will never be able to be picked up.

func (*Item) SetVelocity

func (t *Item) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*Item) Tick

func (it *Item) Tick(w *world.World, current int64)

Tick ticks the entity, performing movement.

func (*Item) Type added in v0.8.7

func (it *Item) Type() world.EntityType

Type returns ItemType.

func (*Item) Velocity

func (t *Item) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*Item) World

func (t *Item) World() *world.World

World returns the world of the entity.

type ItemType added in v0.8.7

type ItemType struct{}

ItemType is a world.EntityType implementation for Item.

func (ItemType) BBox added in v0.8.7

func (ItemType) BBox(world.Entity) cube.BBox

func (ItemType) DecodeNBT added in v0.8.7

func (ItemType) DecodeNBT(m map[string]any) world.Entity

func (ItemType) EncodeEntity added in v0.8.7

func (ItemType) EncodeEntity() string

func (ItemType) EncodeNBT added in v0.8.7

func (ItemType) EncodeNBT(e world.Entity) map[string]any

type Lightning added in v0.3.0

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

Lightning is a lethal element to thunderstorms. Lightning momentarily increases the skylight's brightness to slightly greater than full daylight.

func NewLightning added in v0.3.0

func NewLightning(pos mgl64.Vec3) *Lightning

NewLightning creates a lightning entity. The lightning entity will be positioned at the position passed.

func NewLightningWithDamage added in v0.8.2

func NewLightningWithDamage(pos mgl64.Vec3, dmg float64, blockFire, entityFire bool) *Lightning

NewLightningWithDamage creates a lightning entity but lets you specify damage and whether blocks and entities should be set on fire.

func (*Lightning) Close added in v0.3.0

func (li *Lightning) Close() error

Close closes the lighting.

func (*Lightning) New added in v0.4.0

func (li *Lightning) New(pos mgl64.Vec3) world.Entity

New strikes the Lightning at a specific position in a new world.

func (*Lightning) Position added in v0.3.0

func (li *Lightning) Position() mgl64.Vec3

Position returns the current position of the lightning entity.

func (*Lightning) Rotation added in v0.3.0

func (li *Lightning) Rotation() (c cube.Rotation)

Rotation ...

func (*Lightning) Tick added in v0.3.0

func (li *Lightning) Tick(w *world.World, _ int64)

Tick ...

func (*Lightning) Type added in v0.8.7

func (*Lightning) Type() world.EntityType

Type returns LightningType.

func (*Lightning) World added in v0.3.0

func (li *Lightning) World() *world.World

World returns the world that the lightning entity is currently in, or nil if it is not added to a world.

type LightningDamageSource added in v0.8.6

type LightningDamageSource struct{}

LightningDamageSource is used for damage caused by being struck by lightning.

func (LightningDamageSource) Fire added in v0.8.6

func (LightningDamageSource) Fire() bool

func (LightningDamageSource) ReducedByArmour added in v0.8.6

func (LightningDamageSource) ReducedByArmour() bool

func (LightningDamageSource) ReducedByResistance added in v0.8.6

func (LightningDamageSource) ReducedByResistance() bool

type LightningType added in v0.8.7

type LightningType struct{}

LightningType is a world.EntityType implementation for Lightning.

func (LightningType) BBox added in v0.8.7

func (LightningType) DecodeNBT added in v0.8.7

func (LightningType) DecodeNBT(map[string]any) world.Entity

func (LightningType) EncodeEntity added in v0.8.7

func (LightningType) EncodeEntity() string

func (LightningType) EncodeNBT added in v0.8.7

func (LightningType) EncodeNBT(world.Entity) map[string]any

type LingeringPotion added in v0.8.0

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

LingeringPotion is a variant of a splash potion that can be thrown to leave clouds with status effects that linger on the ground in an area.

func NewLingeringPotion added in v0.8.0

func NewLingeringPotion(pos mgl64.Vec3, owner world.Entity, t potion.Potion) *LingeringPotion

NewLingeringPotion ...

func (*LingeringPotion) Close added in v0.8.0

func (t *LingeringPotion) Close() error

Close closes the transform and removes the associated entity from the world.

func (*LingeringPotion) Glint added in v0.8.0

func (s *LingeringPotion) Glint() bool

Glint returns true if the splashable should render with glint.

func (*LingeringPotion) Lingers added in v0.8.0

func (l *LingeringPotion) Lingers() bool

Lingers always returns true.

func (*LingeringPotion) New added in v0.8.0

func (l *LingeringPotion) New(pos, vel mgl64.Vec3, t potion.Potion, owner world.Entity) world.Entity

New creates a LingeringPotion with the position and velocity provided. It doesn't spawn the LingeringPotion, only returns it.

func (*LingeringPotion) Owner added in v0.8.0

func (l *LingeringPotion) Owner() world.Entity

Owner ...

func (*LingeringPotion) Position added in v0.8.0

func (t *LingeringPotion) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*LingeringPotion) Potion added in v0.8.7

func (s *LingeringPotion) Potion() potion.Potion

Potion returns the type of potion the splashable will grant effects for when thrown.

func (*LingeringPotion) Rotation added in v0.8.0

func (t *LingeringPotion) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*LingeringPotion) SetVelocity added in v0.8.0

func (t *LingeringPotion) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*LingeringPotion) Tick added in v0.8.0

func (l *LingeringPotion) Tick(w *world.World, current int64)

Tick ...

func (*LingeringPotion) Type added in v0.8.0

Type returns LingeringPotionType.

func (*LingeringPotion) Velocity added in v0.8.0

func (t *LingeringPotion) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*LingeringPotion) World added in v0.8.0

func (t *LingeringPotion) World() *world.World

World returns the world of the entity.

type LingeringPotionType added in v0.8.7

type LingeringPotionType struct{}

LingeringPotionType is a world.EntityType implementation for LingeringPotion.

func (LingeringPotionType) BBox added in v0.8.7

func (LingeringPotionType) DecodeNBT added in v0.8.7

func (LingeringPotionType) DecodeNBT(m map[string]any) world.Entity

func (LingeringPotionType) EncodeEntity added in v0.8.7

func (LingeringPotionType) EncodeEntity() string

func (LingeringPotionType) EncodeNBT added in v0.8.7

func (LingeringPotionType) EncodeNBT(e world.Entity) map[string]any

type Living

type Living interface {
	world.Entity
	// Health returns the health of the entity.
	Health() float64
	// MaxHealth returns the maximum health of the entity.
	MaxHealth() float64
	// SetMaxHealth changes the maximum health of the entity to the value passed.
	SetMaxHealth(v float64)
	// Dead checks if the entity is considered dead. True is returned if the health of the entity is equal to or
	// lower than 0.
	Dead() bool
	// AttackImmune checks if the entity is currently immune to entity attacks. Entities typically turn
	// immune for half a second after being attacked.
	AttackImmune() bool
	// Hurt hurts the entity for a given amount of damage. The source passed represents the cause of the
	// damage, for example AttackDamageSource if the entity is attacked by another entity.
	// If the final damage exceeds the health that the entity currently has, the entity is killed.
	// Hurt returns the final amount of damage dealt to the Living entity and returns whether the Living entity
	// was vulnerable to the damage at all.
	Hurt(damage float64, src world.DamageSource) (n float64, vulnerable bool)
	// Heal heals the entity for a given amount of health. The source passed represents the cause of the
	// healing, for example FoodHealingSource if the entity healed by having a full food bar. If the health
	// added to the original health exceeds the entity's max health, Heal may not add the full amount.
	Heal(health float64, src world.HealingSource)
	// KnockBack knocks the entity back with a given force and height. A source is passed which indicates the
	// source of the velocity, typically the position of an attacking entity. The source is used to calculate
	// the direction which the entity should be knocked back in.
	KnockBack(src mgl64.Vec3, force, height float64)
	// Velocity returns the players current velocity.
	Velocity() mgl64.Vec3
	// SetVelocity updates the entity's velocity.
	SetVelocity(velocity mgl64.Vec3)
	// AddEffect adds an entity.Effect to the entity. If the effect is instant, it is applied to the entity
	// immediately. If not, the effect is applied to the entity every time the Tick method is called.
	// AddEffect will overwrite any effects present if the level of the effect is higher than the existing one, or
	// if the effects' levels are equal and the new effect has a longer duration.
	AddEffect(e effect.Effect)
	// RemoveEffect removes any effect that might currently be active on the entity.
	RemoveEffect(e effect.Type)
	// Effects returns any effect currently applied to the entity. The returned effects are guaranteed not to have
	// expired when returned.
	Effects() []effect.Effect
	// Speed returns the current speed of the living entity. The default value is different for each entity.
	Speed() float64
	// SetSpeed sets the speed of an entity to a new value.
	SetSpeed(float64)
}

Living represents an entity that is alive and that has health. It is able to take damage and will die upon taking fatal damage.

type Movement added in v0.4.1

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

Movement represents the movement of a world.Entity as a result of a call to MovementComputer.TickMovement. The resulting position and velocity can be obtained by calling Position and Velocity. These can be sent to viewers by calling Send.

func (*Movement) Position added in v0.4.1

func (m *Movement) Position() mgl64.Vec3

Position returns the position as a result of the Movement as an mgl64.Vec3.

func (*Movement) Rotation added in v0.4.1

func (m *Movement) Rotation() (yaw, pitch float64)

Rotation returns the rotation, yaw and pitch, of the entity after the Movement.

func (*Movement) Send added in v0.4.1

func (m *Movement) Send()

Send sends the Movement to any viewers watching the entity at the time of the movement. If the position/velocity changes were negligible, nothing is sent.

func (*Movement) Velocity added in v0.4.1

func (m *Movement) Velocity() mgl64.Vec3

Velocity returns the velocity after the Movement as an mgl64.Vec3.

type MovementComputer

type MovementComputer struct {
	Gravity, Drag     float64
	DragBeforeGravity bool
	// contains filtered or unexported fields
}

MovementComputer is used to compute movement of an entity. When constructed, the Gravity of the entity the movement is computed for must be passed.

func (*MovementComputer) OnGround

func (c *MovementComputer) OnGround() bool

OnGround checks if the entity that this computer calculates is currently on the ground.

func (*MovementComputer) TickMovement added in v0.2.0

func (c *MovementComputer) TickMovement(e world.Entity, pos, vel mgl64.Vec3, yaw, pitch float64) *Movement

TickMovement performs a movement tick on an entity. Velocity is applied and changed according to the values of its Drag and Gravity. The new position of the entity after movement is returned. The resulting Movement can be sent to viewers by calling Movement.Send.

type PickedUpAction added in v0.6.0

type PickedUpAction struct {
	// Collector is the entity that collected the item.
	Collector world.Entity
	// contains filtered or unexported fields
}

PickedUpAction is a world.EntityAction that makes an item get picked up by a collector. After this animation, the item disappears from viewers watching it.

func (PickedUpAction) EntityAction added in v0.6.0

func (PickedUpAction) EntityAction()

type Projectile added in v0.4.0

type Projectile interface {
	world.Entity
	Owner() world.Entity
}

Projectile is a world.Entity that can be fired by another entity. It has an Owner method.

type ProjectileComputer added in v0.4.0

type ProjectileComputer struct {
	*MovementComputer
	// contains filtered or unexported fields
}

ProjectileComputer is used to compute movement of a projectile. When constructed, a MovementComputer must be passed.

func (*ProjectileComputer) TickMovement added in v0.4.0

func (c *ProjectileComputer) TickMovement(e Projectile, pos, vel mgl64.Vec3, yaw, pitch float64) (*Movement, trace.Result)

TickMovement performs a movement tick on a projectile. Velocity is applied and changed according to the values of its Drag and Gravity. A ray trace is performed to see if the projectile has collided with any block or entity, the ray trace result is returned. The resulting Movement can be sent to viewers by calling Movement.Send.

type ProjectileDamageSource added in v0.8.6

type ProjectileDamageSource struct {
	// Projectile and Owner are the world.Entity that dealt the damage and
	// the one that fired the projectile respectively.
	Projectile, Owner world.Entity
}

ProjectileDamageSource is used for damage caused by a projectile.

func (ProjectileDamageSource) AffectedByEnchantment added in v0.8.6

func (ProjectileDamageSource) AffectedByEnchantment(e item.EnchantmentType) bool

func (ProjectileDamageSource) Fire added in v0.8.6

func (ProjectileDamageSource) ReducedByArmour added in v0.8.6

func (ProjectileDamageSource) ReducedByArmour() bool

func (ProjectileDamageSource) ReducedByResistance added in v0.8.6

func (ProjectileDamageSource) ReducedByResistance() bool

type Snowball added in v0.4.0

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

Snowball is a throwable projectile which damages entities on impact.

func NewSnowball added in v0.4.0

func NewSnowball(pos mgl64.Vec3, owner world.Entity) *Snowball

NewSnowball ...

func (*Snowball) Close added in v0.4.0

func (t *Snowball) Close() error

Close closes the transform and removes the associated entity from the world.

func (*Snowball) Explode added in v0.8.0

func (s *Snowball) Explode(explosionPos mgl64.Vec3, impact float64, _ block.ExplosionConfig)

Explode ...

func (*Snowball) New added in v0.4.0

func (s *Snowball) New(pos, vel mgl64.Vec3, owner world.Entity) world.Entity

New creates a snowball with the position, velocity, yaw, and pitch provided. It doesn't spawn the snowball, only returns it.

func (*Snowball) Owner added in v0.4.0

func (s *Snowball) Owner() world.Entity

Owner ...

func (*Snowball) Position added in v0.4.0

func (t *Snowball) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*Snowball) Rotation added in v0.4.0

func (t *Snowball) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*Snowball) SetVelocity added in v0.4.0

func (t *Snowball) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*Snowball) Tick added in v0.4.0

func (s *Snowball) Tick(w *world.World, current int64)

Tick ...

func (*Snowball) Type added in v0.8.7

func (s *Snowball) Type() world.EntityType

Type returns SnowballType.

func (*Snowball) Velocity added in v0.4.0

func (t *Snowball) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*Snowball) World added in v0.4.0

func (t *Snowball) World() *world.World

World returns the world of the entity.

type SnowballType added in v0.8.7

type SnowballType struct{}

SnowballType is a world.EntityType implementation for Snowball.

func (SnowballType) BBox added in v0.8.7

func (SnowballType) DecodeNBT added in v0.8.7

func (SnowballType) DecodeNBT(m map[string]any) world.Entity

func (SnowballType) EncodeEntity added in v0.8.7

func (SnowballType) EncodeEntity() string

func (SnowballType) EncodeNBT added in v0.8.7

func (SnowballType) EncodeNBT(e world.Entity) map[string]any

type Solidifiable

type Solidifiable interface {
	// Solidifies returns whether the falling block can solidify at the position it is currently in. If so,
	// the block will immediately stop falling.
	Solidifies(pos cube.Pos, w *world.World) bool
}

Solidifiable represents a block that can solidify by specific adjacent blocks. An example is concrete powder, which can turn into concrete by touching water.

type SplashPotion added in v0.5.0

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

SplashPotion is an item that grants effects when thrown.

func NewSplashPotion added in v0.5.0

func NewSplashPotion(pos mgl64.Vec3, owner world.Entity, t potion.Potion) *SplashPotion

NewSplashPotion ...

func (*SplashPotion) Close added in v0.5.0

func (t *SplashPotion) Close() error

Close closes the transform and removes the associated entity from the world.

func (*SplashPotion) Explode added in v0.8.0

func (s *SplashPotion) Explode(explosionPos mgl64.Vec3, impact float64, _ block.ExplosionConfig)

Explode ...

func (*SplashPotion) Glint added in v0.8.0

func (s *SplashPotion) Glint() bool

Glint returns true if the splashable should render with glint.

func (*SplashPotion) New added in v0.5.0

func (s *SplashPotion) New(pos, vel mgl64.Vec3, t potion.Potion, owner world.Entity) world.Entity

New creates a SplashPotion with the position and velocity provided. It doesn't spawn the SplashPotion, only returns it.

func (*SplashPotion) Owner added in v0.5.0

func (s *SplashPotion) Owner() world.Entity

Owner ...

func (*SplashPotion) Position added in v0.5.0

func (t *SplashPotion) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*SplashPotion) Potion added in v0.8.7

func (s *SplashPotion) Potion() potion.Potion

Potion returns the type of potion the splashable will grant effects for when thrown.

func (*SplashPotion) Rotation added in v0.5.0

func (t *SplashPotion) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*SplashPotion) SetVelocity added in v0.5.0

func (t *SplashPotion) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*SplashPotion) Tick added in v0.5.0

func (s *SplashPotion) Tick(w *world.World, current int64)

Tick ...

func (*SplashPotion) Type added in v0.5.0

func (*SplashPotion) Type() world.EntityType

Type returns SplashPotionType.

func (*SplashPotion) Velocity added in v0.5.0

func (t *SplashPotion) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*SplashPotion) World added in v0.5.0

func (t *SplashPotion) World() *world.World

World returns the world of the entity.

type SplashPotionType added in v0.8.7

type SplashPotionType struct{}

SplashPotionType is a world.EntityType implementation for SplashPotion.

func (SplashPotionType) BBox added in v0.8.7

func (SplashPotionType) DecodeNBT added in v0.8.7

func (SplashPotionType) DecodeNBT(m map[string]any) world.Entity

func (SplashPotionType) EncodeEntity added in v0.8.7

func (SplashPotionType) EncodeEntity() string

func (SplashPotionType) EncodeNBT added in v0.8.7

func (SplashPotionType) EncodeNBT(e world.Entity) map[string]any

type SuffocationDamageSource added in v0.8.6

type SuffocationDamageSource struct{}

SuffocationDamageSource is used for damage caused by an entity suffocating in a block.

func (SuffocationDamageSource) Fire added in v0.8.6

func (SuffocationDamageSource) ReducedByArmour added in v0.8.6

func (SuffocationDamageSource) ReducedByArmour() bool

func (SuffocationDamageSource) ReducedByResistance added in v0.8.6

func (SuffocationDamageSource) ReducedByResistance() bool

type SwingArmAction added in v0.6.0

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

SwingArmAction is a world.EntityAction that makes an entity or player swing its arm.

func (SwingArmAction) EntityAction added in v0.6.0

func (SwingArmAction) EntityAction()

type TNT added in v0.8.0

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

TNT represents a primed TNT entity.

func NewTNT added in v0.8.0

func NewTNT(pos mgl64.Vec3, fuse time.Duration) *TNT

NewTNT creates a new prime TNT instance.

func (*TNT) Close added in v0.8.0

func (t *TNT) Close() error

Close closes the transform and removes the associated entity from the world.

func (*TNT) Explode added in v0.8.0

func (t *TNT) Explode(explosionPos mgl64.Vec3, impact float64, _ block.ExplosionConfig)

Explode ...

func (*TNT) Fuse added in v0.8.0

func (t *TNT) Fuse() time.Duration

Fuse returns the remaining duration of the TNT's fuse.

func (*TNT) New added in v0.8.0

func (t *TNT) New(pos mgl64.Vec3, fuse time.Duration) world.Entity

New creates and returns an TNT with the world.Block and position provided. It doesn't spawn the TNT by itself.

func (*TNT) Position added in v0.8.0

func (t *TNT) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*TNT) Rotation added in v0.8.0

func (t *TNT) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*TNT) SetVelocity added in v0.8.0

func (t *TNT) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*TNT) Tick added in v0.8.0

func (t *TNT) Tick(w *world.World, _ int64)

Tick ticks the entity, performing movement.

func (*TNT) Type added in v0.8.7

func (*TNT) Type() world.EntityType

Type returns TNTType.

func (*TNT) Velocity added in v0.8.0

func (t *TNT) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*TNT) World added in v0.8.0

func (t *TNT) World() *world.World

World returns the world of the entity.

type TNTType added in v0.8.7

type TNTType struct{}

TNTType is a world.EntityType implementation for TNT.

func (TNTType) BBox added in v0.8.7

func (TNTType) BBox(world.Entity) cube.BBox

func (TNTType) DecodeNBT added in v0.8.7

func (TNTType) DecodeNBT(m map[string]any) world.Entity

func (TNTType) EncodeEntity added in v0.8.7

func (TNTType) EncodeEntity() string

func (TNTType) EncodeNBT added in v0.8.7

func (TNTType) EncodeNBT(e world.Entity) map[string]any

type Text added in v0.2.0

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

Text is an entity that only displays floating text. The entity is otherwise invisible and cannot be moved.

func NewText added in v0.2.0

func NewText(text string, pos mgl64.Vec3) *Text

NewText creates and returns a new Text entity with the text and position provided.

func (*Text) Close added in v0.2.0

func (t *Text) Close() error

Close closes the transform and removes the associated entity from the world.

func (*Text) Immobile added in v0.2.0

func (t *Text) Immobile() bool

Immobile always returns true.

func (*Text) NameTag added in v0.2.0

func (t *Text) NameTag() string

NameTag returns the designated text of the entity. It is an alias for the Text function.

func (*Text) Position added in v0.2.0

func (t *Text) Position() mgl64.Vec3

Position returns the current position of the entity.

func (*Text) Rotation added in v0.2.0

func (t *Text) Rotation() cube.Rotation

Rotation always returns an empty cube.Rotation.

func (*Text) SetText added in v0.6.1

func (t *Text) SetText(text string)

SetText updates the designated text of the entity.

func (*Text) SetVelocity added in v0.2.0

func (t *Text) SetVelocity(v mgl64.Vec3)

SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.

func (*Text) Text added in v0.6.1

func (t *Text) Text() string

Text returns the designated text of the entity.

func (*Text) Type added in v0.8.7

func (*Text) Type() world.EntityType

Type returns TextType.

func (*Text) Velocity added in v0.2.0

func (t *Text) Velocity() mgl64.Vec3

Velocity returns the current velocity of the entity. The values in the Vec3 returned represent the speed on that axis in blocks/tick.

func (*Text) World added in v0.2.0

func (t *Text) World() *world.World

World returns the world of the entity.

type TextType added in v0.8.7

type TextType struct{}

TextType is a world.EntityType implementation for Text.

func (TextType) BBox added in v0.8.7

func (TextType) BBox(world.Entity) cube.BBox

func (TextType) DecodeNBT added in v0.8.7

func (TextType) DecodeNBT(m map[string]any) world.Entity

func (TextType) EncodeEntity added in v0.8.7

func (TextType) EncodeEntity() string

func (TextType) EncodeNBT added in v0.8.7

func (TextType) EncodeNBT(e world.Entity) map[string]any

func (TextType) NetworkEncodeEntity added in v0.8.7

func (TextType) NetworkEncodeEntity() string

type VoidDamageSource added in v0.8.6

type VoidDamageSource struct{}

VoidDamageSource is used for damage caused by an entity being in the void.

func (VoidDamageSource) Fire added in v0.8.6

func (VoidDamageSource) Fire() bool

func (VoidDamageSource) ReducedByArmour added in v0.8.6

func (VoidDamageSource) ReducedByArmour() bool

func (VoidDamageSource) ReducedByResistance added in v0.8.6

func (VoidDamageSource) ReducedByResistance() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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