entity

package
v0.5.16 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirectionVector

func DirectionVector(e world.Entity) mgl64.Vec3

DirectionVector returns a vector that describes the direction of the entity passed. The length of the Vec3 returned is always 1.

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.

func Facing

func Facing(e world.Entity) cube.Direction

Facing returns the horizontal direction that an entity is facing.

Types

type Arrow

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

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 NewTippedArrow

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. The Arrow's base damage may be changed by calling Arrow.SetBaseDamage. It is 2.0 by default.

func (*Arrow) AABB

func (a *Arrow) AABB() physics.AABB

AABB ...

func (*Arrow) BaseDamage

func (a *Arrow) BaseDamage() float64

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

func (*Arrow) Close

func (t *Arrow) Close() error

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

func (*Arrow) CollisionPos

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

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

func (a *Arrow) DecodeNBT(data map[string]interface{}) interface{}

DecodeNBT decodes the properties in a map to an Arrow and returns a new Arrow entity.

func (*Arrow) DisallowPickup

func (a *Arrow) DisallowPickup()

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

func (*Arrow) EncodeEntity

func (a *Arrow) EncodeEntity() string

EncodeEntity ...

func (*Arrow) EncodeNBT

func (a *Arrow) EncodeNBT() map[string]interface{}

EncodeNBT encodes the Arrow entity's properties as a map and returns it.

func (*Arrow) Name

func (a *Arrow) Name() string

Name ...

func (*Arrow) New

func (a *Arrow) New(pos, vel mgl64.Vec3, yaw, pitch float64, owner world.Entity, critical, disallowPickup, obtainArrowOnPickup bool, 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) Owner

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

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

Position returns the current position of the entity.

func (*Arrow) Rotation

func (a *Arrow) Rotation() (float64, float64)

Rotation ...

func (*Arrow) SetBaseDamage

func (a *Arrow) SetBaseDamage(baseDamage float64)

SetBaseDamage sets the base damage the arrow will deal, before accounting for velocity.

func (*Arrow) SetCritical

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

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

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

Tick ...

func (*Arrow) Tip

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

func (a *Arrow) VanishOnPickup()

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

func (*Arrow) Velocity

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

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

World returns the world of the entity.

type ArrowShakeAction

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

func (ArrowShakeAction) EntityAction()

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

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

func (CriticalHitAction) EntityAction()

type DeathAction

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

func (DeathAction) EntityAction()

type EatAction

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

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

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 EnderPearl

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

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

NewEnderPearl ...

func (*EnderPearl) AABB

func (e *EnderPearl) AABB() physics.AABB

AABB ...

func (*EnderPearl) Close

func (t *EnderPearl) Close() error

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

func (*EnderPearl) DecodeNBT

func (e *EnderPearl) DecodeNBT(data map[string]interface{}) interface{}

DecodeNBT decodes the properties in a map to a EnderPearl and returns a new EnderPearl entity.

func (*EnderPearl) EncodeEntity

func (e *EnderPearl) EncodeEntity() string

EncodeEntity ...

func (*EnderPearl) EncodeNBT

func (e *EnderPearl) EncodeNBT() map[string]interface{}

EncodeNBT encodes the EnderPearl entity's properties as a map and returns it.

func (*EnderPearl) Name

func (e *EnderPearl) Name() string

Name ...

func (*EnderPearl) New

func (e *EnderPearl) New(pos, vel mgl64.Vec3, yaw, pitch float64) 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) Own

func (e *EnderPearl) Own(owner world.Entity)

Own ...

func (*EnderPearl) Owner

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

Owner ...

func (*EnderPearl) Position

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

Position returns the current position of the entity.

func (*EnderPearl) Rotation

func (e *EnderPearl) Rotation() (float64, float64)

Rotation ...

func (*EnderPearl) SetVelocity

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

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

Tick ...

func (*EnderPearl) Velocity

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

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

World returns the world of the entity.

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

func (*FallingBlock) AABB

func (f *FallingBlock) AABB() physics.AABB

AABB ...

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

