Documentation
¶
Index ¶
- func BreakDuration(b world.Block, i item.Stack) time.Duration
- func BreaksInstantly(b world.Block, i item.Stack) bool
- func Parse(s string) ([]world.Block, error)
- type AABBer
- type Activatable
- type Air
- func (Air) AABB(world.BlockPos, *world.World) []physics.AABB
- func (Air) CanDisplace(world.Liquid) bool
- func (Air) EncodeBlock() (name string, properties map[string]interface{})
- func (Air) EncodeItem() (id int32, meta int16)
- func (Air) HasLiquidDrops() bool
- func (Air) LightDiffusionLevel() uint8
- func (Air) ReplaceableBy(world.Block) bool
- type Andesite
- type Bedrock
- type BreakInfo
- type Breakable
- type Chest
- func (c Chest) AABB(world.BlockPos, *world.World) []physics.AABB
- func (c Chest) Activate(pos world.BlockPos, _ world.Face, _ *world.World, u item.User)
- func (c Chest) AddViewer(v ContainerViewer, w *world.World, pos world.BlockPos)
- func (c Chest) BreakInfo() BreakInfo
- func (Chest) CanDisplace(b world.Liquid) bool
- func (c Chest) DecodeNBT(data map[string]interface{}) interface{}
- func (c Chest) Drops() []item.Stack
- func (c Chest) EncodeBlock() (name string, properties map[string]interface{})
- func (Chest) EncodeItem() (id int32, meta int16)
- func (c Chest) EncodeNBT() map[string]interface{}
- func (c Chest) Inventory() *inventory.Inventory
- func (Chest) LightDiffusionLevel() uint8
- func (c Chest) RemoveViewer(v ContainerViewer, w *world.World, pos world.BlockPos)
- func (Chest) SideClosed(world.BlockPos, world.BlockPos, *world.World) bool
- func (c Chest) UseOnBlock(pos world.BlockPos, face world.Face, _ mgl64.Vec3, w *world.World, ...) (used bool)
- func (c Chest) WithName(a ...interface{}) world.Item
- type Cobblestone
- type Concrete
- type Container
- type ContainerOpener
- type ContainerViewer
- type Diorite
- type Dirt
- type FromStringer
- type Granite
- type Grass
- func (g Grass) BreakInfo() BreakInfo
- func (g Grass) EncodeBlock() (name string, properties map[string]interface{})
- func (g Grass) EncodeItem() (id int32, meta int16)
- func (g Grass) NeighbourUpdateTick(pos, _ world.BlockPos, w *world.World)
- func (g Grass) RandomTick(pos world.BlockPos, w *world.World, r *rand.Rand)
- type Lava
- func (l Lava) EncodeBlock() (name string, properties map[string]interface{})
- func (l Lava) Harden(pos world.BlockPos, w *world.World, flownIntoBy *world.BlockPos) bool
- func (Lava) HasLiquidDrops() bool
- func (Lava) LightDiffusionLevel() uint8
- func (Lava) LightEmissionLevel() uint8
- func (l Lava) LiquidDepth() int
- func (l Lava) LiquidFalling() bool
- func (Lava) LiquidType() string
- func (l Lava) NeighbourUpdateTick(pos, _ world.BlockPos, w *world.World)
- func (Lava) ReplaceableBy(world.Block) bool
- func (l Lava) ScheduledTick(pos world.BlockPos, w *world.World)
- func (Lava) SpreadDecay() int
- func (l Lava) WithDepth(depth int, falling bool) world.Liquid
- type Leaves
- func (l Leaves) BreakInfo() BreakInfo
- func (Leaves) CanDisplace(b world.Liquid) bool
- func (l Leaves) EncodeBlock() (name string, properties map[string]interface{})
- func (l Leaves) EncodeItem() (id int32, meta int16)
- func (Leaves) LightDiffusionLevel() uint8
- func (Leaves) SideClosed(world.BlockPos, world.BlockPos, *world.World) bool
- type Light
- type LightDiffuser
- type LightEmitter
- type LiquidRemovable
- type Log
- type Obsidian
- type Placer
- type Planks
- type Replaceable
- type Stone
- type Water
- func (w Water) EncodeBlock() (name string, properties map[string]interface{})
- func (w Water) Harden(pos world.BlockPos, wo *world.World, flownIntoBy *world.BlockPos) bool
- func (Water) HasLiquidDrops() bool
- func (Water) LightDiffusionLevel() uint8
- func (w Water) LiquidDepth() int
- func (w Water) LiquidFalling() bool
- func (Water) LiquidType() string
- func (Water) NeighbourUpdateTick(pos, _ world.BlockPos, wo *world.World)
- func (Water) ReplaceableBy(world.Block) bool
- func (w Water) ScheduledTick(pos world.BlockPos, wo *world.World)
- func (Water) SpreadDecay() int
- func (w Water) WithDepth(depth int, falling bool) world.Liquid
- type WoodSlab
- func (s WoodSlab) AABB(world.BlockPos, *world.World) []physics.AABB
- func (s WoodSlab) BreakInfo() BreakInfo
- func (s WoodSlab) CanDisplace(b world.Liquid) bool
- func (s WoodSlab) EncodeBlock() (name string, properties map[string]interface{})
- func (s WoodSlab) EncodeItem() (id int32, meta int16)
- func (s WoodSlab) LightDiffusionLevel() uint8
- func (s WoodSlab) SideClosed(pos, side world.BlockPos, w *world.World) bool
- func (s WoodSlab) UseOnBlock(pos world.BlockPos, face world.Face, clickPos mgl64.Vec3, w *world.World, ...) (used bool)
- type WoodStairs
- func (s WoodStairs) AABB(pos world.BlockPos, w *world.World) []physics.AABB
- func (s WoodStairs) BreakInfo() BreakInfo
- func (WoodStairs) CanDisplace(b world.Liquid) bool
- func (s WoodStairs) EncodeBlock() (name string, properties map[string]interface{})
- func (s WoodStairs) EncodeItem() (id int32, meta int16)
- func (WoodStairs) LightDiffusionLevel() uint8
- func (s WoodStairs) SideClosed(pos, side world.BlockPos, w *world.World) bool
- func (s WoodStairs) UseOnBlock(pos world.BlockPos, face world.Face, clickPos mgl64.Vec3, w *world.World, ...) (used bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BreakDuration ¶
BreakDuration returns the base duration that breaking the block passed takes when being broken using the item passed.
func BreaksInstantly ¶
BreaksInstantly checks if the block passed can be broken instantly using the item stack passed to break it.
func Parse ¶
Parse attempts to parse a string passed into a slice of blocks. The string passed is a list of either one or more blocks, separated using a comma. If parsing the string was not successful, the slice returned is nil and an error is returned explaining the reason the string could not be parsed.
Parse parses strings in a rather specific format. The strings accepted may look like the following: "andesite" "andesite,log[wood=oak]" "log,leaves[wood=spruce,persistent=true]" The properties, which are optional, are identical to the fields of the blocks registered, except for being fully lowercase.
Errors returned by Parse are explicitly user-friendly. They are fit to be displayed to the end user supplying the string. noinspection GoErrorStringFormat
Types ¶
type AABBer ¶
type AABBer interface {
// AABB returns all the axis aligned bounding boxes of the block.
AABB(pos world.BlockPos, w *world.World) []physics.AABB
}
AABBer represents a block that has one or multiple specific Axis Aligned Bounding Boxes. These boxes are used to calculate collision.
type Activatable ¶
type Activatable interface {
// Activate activates the block at a specific block position. The face clicked is passed, as well as the
// world in which the block was activated and the viewer that activated it.
Activate(pos world.BlockPos, clickedFace world.Face, w *world.World, u item.User)
}
Activatable represents a block that may be activated by a viewer of the world. When activated, the block will execute some specific logic.
type Air ¶
type Air struct{}
Air is the block present in otherwise empty space.
func (Air) AABB ¶
AABB returns an empty Axis Aligned Bounding Box (as nothing can collide with air).
func (Air) EncodeBlock ¶
EncodeBlock ...
type Andesite ¶
type Andesite polishable
Andesite is a type of igneous rock.
func (Andesite) EncodeBlock ¶
EncodeBlock ...
type Bedrock ¶
type Bedrock struct {
// InfiniteBurning specifies if the bedrock block is set aflame and will burn forever. This is the case
// for bedrock found under end crystals on top of the end pillars.
InfiniteBurning bool
}
Bedrock is a block that is indestructible in survival.
func (Bedrock) EncodeBlock ¶
EncodeBlock ...
type BreakInfo ¶
type BreakInfo struct {
// Hardness is the hardness of the block, which influences the speed with which the block may be mined.
Hardness float64
// Harvestable is a function called to check if the block is harvestable using the tool passed. If the
// item used to break the block is not a tool, a tool.None is passed.
Harvestable func(t tool.Tool) bool
// Effective is a function called to check if the block can be mined more effectively with the tool passed
// than with an empty hand.
Effective func(t tool.Tool) bool
// Drops is a function called to get the drops of the block if it is broken using the tool passed. If the
// item used to break the block is not a tool, a tool.None is passed.
Drops func(t tool.Tool) []item.Stack
}
BreakInfo is a struct returned by every block. It holds information on block breaking related data, such as the tool type and tier required to break it.
type Breakable ¶
type Breakable interface {
// BreakInfo returns information of the block related to the breaking of it.
BreakInfo() BreakInfo
}
Breakable represents a block that may be broken by a player in survival mode. Blocks not include are blocks such as bedrock.
type Chest ¶
type Chest struct {
// Facing is the direction that the chest is facing.
Facing world.Direction
// CustomName is the custom name of the chest. This name is displayed when the chest is opened, and may
// include colour codes.
CustomName string
// contains filtered or unexported fields
}
Chest is a container block which may be used to store items. Chests may also be paired to create a bigger single container. The empty value of Chest is not valid. It must be created using item.NewChest().
func NewChest ¶
func NewChest() Chest
NewChest creates a new initialised chest. The inventory is properly initialised.
func (Chest) AddViewer ¶
AddViewer adds a viewer to the chest, so that it is updated whenever the inventory of the chest is changed.
func (Chest) Drops ¶
Drops returns the drops of the chest. This includes all items held in the inventory and the chest itself.
func (Chest) EncodeBlock ¶
EncodeBlock ...
func (Chest) Inventory ¶
Inventory returns the inventory of the chest. The size of the inventory will be 27 or 54, depending on whether the chest is single or double.
func (Chest) RemoveViewer ¶
RemoveViewer removes a viewer from the chest, so that slot updates in the inventory are no longer sent to it.
func (Chest) SideClosed ¶
SideClosed ...
type Cobblestone ¶
type Cobblestone struct {
// Mossy specifies if the cobblestone is mossy. This variant of cobblestone is typically found in
// dungeons or in small clusters in the giant tree taiga biome.
Mossy bool
}
Cobblestone is a common block, obtained from mining stone.
func (Cobblestone) EncodeBlock ¶
func (c Cobblestone) EncodeBlock() (name string, properties map[string]interface{})
EncodeBlock ...
func (Cobblestone) EncodeItem ¶
func (c Cobblestone) EncodeItem() (id int32, meta int16)
EncodeItem ...
type Concrete ¶
Concrete is a solid block which comes in the 16 regular dye colors, created by placing concrete powder adjacent to water.
func (Concrete) EncodeBlock ¶
EncodeBlock ...
type Container ¶
type Container interface {
AddViewer(v ContainerViewer, w *world.World, pos world.BlockPos)
RemoveViewer(v ContainerViewer, w *world.World, pos world.BlockPos)
Inventory() *inventory.Inventory
}
Container represents a container of items, typically a block such as a chest. Containers may have their inventory opened by viewers.
type ContainerOpener ¶
type ContainerOpener interface {
// OpenBlockContainer opens a block container at the position passed.
OpenBlockContainer(pos world.BlockPos)
}
ContainerOpener represents an entity that is able to open a container.
type ContainerViewer ¶
type ContainerViewer interface {
// ViewSlotChange views a change of a single slot in the inventory, in which the item was changed to the
// new item passed.
ViewSlotChange(slot int, newItem item.Stack)
}
ContainerViewer represents a viewer that is able to view a container and its inventory.
type Diorite ¶
type Diorite polishable
Diorite is a type of igneous rock.
func (Diorite) EncodeBlock ¶
EncodeBlock ...
type Dirt ¶
type Dirt struct {
// Coarse specifies if the dirt should be off the coarse dirt variant. Grass blocks won't spread on
// the block if set to true.
Coarse bool
}
Dirt is a block found abundantly in most biomes under a layer of grass blocks at the top of the normal world.
func (Dirt) EncodeBlock ¶
EncodeBlock ...
type FromStringer ¶
FromStringer represents a type that is able to return a specific variant of itself by reading the string passed.
type Granite ¶
type Granite polishable
Granite is a type of igneous rock.
func (Granite) EncodeBlock ¶
EncodeBlock ...
type Grass ¶
type Grass struct {
// Path specifies if the grass was made into a path or not. If true, the block will have only 15/16th of
// the height of a full block.
Path bool
}
Grass blocks generate abundantly across the surface of the world.
func (Grass) EncodeBlock ¶
EncodeBlock ...
func (Grass) NeighbourUpdateTick ¶
NeighbourUpdateTick handles the turning from grass path into dirt if a block is placed on top of it.
type Lava ¶
type Lava struct {
// Still makes the lava not spread whenever it is updated. Still lava cannot be acquired in the game
// without world editing.
Still bool
// Depth is the depth of the water. This is a number from 1-8, where 8 is a source block and 1 is the
// smallest possible lava block.
Depth int
// Falling specifies if the lava is falling. Falling lava will always appear as a source block, but its
// behaviour differs when it starts spreading.
Falling bool
}
Lava is a light-emitting fluid block that causes fire damage.
func (Lava) EncodeBlock ¶
EncodeBlock ...
func (Lava) LightDiffusionLevel ¶
LightDiffusionLevel always returns 2.
func (Lava) LightEmissionLevel ¶
LightEmissionLevel returns 15.
func (Lava) LiquidDepth ¶
LiquidDepth returns the depth of the lava.
func (Lava) LiquidFalling ¶
LiquidFalling checks if the lava is falling.
func (Lava) LiquidType ¶
LiquidType returns "lava" as a unique identifier for the lava liquid.
func (Lava) NeighbourUpdateTick ¶
NeighbourUpdateTick ...
func (Lava) ScheduledTick ¶
ScheduledTick ...
type Leaves ¶
type Leaves struct {
// Wood is the type of wood of the leaves. This field must have one of the values found in the material
// package.
Wood wood.Wood
// Persistent specifies if the leaves are persistent, meaning they will not decay as a result of no wood
// being nearby.
Persistent bool
// contains filtered or unexported fields
}
Leaves are blocks that grow as part of trees which mainly drop saplings and sticks.
func (Leaves) EncodeBlock ¶
EncodeBlock ...
func (Leaves) LightDiffusionLevel ¶
LightDiffusionLevel ...
type Light ¶
type Light struct {
// Level is the light level that the light block produces. It is a number from 0-15, where 15 is the
// brightest and 0 is no light at all.
Level int
}
Light is an invisible block that can produce any light level.
func (Light) EncodeBlock ¶
EncodeBlock ...
func (Light) LightDiffusionLevel ¶
LightDiffusionLevel ...
type LightDiffuser ¶
type LightDiffuser interface {
// LightDiffusionLevel returns the amount of light levels that is subtracted when light passes through
// this block. Some locks, such as leaves, have this behaviour. A diffusion level of 15 means that all
// light will be completely blocked when light passes through the block.
LightDiffusionLevel() uint8
}
LightDiffuser represents a block that diffuses light. This means that a specific amount of light levels will be subtracted when light passes through the block. Blocks that do not implement LightDiffuser will be assumed to be solid: Light will not be able to pass through these blocks.
type LightEmitter ¶
type LightEmitter interface {
// LightEmissionLevel returns the light emission level of the block, a number from 0-15 where 15 is the
// brightest and 0 means it doesn't emit light at all.
LightEmissionLevel() uint8
}
LightEmitter represents a block that emits light when placed. Blocks such as torches or lanterns implement this interface.
type LiquidRemovable ¶
type LiquidRemovable interface {
HasLiquidDrops() bool
}
LiquidRemovable represents a block that may be removed by a liquid flowing into it. When this happens, the block's drops are dropped at the position if HasLiquidDrops returns true.
type Log ¶
type Log struct {
// Wood is the type of wood of the log. This field must have one of the values found in the material
// package.
Wood wood.Wood
// Stripped specifies if the log is stripped or not.
Stripped bool
// Axis is the axis which the log block faces.
Axis world.Axis
}
Log is a naturally occurring block found in trees, primarily used to create planks. It comes in six species: oak, spruce, birch, jungle, acacia, and dark oak. Stripped log is a variant obtained by using an axe on a log.
func (Log) EncodeBlock ¶
EncodeBlock ...
type Obsidian ¶
type Obsidian struct{}
Obsidian is a dark purple block known for its high blast resistance and strength, most commonly found when water flows over lava.
func (Obsidian) EncodeBlock ¶
EncodeBlock ...
type Placer ¶
type Placer interface {
item.User
PlaceBlock(pos world.BlockPos, b world.Block, ctx *item.UseContext)
}
Placer represents an entity that is able to place a block at a specific position in the world.
type Planks ¶
type Planks struct {
// Wood is the type of wood of the planks. This field must have one of the values found in the material
// package.
Wood wood.Wood
}
Planks are common blocks used in crafting recipes. They are made by crafting logs into planks.
func (Planks) EncodeBlock ¶
EncodeBlock ...
type Replaceable ¶
type Replaceable interface {
// ReplaceableBy returns a bool which indicates if the block is replaceable by another block.
ReplaceableBy(b world.Block) bool
}
Replaceable represents a block that may be replaced by another block automatically. An example is grass, which may be replaced by clicking it with another block.
type Stone ¶
type Stone struct{}
Stone is a block found underground in the world or on mountains.
func (Stone) EncodeBlock ¶
EncodeBlock ...
type Water ¶
type Water struct {
// Still makes the water appear as if it is not flowing.
Still bool
// Depth is the depth of the water. This is a number from 1-8, where 8 is a source block and 1 is the
// smallest possible water block.
Depth int
// Falling specifies if the water is falling. Falling water will always appear as a source block, but its
// behaviour differs when it starts spreading.
Falling bool
}
Water is a natural fluid that generates abundantly in the world.
func (Water) EncodeBlock ¶
EncodeBlock ...
func (Water) LiquidDepth ¶
LiquidDepth returns the depth of the water.
func (Water) LiquidFalling ¶
LiquidFalling returns Water.Falling.
func (Water) NeighbourUpdateTick ¶
NeighbourUpdateTick ...
func (Water) ScheduledTick ¶
ScheduledTick ...
func (Water) SpreadDecay ¶
SpreadDecay returns 1 - The amount of levels decreased upon spreading.
type WoodSlab ¶
type WoodSlab struct {
// Wood is the type of wood of the slabs. This field must have one of the values found in the material
// package.
Wood wood.Wood
// UpsideDown specifies if the slabs are upside down.
UpsideDown bool
// Double specifies if the slab is a double slab. These double slabs can be made by placing another slab
// on an existing slab.
Double bool
}
WoodSlab is a half block that allows entities to walk up blocks without jumping.
func (WoodSlab) EncodeBlock ¶
EncodeBlock ...
func (WoodSlab) LightDiffusionLevel ¶
LightDiffusionLevel returns 0 if the slab is a half slab, or 15 if it is double.
func (WoodSlab) SideClosed ¶
SideClosed ...
func (WoodSlab) UseOnBlock ¶
func (s WoodSlab) UseOnBlock(pos world.BlockPos, face world.Face, clickPos mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool)
UseOnBlock handles the placement of slabs with relation to them being upside down or not and handles slabs being turned into double slabs.
type WoodStairs ¶
type WoodStairs struct {
// Wood is the type of wood of the stairs. This field must have one of the values found in the material
// package.
Wood wood.Wood
// UpsideDown specifies if the stairs are upside down. If set to true, the full side is at the top part
// of the block.
UpsideDown bool
// Facing is the direction that the full side of the stairs is facing.
Facing world.Direction
}
WoodStairs are blocks that allow entities to walk up blocks without jumping. They are crafted using planks.
func (WoodStairs) EncodeBlock ¶
func (s WoodStairs) EncodeBlock() (name string, properties map[string]interface{})
EncodeBlock ...
func (WoodStairs) EncodeItem ¶
func (s WoodStairs) EncodeItem() (id int32, meta int16)
EncodeItem ...
func (WoodStairs) LightDiffusionLevel ¶
func (WoodStairs) LightDiffusionLevel() uint8
LightDiffusionLevel always returns 0.
func (WoodStairs) SideClosed ¶
SideClosed ...
func (WoodStairs) UseOnBlock ¶
func (s WoodStairs) UseOnBlock(pos world.BlockPos, face world.Face, clickPos mgl64.Vec3, w *world.World, user item.User, ctx *item.UseContext) (used bool)
UseOnBlock handles the directional placing of stairs and makes sure they are properly placed upside down when needed.