cube

package
v0.0.0-...-d1826b6 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: AGPL-3.0, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxY = 319
	MinY = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis int

Axis represents the axis that a block may be directed in. Most blocks do not have an axis, but blocks such as logs or pillars do.

const (
	// Y represents the vertical Y axis.
	Y Axis = iota
	// Z represents the horizontal Z axis.
	Z
	// X represents the horizontal X axis.
	X
)

func Axes

func Axes() []Axis

Axes return all possible axes. (x, y, z)

func (Axis) FromString

func (a Axis) FromString(s string) (interface{}, error)

FromString returns an axis by a string.

func (Axis) RotateLeft

func (a Axis) RotateLeft() Axis

RotateLeft rotates an Axis from X to Z or from Z to X.

func (Axis) RotateRight

func (a Axis) RotateRight() Axis

RotateRight rotates an Axis from X to Z or from Z to X.

func (Axis) String

func (a Axis) String() string

String converts an Axis into either x, y or z, depending on which axis it is.

type Direction

type Direction int

Direction represents a direction towards one of the horizontal axes of the world.

const (
	// North represents the north direction.
	North Direction = iota
	// South represents the south direction.
	South
	// West represents the west direction.
	West
	// East represents the east direction.
	East
)

func Directions

func Directions() []Direction

Directions returns a list of all directions, going from North to West.

func (Direction) Face

func (d Direction) Face() Face

Face converts the direction to a block face.

func (Direction) Opposite

func (d Direction) Opposite() Direction

Opposite returns the opposite direction.

func (Direction) RotateLeft

func (d Direction) RotateLeft() Direction

RotateLeft rotates the direction 90 degrees to the left horizontally and returns the new direction.

func (Direction) RotateRight

func (d Direction) RotateRight() Direction

RotateRight rotates the direction 90 degrees to the right horizontally and returns the new direction.

func (Direction) String

func (d Direction) String() string

String returns the Direction as a string.

type Face

type Face int

Face represents the face of a block or entity.

const (
	// FaceDown represents the bottom face of a block.
	FaceDown Face = iota
	// FaceUp represents the top face of a block.
	FaceUp
	// FaceNorth represents the north face of a block.
	FaceNorth
	// FaceSouth represents the south face of a block.
	FaceSouth
	// FaceWest represents the west face of the block.
	FaceWest
	// FaceEast represents the east face of the block.
	FaceEast
)

func Faces

func Faces() []Face

Faces returns a list of all faces, starting with down, then up, then north to west.

func HorizontalFaces

func HorizontalFaces() []Face

HorizontalFaces returns a list of all horizontal faces, from north to west.

func (Face) Axis

func (f Face) Axis() Axis

Axis returns the axis the face is facing. FaceEast and west correspond to the x axis, north and south to the z axis and up and down to the y axis.

func (Face) Direction

func (f Face) Direction() Direction

Direction converts the Face to a Direction and returns it, assuming the Face is horizontal and not FaceUp or FaceDown.

func (Face) FromString

func (f Face) FromString(s string) (interface{}, error)

FromString returns a Face by a string.

func (Face) Opposite

func (f Face) Opposite() Face

Opposite returns the opposite face. FaceDown will return up, north will return south and west will return east, and vice versa.

func (Face) RotateLeft

func (f Face) RotateLeft() Face

RotateLeft rotates the face 90 degrees to the left horizontally and returns the new face.

func (Face) RotateRight

func (f Face) RotateRight() Face

RotateRight rotates the face 90 degrees to the right horizontally and returns the new face.

func (Face) String

func (f Face) String() string

String returns the Face as a string.

type Orientation

type Orientation int

Orientation represents the orientation of a sign

func OrientationFromYaw

func OrientationFromYaw(yaw float64) Orientation

OrientationFromYaw returns an Orientation value that (roughly) matches the yaw passed.

func (Orientation) Opposite

func (o Orientation) Opposite() Orientation

Opposite returns the opposite orientation value of the Orientation.

func (Orientation) RotateLeft

func (o Orientation) RotateLeft() Orientation

RotateLeft rotates the orientation left by 90 degrees and returns it.

func (Orientation) RotateRight

func (o Orientation) RotateRight() Orientation

RotateRight rotates the orientation right by 90 degrees and returns it.

func (Orientation) Yaw

func (o Orientation) Yaw() float64

Yaw returns the yaw value that matches the orientation.

type Pos

type Pos [3]int

Pos holds the position of a block. The position is represented of an array with an x, y and z value, where the y value is positive.

func PosFromVec3

func PosFromVec3(vec3 mgl64.Vec3) Pos

PosFromVec3 returns a block position by a Vec3, rounding the values down adequately.

func (Pos) Add

func (p Pos) Add(pos Pos) Pos

Add adds two block positions together and returns a new one with the combined values.

func (Pos) Face

func (p Pos) Face(other Pos) Face

Face returns the face that the other Pos was on compared to the current Pos. The other Pos is assumed to be a direct neighbour of the current Pos.

func (Pos) Neighbours

func (p Pos) Neighbours(f func(neighbour Pos))

Neighbours calls the function passed for each of the block position's neighbours. If the Y value is out of bounds, the function will not be called for that position.

func (Pos) OutOfBounds

func (p Pos) OutOfBounds() bool

OutOfBounds checks if the Y value is either bigger than 255 or smaller than 0.

func (Pos) Side

func (p Pos) Side(face Face) Pos

Side returns the position on the side of this block position, at a specific face.

func (Pos) Subtract

func (p Pos) Subtract(pos Pos) Pos

Subtract subtracts two block positions together and returns a new one with the combined values.

func (Pos) Vec3

func (p Pos) Vec3() mgl64.Vec3

Vec3 returns a vec3 holding the same coordinates as the block position.

func (Pos) Vec3Centre

func (p Pos) Vec3Centre() mgl64.Vec3

Vec3Centre returns a Vec3 holding the coordinates of the block position with 0.5 added on all axes.

func (Pos) Vec3Middle

func (p Pos) Vec3Middle() mgl64.Vec3

Vec3Middle returns a Vec3 holding the coordinates of the block position with 0.5 added on both horizontal axes.

func (Pos) X

func (p Pos) X() int

X returns the X coordinate of the block position.

func (Pos) Y

func (p Pos) Y() int

Y returns the Y coordinate of the block position.

func (Pos) Z

func (p Pos) Z() int

Z returns the Z coordinate of the block position.

Jump to

Keyboard shortcuts

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