model

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 4 Imported by: 8

Documentation

Overview

Package model has world.BlockModel implementations for each world.Block implementation in the block package. These models may be reused by blocks that share the same model. Some block models require additional fields and knowledge about the surrounding blocks to calculate the correct model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cake

type Cake struct {
	// Bites is the amount of bites that were taken from the cake. A cake can have up to 7 bites taken from it, before
	// being consumed entirely.
	Bites int
}

Cake is a model used by cake blocks.

func (Cake) AABB

func (c Cake) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns an AABB with a size that depends on the amount of bites taken.

func (Cake) FaceSolid

func (c Cake) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Carpet

type Carpet struct{}

Carpet is a model for carpet-like extremely thin blocks.

func (Carpet) AABB

func (Carpet) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns a flat AABB with a width of 0.0625.

func (Carpet) FaceSolid

func (Carpet) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Chain added in v0.5.0

type Chain struct {
	// Axis is the axis which the chain faces.
	Axis cube.Axis
}

Chain is a model used by chain blocks.

func (Chain) AABB added in v0.5.0

func (c Chain) AABB(cube.Pos, *world.World) []physics.AABB

AABB ...

func (Chain) FaceSolid added in v0.5.0

func (Chain) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid ...

type Chest

type Chest struct{}

Chest is the model of a chest. It is just barely not a full block, having a slightly reduced with on all axes.

func (Chest) AABB

func (Chest) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns a physics.AABB that is slightly smaller than a full block.

func (Chest) FaceSolid

func (Chest) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type CocoaBean

type CocoaBean struct {
	// Facing is the face that the cocoa bean faces. It is the opposite of the face that the CocoaBean is attached to.
	Facing cube.Direction
	// Age is the age of the CocoaBean. The age influences the size of the CocoaBean. The maximum age value of a cocoa
	// bean is 3.
	Age int
}

CocoaBean is a model used by cocoa bean blocks.

func (CocoaBean) AABB

func (c CocoaBean) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns a single physics.AABB whose size depends on the age of the CocoaBean.

func (CocoaBean) FaceSolid

func (c CocoaBean) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Door

type Door struct {
	// Facing is the direction that the door is facing when closed.
	Facing cube.Direction
	// Open specifies if the Door is open. The direction it opens towards depends on the Right field.
	Open bool
	// Right specifies the attachment side of the door and, with that, the direction it opens in.
	Right bool
}

Door is a model used for doors. It has no solid faces and a bounding box that changes depending on the direction of the door, whether it is open, and the side of its hinge.

func (Door) AABB

func (d Door) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns a physics.AABB that depends on if the Door is open, what direction it is facing and whether it is attached to the right/left side of a block.

func (Door) FaceSolid

func (d Door) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Empty

type Empty struct{}

Empty is a model that is completely empty. It has no collision boxes or solid faces.

func (Empty) AABB

func (Empty) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns an empty slice.

func (Empty) FaceSolid

func (Empty) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Fence

type Fence struct {
	// Wood specifies if the Fence is made from wood. This field is used to check if two fences are able to attach to
	// each other.
	Wood bool
}

Fence is a model used by fences of any type. It can attach to blocks with solid faces and other fences of the same type and has a model height just slightly over 1.

func (Fence) AABB

func (f Fence) AABB(pos cube.Pos, w *world.World) []physics.AABB

AABB returns multiple physics.AABB depending on how many connections it has with the surrounding blocks.

func (Fence) FaceSolid

func (f Fence) FaceSolid(_ cube.Pos, face cube.Face, _ *world.World) bool

FaceSolid returns true if the face is cube.FaceDown or cube.FaceUp.

type FenceGate

type FenceGate struct {
	// Facing is the facing direction of the FenceGate. A fence gate can only be opened in this direction or the
	// direction opposite to it.
	Facing cube.Direction
	// Open specifies if the FenceGate is open. In this case, AABB returns an empty slice.
	Open bool
}

FenceGate is a model used by fence gates. The model is completely zero-ed when the FenceGate is opened.

func (FenceGate) AABB

func (f FenceGate) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns up to one physics.AABB depending on the facing direction of the FenceGate and whether it is open.

func (FenceGate) FaceSolid

func (f FenceGate) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Ladder added in v0.2.0

type Ladder struct {
	// Facing is the side opposite to the block the Ladder is currently attached to.
	Facing cube.Direction
}

Ladder is the model for a ladder block.

func (Ladder) AABB added in v0.2.0

func (l Ladder) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns one physics.AABB that depends on the facing direction of the Ladder.

