customblock

package
v0.9.16 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Material

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

Material represents a single material used for rendering part of a custom block.

func NewMaterial

func NewMaterial(texture string, method Method) Material

NewMaterial returns a new Material with the provided information. It enables face dimming by default and ambient occlusion based on the render method given.

func (Material) Encode

func (m Material) Encode() map[string]any

Encode returns the material encoded as a map that can be sent over the network to the client.

func (Material) WithAmbientOcclusion

func (m Material) WithAmbientOcclusion() Material

WithAmbientOcclusion returns a copy of the Material with ambient occlusion enabled.

func (Material) WithFaceDimming

func (m Material) WithFaceDimming() Material

WithFaceDimming returns a copy of the Material with face dimming enabled.

func (Material) WithoutAmbientOcclusion

func (m Material) WithoutAmbientOcclusion() Material

WithoutAmbientOcclusion returns a copy of the Material with ambient occlusion disabled.

func (Material) WithoutFaceDimming

func (m Material) WithoutFaceDimming() Material

WithoutFaceDimming returns a copy of the Material with face dimming disabled.

type Method

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

Method is the method to use when rendering a material for a custom block.

func AlphaTestRenderMethod

func AlphaTestRenderMethod() Method

AlphaTestRenderMethod returns the alpha_test rendering method for a material. It does not allow for translucent textures, only textures that are fully opaque or fully transparent, used for blocks such as regular glass. It also disables ambient occlusion by default.

func BlendRenderMethod

func BlendRenderMethod() Method

BlendRenderMethod returns the blend rendering method for a material. It allows for transparent and translucent textures, used for blocks such as stained-glass. It also disables ambient occlusion by default.

func DoubleSidedRenderMethod

func DoubleSidedRenderMethod() Method

DoubleSidedRenderMethod returns the double_sided rendering method for a material. It is used to completely disable backface culling, which would be used for flat faces visible from both sides.

func OpaqueRenderMethod

func OpaqueRenderMethod() Method

OpaqueRenderMethod returns the opaque rendering method for a material. It does not render an alpha layer, meaning it does not support transparent or translucent textures, only textures that are fully opaque.

func (Method) AmbientOcclusion

func (m Method) AmbientOcclusion() bool

AmbientOcclusion returns if ambient occlusion should be enabled by default for a material using this rendering method.

func (Method) String

func (m Method) String() string

String ...

func (Method) Uint8

func (m Method) Uint8() uint8

Uint8 returns the render method as a uint8.

type Permutation

type Permutation struct {
	Properties
	// Condition is a molang query that is used to determine whether the permutation should be applied.
	// Only the latest version of molang is supported.
	Condition string
}

Permutation represents a specific permutation for a block that is only applied when the condition is met.

type Properties

type Properties struct {
	// CollisionBox represents the bounding box of the block that the player can collide with. This cannot exceed the
	// position of the current block in the world, otherwise it will be cut off at the edge.
	CollisionBox cube.BBox
	// Cube determines whether the block should inherit the default cube geometry. This will only be considered if the
	// Geometry field is empty.
	Cube bool
	// Geometry represents the geometry identifier that should be used for the block. If you want to use the default
	// cube geometry, leave this field empty and set Cube to true.
	Geometry string
	// MapColour represents the hex colour that should be used for the block on a map.
	MapColour string
	// Rotation represents the rotation of the block. Rotations are only applied in 90 degree increments, meaning
	// 1 = 90 degrees, 2 = 180 degrees, 3 = 270 degrees and 4 = 360 degrees.
	Rotation cube.Pos
	// Scale is the scale of the block, with 1 being the default scale in all axes. When scaled, the block cannot
	// exceed a 30x30x30 pixel area otherwise the client will not render the block.
	Scale mgl64.Vec3
	// SelectionBox represents the bounding box of the block that the player can interact with. This cannot exceed the
	// position of the current block in the world, otherwise it will be cut off at the edge.
	SelectionBox cube.BBox
	// Textures define the textures that should be used for the block. The key is the target of the texture, such as
	// "*" for all sides, or one of "up", "down", "north", "south", "east", "west" for a specific side.
	Textures map[string]Material
	// Translation is the translation of the block within itself. When translated, the block cannot exceed a 30x30x30
	// pixel area otherwise the client will not render the block.
	Translation mgl64.Vec3
}

Properties represents the different properties that can be applied to a block or a permutation.

Jump to

Keyboard shortcuts

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