entity

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 10 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) world.Direction

Facing returns the horizontal direction that an entity is facing.

func TargetBlock

func TargetBlock(e world.Entity, maxDistance float64) world.BlockPos

TargetBlock finds the target block of the entity passed. The block position returned will be at most maxDistance away from the entity. If no block can be found there, the block position returned will be that of an air block.

Types

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 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 (it *Item) Close() error

Close closes the item, removing it from the world that it is currently in.

func (*Item) Item

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

Item returns the item stack that the item entity holds.

func (Item) OnGround

func (c Item) OnGround() bool

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

func (*Item) Pitch

func (it *Item) Pitch() float64

Pitch always returns 0.

func (*Item) Position

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

Position returns the current position of the item entity.

func (*Item) SetVelocity

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

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

func (*Item) State

func (it *Item) State() []state.State

State ...

func (*Item) Tick

func (it *Item) Tick()

Tick ticks the entity, performing movement.

func (*Item) Velocity

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

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

func (*Item) World

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

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

func (*Item) Yaw

func (it *Item) Yaw() float64

Yaw always returns 0.

type Living

type Living interface {
	// Health returns the health of the entity.
	Health() 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)
	// 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)
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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