func (f *FallingBlock) DecodeNBT(data map[string]interface{}) interface{}

DecodeNBT decodes the relevant data from the entity NBT passed and returns a new FallingBlock entity.

func (*FallingBlock) EncodeEntity

func (f *FallingBlock) EncodeEntity() string

EncodeEntity ...

func (*FallingBlock) EncodeNBT

func (f *FallingBlock) EncodeNBT() map[string]interface{}

EncodeNBT encodes the FallingBlock entity to a map that can be encoded for NBT.

func (*FallingBlock) Name

func (f *FallingBlock) Name() string

Name ...

func (*FallingBlock) Position

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

Position returns the current position of the entity.

func (*FallingBlock) Rotation

func (t *FallingBlock) Rotation() (float64, float64)

Rotation always returns 0.

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

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

HealthManager handles the health of an entity.

func NewHealthManager

func NewHealthManager() *HealthManager

NewHealthManager returns a new health manager with a default of 20 health and max health.

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

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

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

func (it *Item) AABB() physics.AABB

AABB ...

func (*Item) Close

func (t *Item) Close() error

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

func (*Item) DecodeNBT

func (it *Item) DecodeNBT(data map[string]interface{}) interface{}

DecodeNBT decodes the properties in a map to an Item and returns a new Item entity.

func (*Item) EncodeEntity

func (it *Item) EncodeEntity() string

EncodeEntity ...

func (*Item) EncodeNBT

func (it *Item) EncodeNBT() map[string]interface{}

EncodeNBT encodes the Item entity's properties as a map and returns it.

func (*Item) Item

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

Item returns the item stack that the item entity holds.

func (*Item) Name

func (it *Item) Name() string

Name ...

func (*Item) Position

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

Position returns the current position of the entity.

func (*Item) Rotation

func (t *Item) Rotation() (float64, float64)

Rotation always returns 0.

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

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

func NewLightning(pos mgl64.Vec3) *Lightning

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

func (Lightning) AABB

func (Lightning) AABB() physics.AABB

AABB ...

func (*Lightning) Close

func (li *Lightning) Close() error

Close closes the lighting.

func (*Lightning) DecodeNBT

func (li *Lightning) DecodeNBT(map[string]interface{}) interface{}

DecodeNBT does nothing.

func (*Lightning) EncodeEntity

func (li *Lightning) EncodeEntity() string

EncodeEntity ...

func (*Lightning) EncodeNBT

func (li *Lightning) EncodeNBT() map[string]interface{}

EncodeNBT does nothing.

func (*Lightning) Name

func (li *Lightning) Name() string

Name ...

func (*Lightning) New

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

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

func (Lightning) OnGround

func (Lightning) OnGround() bool

OnGround ...

func (*Lightning) Position

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

Position returns the current position of the lightning entity.

func (*Lightning) Rotation

func (li *Lightning) Rotation() (yaw, pitch float64)

Rotation ...

func (*Lightning) Tick

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

Tick ...

func (*Lightning) World

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 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)
	// 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 damage.SourceEntityAttack 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, source damage.Source) (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 healing.SourceFood 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, source healing.Source)
	// 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)
	// 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

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

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

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

func (*Movement) Rotation

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

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

func (*Movement) Send

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

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

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 Owned

type Owned interface {
	world.Entity
	Owner() world.Entity
	Own(owner world.Entity)
}

Owned represents an entity that is "owned" by another entity. Entities like projectiles typically are "owned".

type PickedUpAction

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

func (PickedUpAction) EntityAction()

type ProjectileComputer

type ProjectileComputer struct {
	*MovementComputer
}

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

func (*ProjectileComputer) TickMovement

