Documentation ¶
Index ¶
- func DirectionVector(e world.Entity) mgl64.Vec3
- func EyePosition(e world.Entity) mgl64.Vec3
- func Facing(e world.Entity) cube.Direction
- type Collector
- type EffectManager
- type Eyed
- type FallingBlock
- func (f *FallingBlock) AABB() physics.AABB
- func (f *FallingBlock) Block() world.Block
- func (t *FallingBlock) Close() error
- func (f *FallingBlock) DecodeNBT(data map[string]interface{}) interface{}
- func (f *FallingBlock) EncodeEntity() string
- func (f *FallingBlock) EncodeNBT() map[string]interface{}
- func (f *FallingBlock) Name() string
- func (t *FallingBlock) Position() mgl64.Vec3
- func (t *FallingBlock) Rotation() (float64, float64)
- func (t *FallingBlock) SetVelocity(v mgl64.Vec3)
- func (f *FallingBlock) Tick(_ int64)
- func (t *FallingBlock) Velocity() mgl64.Vec3
- func (t *FallingBlock) World() *world.World
- type Flammable
- type HealthManager
- type Item
- func (it *Item) AABB() physics.AABB
- func (t *Item) Close() error
- func (it *Item) DecodeNBT(data map[string]interface{}) interface{}
- func (it *Item) EncodeEntity() string
- func (it *Item) EncodeNBT() map[string]interface{}
- func (it *Item) Item() item.Stack
- func (it *Item) Name() string
- func (t *Item) Position() mgl64.Vec3
- func (t *Item) Rotation() (float64, float64)
- func (it *Item) SetPickupDelay(d time.Duration)
- func (t *Item) SetVelocity(v mgl64.Vec3)
- func (it *Item) Tick(current int64)
- func (t *Item) Velocity() mgl64.Vec3
- func (t *Item) World() *world.World
- type Lightning
- func (Lightning) AABB() physics.AABB
- func (li *Lightning) Close() error
- func (li *Lightning) EncodeEntity() string
- func (li *Lightning) Name() string
- func (Lightning) OnGround() bool
- func (li *Lightning) Position() mgl64.Vec3
- func (li *Lightning) Rotation() (yaw, pitch float64)
- func (li *Lightning) Tick(_ int64)
- func (li *Lightning) World() *world.World
- type Living
- type MovementComputer
- type Solidifiable
- type Text
- func (t *Text) AABB() physics.AABB
- func (t *Text) Close() error
- func (t *Text) DecodeNBT(data map[string]interface{}) interface{}
- func (t *Text) EncodeEntity() string
- func (t *Text) EncodeNBT() map[string]interface{}
- func (t *Text) Immobile() bool
- func (t *Text) Name() string
- func (t *Text) NameTag() string
- func (t *Text) Position() mgl64.Vec3
- func (t *Text) Rotation() (float64, float64)
- func (t *Text) SetVelocity(v mgl64.Vec3)
- func (t *Text) Velocity() mgl64.Vec3
- func (t *Text) World() *world.World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirectionVector ¶
DirectionVector returns a vector that describes the direction of the entity passed. The length of the Vec3 returned is always 1.
func EyePosition ¶
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 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) }
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 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 ¶
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) 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 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) 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) EncodeNBT ¶
func (f *FallingBlock) EncodeNBT() map[string]interface{}
EncodeNBT encodes the FallingBlock entity to a map that can be encoded for NBT.
func (*FallingBlock) SetVelocity ¶
SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.
type Flammable ¶
type Flammable interface { // FireProof is whether the entity is currently fire proof. 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 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 ¶
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) DecodeNBT ¶
DecodeNBT decodes the properties in a map to an Item and returns a new Item entity.
func (*Item) SetPickupDelay ¶
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 ¶
SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.
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 ¶
NewLightning creates a lightning entity. The lightning entity will be positioned at the position passed.
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 player currently has, the entity is killed. Hurt(damage float64, source damage.Source) // 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) // 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 MovementComputer ¶
type MovementComputer struct { Gravity float64 DragBeforeGravity bool Drag float64 // 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) (mgl64.Vec3, mgl64.Vec3)
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.
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 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 (*Text) 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) EncodeEntity ¶
EncodeEntity returns the ID for falling blocks.
func (*Text) EncodeNBT ¶
EncodeNBT encodes the Text entity to a map representation that can be encoded to NBT.
func (*Text) SetVelocity ¶
SetVelocity sets the velocity of the entity. The values in the Vec3 passed represent the speed on that axis in blocks/tick.