func (Ladder) FaceSolid added in v0.2.0

func (l Ladder) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Lantern

type Lantern struct {
	// Hanging specifies if the lantern is hanging from a block or if it's placed on the ground.
	Hanging bool
}

Lantern is a model for the lantern block. It can be placed on the ground or hanging from the ceiling.

func (Lantern) AABB

func (l Lantern) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns a physics.AABB attached to either the ceiling or to the ground.

func (Lantern) FaceSolid

func (l Lantern) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Leaves

type Leaves struct{}

Leaves is a model for leaves-like blocks. These blocks have a full collision box, but none of their faces are solid.

func (Leaves) AABB

func (Leaves) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns a physics.AABB that spans a full block.

func (Leaves) FaceSolid

func (Leaves) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

type Slab

type Slab struct {
	// Double and Top specify if the Slab is a double slab and if it's in the top slot respectively. If Double is true,
	// the AABB returned is always a full block.
	Double, Top bool
}

Slab is the model of a slab-like block, which is either a half block or a full block, depending on if the slab is double.

func (Slab) AABB

func (s Slab) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns either a physics.AABB spanning a full block or a half block in the top/bottom part of the block, depending on the Double and Top fields.

func (Slab) FaceSolid

func (s Slab) FaceSolid(_ cube.Pos, face cube.Face, _ *world.World) bool

FaceSolid returns true if the Slab is double, or if the face is cube.FaceUp when the Top field is true, or if the face is cube.FaceDown when the Top field is false.

type Solid

type Solid struct{}

Solid is the model of a fully solid block. Blocks with this model, such as stone or wooden planks, have a 1x1x1 collision box.

func (Solid) AABB

func (Solid) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns a physics.AABB spanning a full block.

func (Solid) FaceSolid

func (Solid) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns true.

type Stair

type Stair struct {
	// Facing specifies the direction that the full side of the Stair faces.
	Facing cube.Direction
	// UpsideDown turns the Stair upside-down, meaning the full side of the Stair is turned to the top side of the
	// block.
	UpsideDown bool
}

Stair is a model for stair-like blocks. These have different solid sides depending on the direction the stairs are facing, the surrounding blocks and whether it is upside down or not.

func (Stair) AABB

func (s Stair) AABB(pos cube.Pos, w *world.World) []physics.AABB

AABB returns a slice of physics.AABB depending on if the Stair is upside down and which direction it is facing. Additionally, these AABBs depend on the Stair blocks surrounding this one, which can influence the model.

func (Stair) FaceSolid

func (s Stair) FaceSolid(pos cube.Pos, face cube.Face, w *world.World) bool

FaceSolid returns true for all faces of the Stair that are completely filled.

type Thin

type Thin struct{}

Thin is a model for thin, partial blocks such as a glass pane or an iron bar. It changes its bounding box depending on solid faces next to it.

func (Thin) AABB

func (t Thin) AABB(pos cube.Pos, w *world.World) []physics.AABB

AABB returns a slice of physics.AABB that depends on the blocks surrounding the Thin block. Thin blocks can connect to any other Thin block, wall or solid faces of other blocks.

func (Thin) FaceSolid

func (t Thin) FaceSolid(_ cube.Pos, face cube.Face, _ *world.World) bool

FaceSolid returns true if the face passed is cube.FaceDown.

type TilledGrass

type TilledGrass struct{}

TilledGrass is a model used for grass that has been tilled in some way, such as dirt paths and farmland.

func (TilledGrass) AABB

AABB returns a physics.AABB that spans an entire block.

func (TilledGrass) FaceSolid

func (TilledGrass) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns true.

type Trapdoor

type Trapdoor struct {
	// Facing is the facing direction of the Trapdoor. In addition to the texture, it influences the direction in which
	// the Trapdoor is opened.
	Facing cube.Direction
	// Open and Top specify if the Trapdoor is opened and if it's in the top or bottom part of a block respectively.
	Open, Top bool
}

Trapdoor is a model used for trapdoors. It has no solid faces and a bounding box that changes depending on the direction of the trapdoor.

func (Trapdoor) AABB

func (t Trapdoor) AABB(cube.Pos, *world.World) []physics.AABB

AABB returns a physics.AABB that depends on the facing direction of the Trapdoor and whether it is open and in the top part of the block.

func (Trapdoor) FaceSolid

func (t Trapdoor) FaceSolid(cube.Pos, cube.Face, *world.World) bool

FaceSolid always returns false.

Jump to

Keyboard shortcuts

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