func (c *ProjectileComputer) TickMovement(e world.Entity, pos, vel mgl64.Vec3, yaw, pitch float64, ignored func(world.Entity) bool) (*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 Snowball

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

Snowball is a throwable projectile which damages entities on impact.

func NewSnowball

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

NewSnowball ...

func (*Snowball) AABB

func (s *Snowball) AABB() physics.AABB

AABB ...

func (*Snowball) Close

func (t *Snowball) Close() error

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

func (*Snowball) DecodeNBT

func (s *Snowball) DecodeNBT(data map[string]interface{}) interface{}

DecodeNBT decodes the properties in a map to a Snowball and returns a new Snowball entity.

func (*Snowball) EncodeEntity

func (s *Snowball) EncodeEntity() string

EncodeEntity ...

func (*Snowball) EncodeNBT

func (s *Snowball) EncodeNBT() map[string]interface{}

EncodeNBT encodes the Snowball entity's properties as a map and returns it.

func (*Snowball) Name

func (s *Snowball) Name() string

Name ...

func (*Snowball) New

func (s *Snowball) New(pos, vel mgl64.Vec3, yaw, pitch float64) 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) Own

func (s *Snowball) Own(owner world.Entity)

Own ...

func (*Snowball) Owner

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

Owner ...

func (*Snowball) Position

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

Position returns the current position of the entity.

func (*Snowball) Rotation

func (s *Snowball) Rotation() (float64, float64)

Rotation ...

func (*Snowball) SetVelocity

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

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

Tick ...

func (*Snowball) Velocity

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

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

World returns the world of the entity.

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

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

SplashPotion is an item that grants effects when thrown.

func NewSplashPotion

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

NewSplashPotion ...

func (*SplashPotion) AABB

func (s *SplashPotion) AABB() physics.AABB

AABB ...

func (*SplashPotion) Close

func (t *SplashPotion) Close() error

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

func (*SplashPotion) DecodeNBT

func (s *SplashPotion) DecodeNBT(data map[string]interface{}) interface{}

DecodeNBT decodes the properties in a map to a SplashPotion and returns a new SplashPotion entity.

func (*SplashPotion) EncodeEntity

func (s *SplashPotion) EncodeEntity() string

EncodeEntity ...

func (*SplashPotion) EncodeNBT

func (s *SplashPotion) EncodeNBT() map[string]interface{}

EncodeNBT encodes the SplashPotion entity's properties as a map and returns it.

func (*SplashPotion) Name

func (s *SplashPotion) Name() string

Name ...

func (*SplashPotion) New

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

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

func (*SplashPotion) Own

func (s *SplashPotion) Own(owner world.Entity)

Own ...

func (*SplashPotion) Owner

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

Owner ...

func (*SplashPotion) Position

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

Position returns the current position of the entity.

func (*SplashPotion) Rotation

func (s *SplashPotion) Rotation() (float64, float64)

Rotation ...

func (*SplashPotion) SetVelocity

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

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

Tick ...

func (*SplashPotion) Type

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

Type returns the type of potion the splash potion will grant effects for when thrown.

func (*SplashPotion) Velocity

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

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

World returns the world of the entity.

type SwingArmAction

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

func (SwingArmAction) EntityAction()

type Text

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

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

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

func (*Text) AABB

func (t *Text) AABB() physics.AABB

AABB returns an empty physics.AABB so that players cannot interact with the entity.

func (*Text) Close

func (t *Text) Close() error

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

func (*Text) DecodeNBT

func (t *Text) DecodeNBT(data map[string]interface{}) interface{}

DecodeNBT decodes the data passed to create and return a new Text entity.

func (*Text) EncodeEntity

func (t *Text) EncodeEntity() string

EncodeEntity returns the ID for falling blocks.

func (*Text) EncodeNBT

func (t *Text) EncodeNBT() map[string]interface{}

EncodeNBT encodes the Text entity to a map representation that can be encoded to NBT.

func (*Text) Immobile

func (t *Text) Immobile() bool

Immobile always returns true.

func (*Text) Name

func (t *Text) Name() string

Name returns the name of the text entity, including the text written on it.

func (*Text) NameTag

func (t *Text) NameTag() string

NameTag returns the text passed to NewText.

func (*Text) Position

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

Position returns the current position of the entity.

func (*Text) Rotation

func (t *Text) Rotation() (float64, float64)

Rotation always returns 0.

func (*Text) SetVelocity

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

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

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

World returns the world of the entity.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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