item

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: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConsumeDuration = (time.Second * 161) / 100

DefaultConsumeDuration is the default duration that consuming an item takes. Dried kelp takes half this time to be consumed.

Variables

This section is empty.

Functions

func AllDyes

func AllDyes() []world.Item

AllDyes returns all 16 dye items

func EnchantmentID

func EnchantmentID(e Enchantment) (int, bool)

EnchantmentID attempts to return the ID the enchantment was registered with. If found, the id is returned and the bool true.

func RegisterEnchantment

func RegisterEnchantment(id int, enchantment Enchantment)

RegisterEnchantment registers an enchantment with the ID passed. Once registered, enchantments may be received by instantiating an Enchantment struct (e.g. enchantment.Protection{})

Types

type AmethystShard

type AmethystShard struct{}

AmethystShard is a crystalline mineral obtained from mining a fully grown amethyst cluster.

func (AmethystShard) EncodeItem

func (AmethystShard) EncodeItem() (name string, meta int16)

EncodeItem ...

type Apple

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

Apple is a food item that can be eaten by the player.

func (Apple) AlwaysConsumable

func (Apple) AlwaysConsumable() bool

AlwaysConsumable ...

func (Apple) Consume

func (a Apple) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Apple) ConsumeDuration

func (d Apple) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Apple) EncodeItem

func (a Apple) EncodeItem() (name string, meta int16)

EncodeItem ...

type ArmourContainer

type ArmourContainer interface {
	// SetHelmet sets the item stack passed as the helmet in the inventory.
	SetHelmet(helmet Stack)
	// Helmet returns the item stack set as helmet in the inventory.
	Helmet() Stack
	// SetChestplate sets the item stack passed as the chestplate in the inventory.
	SetChestplate(chestplate Stack)
	// Chestplate returns the item stack set as chestplate in the inventory.
	Chestplate() Stack
	// SetLeggings sets the item stack passed as the leggings in the inventory.
	SetLeggings(leggings Stack)
	// Leggings returns the item stack set as leggings in the inventory.
	Leggings() Stack
	// SetBoots sets the item stack passed as the boots in the inventory.
	SetBoots(boots Stack)
	// Boots returns the item stack set as boots in the inventory.
	Boots() Stack
	// Clear clears all items in the inventory.
	Clear()
}

ArmourContainer represents a container of armour. Generally, entities will want to use the inventory.Armour type.

type Armoured

type Armoured interface {
	// Armour returns the armour inventory of the entity.
	Armour() ArmourContainer
}

Armoured represents an entity that is able to wear armour in a specific armour inventory. These entities typically include human-like entities such as zombies.

type Axe

type Axe struct {
	// Tier is the tier of the axe.
	Tier tool.Tier
}

Axe is a tool generally used for mining wood-like blocks. It may also be used to break some plant-like blocks at a faster pace such as pumpkins.

func (Axe) AttackDamage

func (a Axe) AttackDamage() float64

AttackDamage ...

func (Axe) BaseMiningEfficiency

func (a Axe) BaseMiningEfficiency(world.Block) float64

BaseMiningEfficiency ...

func (Axe) DurabilityInfo

func (a Axe) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Axe) EncodeItem

func (a Axe) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Axe) HarvestLevel

func (a Axe) HarvestLevel() int

HarvestLevel ...

func (Axe) MaxCount

func (a Axe) MaxCount() int

MaxCount always returns 1.

func (Axe) ToolType

func (a Axe) ToolType() tool.Type

ToolType ...

func (Axe) UseOnBlock

func (a Axe) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool

UseOnBlock handles the stripping of logs when a player clicks a log with an axe.

type BakedPotato

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

BakedPotato is a food item that can be eaten by the player.

func (BakedPotato) AlwaysConsumable

func (BakedPotato) AlwaysConsumable() bool

AlwaysConsumable ...

func (BakedPotato) Consume

func (BakedPotato) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (BakedPotato) ConsumeDuration

func (d BakedPotato) ConsumeDuration() time.Duration

ConsumeDuration ...

func (BakedPotato) EncodeItem

func (BakedPotato) EncodeItem() (name string, meta int16)

EncodeItem ...

type BeaconPayment

type BeaconPayment interface {
	PayableForBeacon() bool
}

BeaconPayment represents an item that may be used as payment for a beacon to select effects to be broadcast to surrounding players.

type Beef

type Beef struct {

	// Cooked is whether the beef is cooked.
	Cooked bool
	// contains filtered or unexported fields
}

Beef is a food item obtained from cows. It can be cooked in a furnace, smoker, or campfire.

func (Beef) AlwaysConsumable

func (Beef) AlwaysConsumable() bool

AlwaysConsumable ...

func (Beef) Consume

func (b Beef) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Beef) ConsumeDuration

func (d Beef) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Beef) EncodeItem

func (b Beef) EncodeItem() (name string, meta int16)

EncodeItem ...

type Beetroot

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

Beetroot is a food and dye ingredient.

func (Beetroot) AlwaysConsumable

func (Beetroot) AlwaysConsumable() bool

AlwaysConsumable ...

func (Beetroot) Consume

func (b Beetroot) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Beetroot) ConsumeDuration

func (d Beetroot) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Beetroot) EncodeItem

func (b Beetroot) EncodeItem() (name string, meta int16)

EncodeItem ...

type BeetrootSoup

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

BeetrootSoup is an unstackable food item.

func (BeetrootSoup) AlwaysConsumable

func (BeetrootSoup) AlwaysConsumable() bool

AlwaysConsumable ...

func (BeetrootSoup) Consume

func (BeetrootSoup) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (BeetrootSoup) ConsumeDuration

func (d BeetrootSoup) ConsumeDuration() time.Duration

ConsumeDuration ...

func (BeetrootSoup) EncodeItem

func (BeetrootSoup) EncodeItem() (name string, meta int16)

EncodeItem ...

func (BeetrootSoup) MaxCount

func (BeetrootSoup) MaxCount() int

MaxCount ...

type BlazePowder

type BlazePowder struct{}

BlazePowder is an item made from a blaze rod obtained from blazes.

func (BlazePowder) EncodeItem

func (BlazePowder) EncodeItem() (name string, meta int16)

EncodeItem ...

type BlazeRod

type BlazeRod struct{}

BlazeRod is an item exclusively obtained from blazes.

func (BlazeRod) EncodeItem

func (BlazeRod) EncodeItem() (name string, meta int16)

EncodeItem ...

type Bone

type Bone struct{}

Bone is an item primarily obtained as a drop from skeletons and their variants.

func (Bone) EncodeItem

func (Bone) EncodeItem() (name string, meta int16)

EncodeItem ...

type BoneMeal

type BoneMeal struct{}

BoneMeal is an item used to force growth in plants & crops.

func (BoneMeal) EncodeItem

func (b BoneMeal) EncodeItem() (name string, meta int16)

EncodeItem ...

func (BoneMeal) UseOnBlock

func (b BoneMeal) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool

UseOnBlock ...

type BoneMealAffected

type BoneMealAffected interface {
	// BoneMeal attempts to affect the block using a bone meal item.
	BoneMeal(pos cube.Pos, w *world.World) bool
}

BoneMealAffected represents a block that is affected when bone meal is used on it.

type Book

type Book struct{}

Book is an item used in enchanting and crafting.

func (Book) EncodeItem

func (Book) EncodeItem() (name string, meta int16)

EncodeItem ...

type Boots

type Boots struct {
	// Tier is the tier of the boots.
	Tier armour.Tier
}

Boots are a defensive item that may be equipped in the boots armour slot. They come in several tiers, like leather, gold, chain, iron and diamond.

func (Boots) Boots

func (b Boots) Boots() bool

Boots ...

func (Boots) DefencePoints

func (b Boots) DefencePoints() float64

DefencePoints ...

func (Boots) DurabilityInfo

func (b Boots) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Boots) EncodeItem

func (b Boots) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Boots) KnockBackResistance

func (b Boots) KnockBackResistance() float64

KnockBackResistance ...

func (Boots) MaxCount

func (b Boots) MaxCount() int

MaxCount always returns 1.

func (Boots) Use

func (b Boots) Use(_ *world.World, user User, _ *UseContext) bool

Use handles the auto-equipping of boots in the armour slot when using it.

type Bowl

type Bowl struct{}

Bowl is a container that can hold certain foods.

func (Bowl) EncodeItem

func (Bowl) EncodeItem() (name string, meta int16)

EncodeItem ...

type Bread

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

Bread is a food item that can be eaten by the player.

func (Bread) AlwaysConsumable

func (Bread) AlwaysConsumable() bool

AlwaysConsumable ...

func (Bread) Consume

func (Bread) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Bread) ConsumeDuration

func (d Bread) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Bread) EncodeItem

func (Bread) EncodeItem() (name string, meta int16)

EncodeItem ...

type Brick

type Brick struct{}

Brick is an item made from clay, and is used for making bricks and flower pots.

func (Brick) EncodeItem

func (b Brick) EncodeItem() (name string, meta int16)

EncodeItem ...

type Bucket

type Bucket struct {
	// Content is the content that the bucket has. By default, this value resolves to an empty bucket.
	Content world.Liquid
}

Bucket is a tool used to carry water, lava, milk and fish.

func (Bucket) Empty

func (b Bucket) Empty() bool

Empty returns true if the bucket is empty.

func (Bucket) EncodeItem

func (b Bucket) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Bucket) MaxCount

func (b Bucket) MaxCount() int

MaxCount returns 16.

func (Bucket) UseOnBlock

func (b Bucket) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool

UseOnBlock handles the bucket filling and emptying logic.

type Carrier

type Carrier interface {
	// HeldItems returns the items currently held by the entity. Viewers of the entity will be able to see
	// these items.
	HeldItems() (mainHand, offHand Stack)
}

Carrier represents an entity that is able to carry an item.

type CarrotOnAStick

type CarrotOnAStick struct{}

CarrotOnAStick is an item that can be used to control saddled pigs.

func (CarrotOnAStick) EncodeItem

func (CarrotOnAStick) EncodeItem() (name string, meta int16)

EncodeItem ...

func (CarrotOnAStick) MaxCount

func (CarrotOnAStick) MaxCount() int

MaxCount ...

type Charcoal

type Charcoal struct{}

Charcoal is an item obtained by smelting logs or wood.

func (Charcoal) EncodeItem

func (Charcoal) EncodeItem() (name string, meta int16)

EncodeItem ...

type Chestplate

type Chestplate struct {
	// Tier is the tier of the chestplate.
	Tier armour.Tier
}

Chestplate is a defensive item that may be equipped in the chestplate slot. Generally, chestplates provide the most defence of all armour items.

func (Chestplate) Chestplate

func (c Chestplate) Chestplate() bool

Chestplate ...

func (Chestplate) DefencePoints

func (c Chestplate) DefencePoints() float64

DefencePoints ...

func (Chestplate) DurabilityInfo

func (c Chestplate) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Chestplate) EncodeItem

func (c Chestplate) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Chestplate) KnockBackResistance

func (c Chestplate) KnockBackResistance() float64

KnockBackResistance ...

func (Chestplate) MaxCount

func (c Chestplate) MaxCount() int

MaxCount always returns 1.

func (Chestplate) Use

func (c Chestplate) Use(_ *world.World, user User, _ *UseContext) bool

Use handles the using of a chestplate to auto-equip it in the designated armour slot.

type Chicken

type Chicken struct {

	// Cooked is whether the chicken is cooked.
	Cooked bool
	// contains filtered or unexported fields
}

Chicken is a food item obtained from chickens. It can be cooked in a furnace, smoker, or campfire.

func (Chicken) AlwaysConsumable

func (Chicken) AlwaysConsumable() bool

AlwaysConsumable ...

func (Chicken) Consume

func (ch Chicken) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Chicken) ConsumeDuration

func (d Chicken) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Chicken) EncodeItem

func (ch Chicken) EncodeItem() (name string, meta int16)

EncodeItem ...

type ClayBall

type ClayBall struct{}

ClayBall is obtained from mining clay blocks

func (ClayBall) EncodeItem

func (ClayBall) EncodeItem() (name string, meta int16)

EncodeItem ...

type Clock

type Clock struct{}

Clock is used to measure and display in-game time.

func (Clock) EncodeItem

func (w Clock) EncodeItem() (name string, meta int16)

EncodeItem ...

type Coal

type Coal struct{} //TODO: Fuel

Coal is an item used as fuel & crafting torches.

func (Coal) EncodeItem

func (Coal) EncodeItem() (name string, meta int16)

EncodeItem ...

type Cod

type Cod struct {

	// Cooked is whether the cod is cooked.
	Cooked bool
	// contains filtered or unexported fields
}

Cod is a food item obtained from cod. It can be cooked in a furnace, smoker, or campfire.

func (Cod) AlwaysConsumable

func (Cod) AlwaysConsumable() bool

AlwaysConsumable ...

func (Cod) Consume

func (co Cod) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Cod) ConsumeDuration

func (d Cod) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Cod) EncodeItem

func (co Cod) EncodeItem() (name string, meta int16)

EncodeItem ...

type Colour

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

Colour represents the colour of a block. Typically, Minecraft blocks have a total of 16 different colours.

func ColourBlack

func ColourBlack() Colour

ColourBlack returns the black colour.

func ColourBlue

func ColourBlue() Colour

ColourBlue returns the blue colour.

func ColourBrown

func ColourBrown() Colour

ColourBrown returns the brown colour.

func ColourCyan

func ColourCyan() Colour

ColourCyan returns the cyan colour.

func ColourGreen

func ColourGreen() Colour

ColourGreen returns the green colour.

func ColourGrey

func ColourGrey() Colour

ColourGrey returns the grey colour.

func ColourLightBlue

func ColourLightBlue() Colour

ColourLightBlue returns the light blue colour.

func ColourLightGrey

func ColourLightGrey() Colour

ColourLightGrey returns the light grey colour.

func ColourLime

func ColourLime() Colour

ColourLime returns the lime colour.

func ColourMagenta

func ColourMagenta() Colour

ColourMagenta returns the magenta colour.

func ColourOrange

func ColourOrange() Colour

ColourOrange returns the orange colour.

func ColourPink

func ColourPink() Colour

ColourPink returns the pink colour.

func ColourPurple

func ColourPurple() Colour

ColourPurple returns the purple colour.

func ColourRed

func ColourRed() Colour

ColourRed returns the red colour.

func ColourWhite

func ColourWhite() Colour

ColourWhite returns the white colour.

func ColourYellow

func ColourYellow() Colour

ColourYellow returns the yellow colour.

func Colours

func Colours() []Colour

Colours returns a list of all existing colours.

func (Colour) FromString

func (c Colour) FromString(s string) (interface{}, error)

FromString ...

func (Colour) RGBA

func (c Colour) RGBA() color.RGBA

RGBA returns the colour as RGBA. The alpha channel is always set to the maximum value. Colour values as returned here were obtained by placing signs in a world with all possible dyes used on them. The world was then loaded in Dragonfly to read their respective colours.

func (Colour) String

func (c Colour) String() string

String ...

func (Colour) Uint8

func (c Colour) Uint8() uint8

Uint8 ...

type Compass

type Compass struct{}

Compass is an item used to find the spawn position of a world.

func (Compass) EncodeItem

func (Compass) EncodeItem() (name string, meta int16)

EncodeItem ...

type Consumable

type Consumable interface {
	// AlwaysConsumable specifies if the item is always consumable. Normal food can generally only be consumed
	// when the food bar is not full or when in creative mode. Returning true here means the item can always
	// be consumed, like golden apples or potions.
	AlwaysConsumable() bool
	// ConsumeDuration is the duration consuming the item takes. If the player is using the item for at least
	// this duration, the item will be consumed and have its Consume method called.
	ConsumeDuration() time.Duration
	// Consume consumes one item of the Stack that the Consumable is in. The Stack returned is added back to
	// the inventory after consuming the item. For potions, for example, an empty bottle is returned.
	Consume(w *world.World, c Consumer) Stack
}

Consumable represents an item that may consumed by a player. If an item implements this interface, a player may use and hold the item to consume it.

type Consumer

type Consumer interface {
	User
	// Saturate saturates the Consumer's food bar by the amount of food points passed and the saturation by
	// up to as many saturation points as passed. The final saturation will never exceed the final food level.
	Saturate(food int, saturation float64)
	// AddEffect adds an effect.Effect to the Consumer. If the effect is instant, it is applied to the Consumer
	// immediately. If not, the effect is applied to the consumer every time the Tick method is called.
	// AddEffect will overwrite any effects present if the level of the effect is higher than the existing one, or
	// if the effects' levels are equal and the new effect has a longer duration.
	AddEffect(e effect.Effect)
}

Consumer represents a User that is able to consume Consumable items.

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

Cookie is a food item that can be obtained in large quantities, but do not restore hunger or saturation significantly.

func (Cookie) AlwaysConsumable

func (Cookie) AlwaysConsumable() bool

AlwaysConsumable ...

func (Cookie) Consume

func (Cookie) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Cookie) ConsumeDuration

func (d Cookie) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Cookie) EncodeItem

func (Cookie) EncodeItem() (name string, meta int16)

EncodeItem ...

type CopperIngot

type CopperIngot struct{}

CopperIngot is a metal ingot melted from copper ore.

func (CopperIngot) EncodeItem

func (c CopperIngot) EncodeItem() (name string, meta int16)

EncodeItem ...

type Diamond

type Diamond struct{}

Diamond is a rare mineral obtained from diamond ore or loot chests.

func (Diamond) EncodeItem

func (Diamond) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Diamond) PayableForBeacon

func (Diamond) PayableForBeacon() bool

PayableForBeacon ...

type DragonBreath

type DragonBreath struct{}

DragonBreath is a brewing item that is used solely to make lingering potions.

func (DragonBreath) EncodeItem

func (DragonBreath) EncodeItem() (name string, meta int16)

EncodeItem ...

type DriedKelp

type DriedKelp struct{}

DriedKelp is a food item that can be quickly eaten by the player.

func (DriedKelp) AlwaysConsumable

func (DriedKelp) AlwaysConsumable() bool

AlwaysConsumable ...

func (DriedKelp) Consume

func (DriedKelp) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (DriedKelp) ConsumeDuration

func (DriedKelp) ConsumeDuration() time.Duration

ConsumeDuration ...

func (DriedKelp) EncodeItem

func (DriedKelp) EncodeItem() (name string, meta int16)

EncodeItem ...

type DurabilityInfo

type DurabilityInfo struct {
	// MaxDurability is the maximum durability that this item may have. This field must be positive for the
	// durability to function properly.
	MaxDurability int
	// BrokenItem is the item created when the item is broken. For most durable items, this is simply an
	// air item.
	BrokenItem func() Stack
	// AttackDurability and BreakDurability are the losses in durability that the item sustains when they are
	// used to do the respective actions.
	AttackDurability, BreakDurability int
}

DurabilityInfo is the info of a durable item. It include fields that must be set in order to define durability related behaviour.

type Durable

type Durable interface {
	// DurabilityInfo returns info related to the durability of an item.
	DurabilityInfo() DurabilityInfo
}

Durable represents an item that has durability, and may therefore be broken. Some durable items, when broken, create a new item, such as an elytra.

type Dye

type Dye struct {
	// Colour is the colour of the dye.
	Colour Colour
}

Dye is an item that comes in 16 colours which allows you to colour blocks like concrete and sheep.

func (Dye) EncodeItem

func (d Dye) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Dye) UseOnBlock

func (d Dye) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool

UseOnBlock implements the colouring behaviour of signs.

type Emerald

type Emerald struct{}

Emerald is a rare mineral obtained from emerald ore or from villagers.

func (Emerald) EncodeItem

func (Emerald) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Emerald) PayableForBeacon

func (Emerald) PayableForBeacon() bool

PayableForBeacon ...

type EnchantedApple

type EnchantedApple struct{}

EnchantedApple is a rare variant of the golden apple that has stronger effects.

func (EnchantedApple) AlwaysConsumable

func (EnchantedApple) AlwaysConsumable() bool

AlwaysConsumable ...

func (EnchantedApple) Consume

func (EnchantedApple) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (EnchantedApple) ConsumeDuration

func (EnchantedApple) ConsumeDuration() time.Duration

ConsumeDuration ...

func (EnchantedApple) EncodeItem

func (EnchantedApple) EncodeItem() (name string, meta int16)

EncodeItem ...

type Enchantment

type Enchantment interface {
	// Name returns the name of the enchantment.
	Name() string
	// Level returns the current level of the enchantment. The best way to use this is
	// by having a struct similar to the enchantment.enchantment struct to store the level.
	Level() int
	// MaxLevel returns the maximum level the enchantment should be able to have.
	MaxLevel() int
	// WithLevel is called to create a new instance of the enchantment using the level passed.
	// This method could also be used to limit the level of the enchantment using MaxLevel.
	WithLevel(level int) Enchantment
	// CompatibleWith is called when an enchantment is added to an item. It can be used to check if
	// the enchantment is compatible with the item stack based on the item type, current enchantments etc.
	CompatibleWith(s Stack) bool
}

Enchantment represents an enchantment that can be applied to an item. It has methods to get the name, get the current level, get the maximum level, get a new instance of the enchant with a certain level and to check if the enchantment is compatible with an item stack.

func EnchantmentByID

func EnchantmentByID(id int) (Enchantment, bool)

EnchantmentByID attempts to return an enchantment by the ID it was registered with. If found, the enchantment found is returned and the bool true.

type Feather

type Feather struct{}

Feather are items dropped by chickens and parrots, as well as tamed cats as morning gifts.

func (Feather) EncodeItem

func (Feather) EncodeItem() (name string, meta int16)

EncodeItem ...

type FermentedSpiderEye

type FermentedSpiderEye struct{}

FermentedSpiderEye is a brewing ingredient.

func (FermentedSpiderEye) EncodeItem

func (FermentedSpiderEye) EncodeItem() (name string, meta int16)

EncodeItem ...

type Flint

type Flint struct{}

Flint is an item dropped rarely by gravel.

func (Flint) EncodeItem

func (Flint) EncodeItem() (name string, meta int16)

EncodeItem ...

type FlintAndSteel

type FlintAndSteel struct{}

FlintAndSteel is an item used to light blocks on fire.

func (FlintAndSteel) DurabilityInfo

func (f FlintAndSteel) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (FlintAndSteel) EncodeItem

func (f FlintAndSteel) EncodeItem() (name string, meta int16)

EncodeItem ...

func (FlintAndSteel) MaxCount

func (f FlintAndSteel) MaxCount() int

MaxCount ...

func (FlintAndSteel) UseOnBlock

func (f FlintAndSteel) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool

UseOnBlock ...

type GhastTear

type GhastTear struct{}

GhastTear is a brewing item dropped by ghasts.

func (GhastTear) EncodeItem

func (GhastTear) EncodeItem() (name string, meta int16)

EncodeItem ...

type GlassBottle

type GlassBottle struct{}

GlassBottle is an item that can hold various liquids.

func (GlassBottle) EncodeItem

func (g GlassBottle) EncodeItem() (name string, meta int16)

EncodeItem ...

func (GlassBottle) UseOnBlock

func (g GlassBottle) UseOnBlock(pos cube.Pos, _ cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool

UseOnBlock ...

type GlisteringMelonSlice

type GlisteringMelonSlice struct{}

GlisteringMelonSlice is an inedible item used for brewing potions of healing. It is also one of the many potion ingredients that can be used to make mundane potions.

func (GlisteringMelonSlice) EncodeItem

func (GlisteringMelonSlice) EncodeItem() (name string, meta int16)

EncodeItem ...

type GlowstoneDust

type GlowstoneDust struct{}

GlowstoneDust is dropped when breaking the glowstone block.

func (GlowstoneDust) EncodeItem

func (g GlowstoneDust) EncodeItem() (name string, meta int16)

EncodeItem ...

type GoldIngot

type GoldIngot struct{}

GoldIngot is a metal ingot melted from raw gold or obtained from loot chests.

func (GoldIngot) EncodeItem

func (GoldIngot) EncodeItem() (name string, meta int16)

EncodeItem ...

func (GoldIngot) PayableForBeacon

func (GoldIngot) PayableForBeacon() bool

PayableForBeacon ...

type GoldNugget

type GoldNugget struct{}

GoldNugget is an item used to craft gold ingots & other various gold items.

func (GoldNugget) EncodeItem

func (GoldNugget) EncodeItem() (name string, meta int16)

EncodeItem ...

type GoldenApple

type GoldenApple struct{}

GoldenApple is a special food item that bestows beneficial effects.

func (GoldenApple) AlwaysConsumable

func (e GoldenApple) AlwaysConsumable() bool

AlwaysConsumable ...

func (GoldenApple) Consume

func (e GoldenApple) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (GoldenApple) ConsumeDuration

func (e GoldenApple) ConsumeDuration() time.Duration

ConsumeDuration ...

func (GoldenApple) EncodeItem

func (e GoldenApple) EncodeItem() (name string, meta int16)

EncodeItem ...

type GoldenCarrot

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

GoldenCarrot is a valuable food item and brewing ingredient. It provides the second most saturation in the game, behind Suspicious Stew crafted with either a Dandelion or Blue Orchid.

func (GoldenCarrot) AlwaysConsumable

func (GoldenCarrot) AlwaysConsumable() bool

AlwaysConsumable ...

func (GoldenCarrot) Consume

func (GoldenCarrot) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (GoldenCarrot) ConsumeDuration

func (d GoldenCarrot) ConsumeDuration() time.Duration

ConsumeDuration ...

func (GoldenCarrot) EncodeItem

func (GoldenCarrot) EncodeItem() (name string, meta int16)

EncodeItem ...

type Gunpowder

type Gunpowder struct{}

Gunpowder is an item that is used for explosion-related recipes.

func (Gunpowder) EncodeItem

func (Gunpowder) EncodeItem() (name string, meta int16)

EncodeItem ...

type HeartOfTheSea

type HeartOfTheSea struct{}

HeartOfTheSea is a rare item that can be crafted into a conduit.

func (HeartOfTheSea) EncodeItem

func (HeartOfTheSea) EncodeItem() (name string, meta int16)

EncodeItem ...

type Helmet

type Helmet struct {
	// Tier is the tier of the armour.
	Tier armour.Tier
}

Helmet is a defensive item that may be worn in the head slot. It comes in several tiers, each with different defence points and armour toughness.

func (Helmet) DefencePoints

func (h Helmet) DefencePoints() float64

DefencePoints ...

func (Helmet) DurabilityInfo

func (h Helmet) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Helmet) EncodeItem

func (h Helmet) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Helmet) Helmet

func (h Helmet) Helmet() bool

Helmet ...

func (Helmet) KnockBackResistance

func (h Helmet) KnockBackResistance() float64

KnockBackResistance ...

func (Helmet) MaxCount

func (h Helmet) MaxCount() int

MaxCount always returns 1.

func (Helmet) Use

func (h Helmet) Use(_ *world.World, user User, _ *UseContext) bool

Use handles the using of a helmet to auto-equip it in an armour slot.

type Hoe

type Hoe struct {
	Tier tool.Tier
}

Hoe is a tool generally used to till dirt and grass blocks into farmland blocks for planting crops. Additionally a Hoe can be used to break certain types of blocks such as Crimson and Hay Blocks.

func (Hoe) AttackDamage

func (h Hoe) AttackDamage() float64

AttackDamage ...

func (Hoe) BaseMiningEfficiency

func (h Hoe) BaseMiningEfficiency(world.Block) float64

BaseMiningEfficiency ...

func (Hoe) DurabilityInfo

func (h Hoe) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Hoe) EncodeItem

func (h Hoe) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Hoe) MaxCount

func (h Hoe) MaxCount() int

MaxCount ...

func (Hoe) ToolType

func (h Hoe) ToolType() tool.Type

ToolType ...

func (Hoe) UseOnBlock

func (h Hoe) UseOnBlock(pos cube.Pos, face cube.Face, clickPos mgl64.Vec3, w *world.World, user User, ctx *UseContext) bool

UseOnBlock will turn a dirt or grass block into a farmland if the necessary properties are met.

type Honeycomb

type Honeycomb struct{}

Honeycomb is an item obtained from bee nests and beehives.

func (Honeycomb) EncodeItem

func (Honeycomb) EncodeItem() (name string, meta int16)

EncodeItem ...

type InkSac

type InkSac struct {
	// Glowing specifies if the ink sac is that of a glow squid. If true, it may be used on a sign to light up its text.
	Glowing bool
}

InkSac is an item dropped by a squid upon death used to create black dye, dark prismarine and book and quill. The glowing variant, obtained by killing a glow squid, may be used to cause sign text to light up.

func (InkSac) EncodeItem

func (i InkSac) EncodeItem() (name string, meta int16)

EncodeItem ...

func (InkSac) UseOnBlock

func (i InkSac) UseOnBlock(pos cube.Pos, face cube.Face, clickPos mgl64.Vec3, w *world.World, user User, ctx *UseContext) bool

UseOnBlock handles the logic of using an ink sac on a sign. Glowing ink sacs turn the text of these signs glowing, whereas normal ink sacs revert them back to non-glowing text.

type IronIngot

type IronIngot struct{}

IronIngot is a metal ingot melted from raw iron or obtained from loot chests.

func (IronIngot) EncodeItem

func (IronIngot) EncodeItem() (name string, meta int16)

EncodeItem ...

func (IronIngot) PayableForBeacon

func (IronIngot) PayableForBeacon() bool

PayableForBeacon ...

type IronNugget

type IronNugget struct{}

IronNugget is a piece of iron that can be obtained by smelting iron tools/weapons or iron/chainmail armor.

func (IronNugget) EncodeItem

func (IronNugget) EncodeItem() (name string, meta int16)

EncodeItem ...

type LapisLazuli

type LapisLazuli struct{}

LapisLazuli is a mineral used for enchanting and decoration.

func (LapisLazuli) EncodeItem

func (LapisLazuli) EncodeItem() (name string, meta int16)

EncodeItem ...

type Leather

type Leather struct{}

Leather is an animal skin used to make item frames, armor and books.

func (Leather) EncodeItem

func (Leather) EncodeItem() (name string, meta int16)

EncodeItem ...

type Leggings

type Leggings struct {
	// Tier is the tier of the leggings.
	Tier armour.Tier
}

Leggings are a defensive item that may be equipped in the leggings armour slot. They come in several tiers, like leather, gold, chain, iron and diamond.

func (Leggings) DefencePoints

func (l Leggings) DefencePoints() float64

DefencePoints ...

func (Leggings) DurabilityInfo

func (l Leggings) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Leggings) EncodeItem

func (l Leggings) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Leggings) KnockBackResistance

func (l Leggings) KnockBackResistance() float64

KnockBackResistance ...

func (Leggings) Leggings

func (l Leggings) Leggings() bool

Leggings ...

func (Leggings) MaxCount

func (l Leggings) MaxCount() int

MaxCount always returns 1.

func (Leggings) Use

func (l Leggings) Use(_ *world.World, user User, _ *UseContext) bool

Use handles the auto-equipping of leggings in an armour slot by using the item.

type MagmaCream

type MagmaCream struct{}

MagmaCream is an item used in brewing to create potions of Fire Resistance, and to build magma blocks.

func (MagmaCream) EncodeItem

func (m MagmaCream) EncodeItem() (name string, meta int16)

EncodeItem ...

type MaxCounter

type MaxCounter interface {
	// MaxCount returns the maximum number of items that a stack may be composed of. The number returned must
	// be positive.
	MaxCount() int
}

MaxCounter represents an item that has a specific max count. By default, each item will be expected to have a maximum count of 64. MaxCounter may be implemented to change this behaviour.

type MelonSlice

type MelonSlice struct{}

MelonSlice is a food item dropped by melon blocks.

func (MelonSlice) AlwaysConsumable

func (m MelonSlice) AlwaysConsumable() bool

AlwaysConsumable ...

func (MelonSlice) Consume

func (m MelonSlice) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (MelonSlice) ConsumeDuration

func (m MelonSlice) ConsumeDuration() time.Duration

ConsumeDuration ...

func (MelonSlice) EncodeItem

func (m MelonSlice) EncodeItem() (name string, meta int16)

EncodeItem ...

type MushroomStew

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

MushroomStew is a food item.

func (MushroomStew) AlwaysConsumable

func (MushroomStew) AlwaysConsumable() bool

AlwaysConsumable ...

func (MushroomStew) Consume

func (MushroomStew) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (MushroomStew) ConsumeDuration

func (d MushroomStew) ConsumeDuration() time.Duration

ConsumeDuration ...

func (MushroomStew) EncodeItem

func (MushroomStew) EncodeItem() (name string, meta int16)

EncodeItem ...

func (MushroomStew) MaxCount

func (MushroomStew) MaxCount() int

MaxCount ...

type Mutton

type Mutton struct {

	// Cooked is whether the mutton is cooked.
	Cooked bool
	// contains filtered or unexported fields
}

Mutton is a food item obtained from sheep. It can be cooked in a furnace, smoker, or campfire.

func (Mutton) AlwaysConsumable

func (Mutton) AlwaysConsumable() bool

AlwaysConsumable ...

func (Mutton) Consume

func (m Mutton) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Mutton) ConsumeDuration

func (d Mutton) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Mutton) EncodeItem

func (m Mutton) EncodeItem() (name string, meta int16)

EncodeItem ...

type NautilusShell

type NautilusShell struct{}

NautilusShell is an item that is used for crafting conduits.

func (NautilusShell) EncodeItem

func (NautilusShell) EncodeItem() (name string, meta int16)

EncodeItem ...

type NetherBrick

type NetherBrick struct{}

NetherBrick is an item made by smelting netherrack in a furnace.

func (NetherBrick) EncodeItem

func (NetherBrick) EncodeItem() (name string, meta int16)

EncodeItem ...

type NetherQuartz

type NetherQuartz struct{}

NetherQuartz is a smooth, white mineral found in the Nether.

func (NetherQuartz) EncodeItem

func (NetherQuartz) EncodeItem() (name string, meta int16)

EncodeItem ...

type NetherStar

type NetherStar struct{}

NetherStar is a rare item dropped by the wither that is used solely to craft beacons.

func (NetherStar) EncodeItem

func (NetherStar) EncodeItem() (name string, meta int16)

EncodeItem ...

type NetheriteIngot

type NetheriteIngot struct{}

NetheriteIngot is a rare mineral crafted with 4 pieces of netherite scrap and 4 gold ingots.

func (NetheriteIngot) EncodeItem

func (NetheriteIngot) EncodeItem() (name string, meta int16)

EncodeItem ...

func (NetheriteIngot) PayableForBeacon

func (NetheriteIngot) PayableForBeacon() bool

PayableForBeacon ...

type NetheriteScrap

type NetheriteScrap struct{}

NetheriteScrap is a material smelted from ancient debris, which is found in the Nether.

func (NetheriteScrap) EncodeItem

func (NetheriteScrap) EncodeItem() (name string, meta int16)

EncodeItem ...

type Paper

type Paper struct{}

Paper is an item crafted from sugar cane.

func (Paper) EncodeItem

func (Paper) EncodeItem() (name string, meta int16)

EncodeItem ...

type PhantomMembrane

type PhantomMembrane struct{}

PhantomMembrane are leathery skins obtained from killing phantoms.

func (PhantomMembrane) EncodeItem

func (PhantomMembrane) EncodeItem() (name string, meta int16)

EncodeItem ...

type Pickaxe

type Pickaxe struct {
	// Tier is the tier of the pickaxe.
	Tier tool.Tier
}

Pickaxe is a tool generally used for mining stone-like blocks and ores at a higher speed and to obtain their drops.

func (Pickaxe) AttackDamage

func (p Pickaxe) AttackDamage() float64

AttackDamage returns the attack damage of the pickaxe.

func (Pickaxe) BaseMiningEfficiency

func (p Pickaxe) BaseMiningEfficiency(world.Block) float64

BaseMiningEfficiency is the base efficiency of the pickaxe, when it comes to mining blocks. This decides the speed with which blocks can be mined.

func (Pickaxe) DurabilityInfo

func (p Pickaxe) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Pickaxe) EncodeItem

func (p Pickaxe) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Pickaxe) HarvestLevel

func (p Pickaxe) HarvestLevel() int

HarvestLevel returns the level that this pickaxe is able to harvest. If a block has a harvest level above this one, this pickaxe won't be able to harvest it.

func (Pickaxe) MaxCount

func (p Pickaxe) MaxCount() int

MaxCount returns 1.

func (Pickaxe) ToolType

func (p Pickaxe) ToolType() tool.Type

ToolType returns the type for pickaxes.

type PoisonousPotato

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

PoisonousPotato is a type of potato that can poison the player.

func (PoisonousPotato) AlwaysConsumable

func (PoisonousPotato) AlwaysConsumable() bool

AlwaysConsumable ...

func (PoisonousPotato) Consume

func (p PoisonousPotato) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (PoisonousPotato) ConsumeDuration

func (d PoisonousPotato) ConsumeDuration() time.Duration

ConsumeDuration ...

func (PoisonousPotato) EncodeItem

func (p PoisonousPotato) EncodeItem() (name string, meta int16)

EncodeItem ...

type PoppedChorusFruit

type PoppedChorusFruit struct{}

PoppedChorusFruit is an item obtained by smelting chorus fruit, and used to craft end rods and purpur blocks. Unlike raw chorus fruit, the popped fruit is inedible.

func (PoppedChorusFruit) EncodeItem

func (PoppedChorusFruit) EncodeItem() (name string, meta int16)

EncodeItem ...

type Porkchop

type Porkchop struct {

	// Cooked is whether the porkchop is cooked.
	Cooked bool
	// contains filtered or unexported fields
}

Porkchop is a food item obtained from pigs. It can be cooked in a furnace, smoker, or campfire.

func (Porkchop) AlwaysConsumable

func (Porkchop) AlwaysConsumable() bool

AlwaysConsumable ...

func (Porkchop) Consume

func (p Porkchop) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Porkchop) ConsumeDuration

func (d Porkchop) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Porkchop) EncodeItem

func (p Porkchop) EncodeItem() (name string, meta int16)

EncodeItem ...

type Potion

type Potion struct {
	// Type is the type of potion.
	Type potion.Potion
}

Potion is an item that grants effects on consumption.

func (Potion) AlwaysConsumable

func (p Potion) AlwaysConsumable() bool

AlwaysConsumable ...

func (Potion) Consume

func (p Potion) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Potion) ConsumeDuration

func (p Potion) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Potion) EncodeItem

func (p Potion) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Potion) MaxCount

func (p Potion) MaxCount() int

MaxCount ...

type PrismarineCrystals

type PrismarineCrystals struct{}

PrismarineCrystals are items obtained by defeating guardians or elder guardians. They are used to craft sea lanterns.

func (PrismarineCrystals) EncodeItem

func (p PrismarineCrystals) EncodeItem() (name string, meta int16)

EncodeItem ...

type PrismarineShard

type PrismarineShard struct{}

PrismarineShard is an item obtained by defeating guardians or elder guardians.

func (PrismarineShard) EncodeItem

func (PrismarineShard) EncodeItem() (name string, meta int16)

EncodeItem ...

type Pufferfish

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

Pufferfish is a poisonous type of fish that is used to brew water breathing potions.

func (Pufferfish) AlwaysConsumable

func (Pufferfish) AlwaysConsumable() bool

AlwaysConsumable ...

func (Pufferfish) Consume

func (p Pufferfish) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Pufferfish) ConsumeDuration

func (d Pufferfish) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Pufferfish) EncodeItem

func (p Pufferfish) EncodeItem() (name string, meta int16)

EncodeItem ...

type PumpkinPie

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

PumpkinPie is a food item that can be eaten by the player.

func (PumpkinPie) AlwaysConsumable

func (PumpkinPie) AlwaysConsumable() bool

AlwaysConsumable ...

func (PumpkinPie) Consume

func (PumpkinPie) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (PumpkinPie) ConsumeDuration

func (d PumpkinPie) ConsumeDuration() time.Duration

ConsumeDuration ...

func (PumpkinPie) EncodeItem

func (PumpkinPie) EncodeItem() (name string, meta int16)

EncodeItem ...

type Rabbit

type Rabbit struct {

	// Cooked is whether the rabbit is cooked.
	Cooked bool
	// contains filtered or unexported fields
}

Rabbit is a food item obtained from rabbits. It can be cooked in a furnace, smoker, or campfire.

func (Rabbit) AlwaysConsumable

func (Rabbit) AlwaysConsumable() bool

AlwaysConsumable ...

func (Rabbit) Consume

func (r Rabbit) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Rabbit) ConsumeDuration

func (d Rabbit) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Rabbit) EncodeItem

func (r Rabbit) EncodeItem() (name string, meta int16)

EncodeItem ...

type RabbitFoot

type RabbitFoot struct{}

RabbitFoot is a brewing item obtained from rabbits.

func (RabbitFoot) EncodeItem

func (RabbitFoot) EncodeItem() (name string, meta int16)

EncodeItem ...

type RabbitHide

type RabbitHide struct{}

RabbitHide is an item dropped by rabbits.

func (RabbitHide) EncodeItem

func (RabbitHide) EncodeItem() (name string, meta int16)

EncodeItem ...

type RabbitStew

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

RabbitStew is a food item that can be eaten by the player.

func (RabbitStew) AlwaysConsumable

func (RabbitStew) AlwaysConsumable() bool

AlwaysConsumable ...

func (RabbitStew) Consume

func (RabbitStew) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (RabbitStew) ConsumeDuration

func (d RabbitStew) ConsumeDuration() time.Duration

ConsumeDuration ...

func (RabbitStew) EncodeItem

func (RabbitStew) EncodeItem() (name string, meta int16)

EncodeItem ...

func (RabbitStew) MaxCount

func (RabbitStew) MaxCount() int

MaxCount ...

type RawCopper

type RawCopper struct{}

RawCopper is a raw metal resource obtained from mining copper ore.

func (RawCopper) EncodeItem

func (r RawCopper) EncodeItem() (name string, meta int16)

EncodeItem ...

type RawGold

type RawGold struct{}

RawGold is a raw metal resource obtained from mining gold ore.

func (RawGold) EncodeItem

func (r RawGold) EncodeItem() (name string, meta int16)

EncodeItem ...

type RawIron

type RawIron struct{}

RawIron is a raw metal resource obtained from mining iron ore.

func (RawIron) EncodeItem

func (r RawIron) EncodeItem() (name string, meta int16)

EncodeItem ...

type RottenFlesh

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

RottenFlesh is a food item that can be eaten by the player, at the high risk of inflicting Hunger.

func (RottenFlesh) AlwaysConsumable

func (RottenFlesh) AlwaysConsumable() bool

AlwaysConsumable ...

func (RottenFlesh) Consume

func (RottenFlesh) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (RottenFlesh) ConsumeDuration

func (d RottenFlesh) ConsumeDuration() time.Duration

ConsumeDuration ...

func (RottenFlesh) EncodeItem

func (RottenFlesh) EncodeItem() (name string, meta int16)

EncodeItem ...

type Salmon

type Salmon struct {

	// Cooked is whether the salmon is cooked.
	Cooked bool
	// contains filtered or unexported fields
}

Salmon is a food item obtained from salmons. It can be cooked in a furnace, smoker, or campfire.

func (Salmon) AlwaysConsumable

func (Salmon) AlwaysConsumable() bool

AlwaysConsumable ...

func (Salmon) Consume

func (s Salmon) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (Salmon) ConsumeDuration

func (d Salmon) ConsumeDuration() time.Duration

ConsumeDuration ...

func (Salmon) EncodeItem

func (s Salmon) EncodeItem() (name string, meta int16)

EncodeItem ...

type Scute

type Scute struct{}

Scute is an item that baby turtles drop when they grow into adults.

func (Scute) EncodeItem

func (Scute) EncodeItem() (name string, meta int16)

EncodeItem ...

type Shears

type Shears struct{}

Shears is a tool used to shear sheep, mine a few types of blocks, and carve pumpkins.

func (Shears) BaseMiningEfficiency

func (s Shears) BaseMiningEfficiency(b world.Block) float64

BaseMiningEfficiency ...

func (Shears) DurabilityInfo

func (s Shears) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Shears) EncodeItem

func (s Shears) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Shears) HarvestLevel

func (s Shears) HarvestLevel() int

HarvestLevel ...

func (Shears) MaxCount

func (s Shears) MaxCount() int

MaxCount ...

func (Shears) ToolType

func (s Shears) ToolType() tool.Type

ToolType ...

func (Shears) UseOnBlock

func (s Shears) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool

UseOnBlock ...

type Shovel

type Shovel struct {
	// Tier is the tier of the shovel.
	Tier tool.Tier
}

Shovel is a tool generally used for mining ground-like blocks, such as sand, gravel and dirt. Additionally, shovels may be used to turn grass into dirt paths.

func (Shovel) AttackDamage

func (s Shovel) AttackDamage() float64

AttackDamage returns the attack damage of the shovel.

func (Shovel) BaseMiningEfficiency

func (s Shovel) BaseMiningEfficiency(world.Block) float64

BaseMiningEfficiency ...

func (Shovel) DurabilityInfo

func (s Shovel) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Shovel) EncodeItem

func (s Shovel) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Shovel) HarvestLevel

func (s Shovel) HarvestLevel() int

HarvestLevel ...

func (Shovel) MaxCount

func (s Shovel) MaxCount() int

MaxCount always returns 1.

func (Shovel) ToolType

func (s Shovel) ToolType() tool.Type

ToolType returns the tool type for shovels.

func (Shovel) UseOnBlock

func (s Shovel) UseOnBlock(pos cube.Pos, face cube.Face, _ mgl64.Vec3, w *world.World, _ User, ctx *UseContext) bool

UseOnBlock handles the creation of dirt path blocks from dirt or grass blocks.

type ShulkerShell

type ShulkerShell struct{}

ShulkerShell are items dropped by shulkers that are used solely to craft shulker boxes.

func (ShulkerShell) EncodeItem

func (ShulkerShell) EncodeItem() (name string, meta int16)

EncodeItem ...

type Slimeball

type Slimeball struct{}

Slimeball is a crafting ingredient commonly dropped by slimes, and can be sneezed out by pandas.

func (Slimeball) EncodeItem

func (Slimeball) EncodeItem() (name string, meta int16)

EncodeItem ...

type SpiderEye

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

SpiderEye is a poisonous food and brewing item.

func (SpiderEye) AlwaysConsumable

func (SpiderEye) AlwaysConsumable() bool

AlwaysConsumable ...

func (SpiderEye) Consume

func (SpiderEye) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (SpiderEye) ConsumeDuration

func (d SpiderEye) ConsumeDuration() time.Duration

ConsumeDuration ...

func (SpiderEye) EncodeItem

func (SpiderEye) EncodeItem() (name string, meta int16)

EncodeItem ...

type Stack

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

Stack represents a stack of items. The stack shares the same item type and has a count which specifies the size of the stack.

func NewStack

func NewStack(t world.Item, count int) Stack

NewStack returns a new stack using the item type and the count passed. NewStack panics if the count passed is negative or if the item type passed is nil.

func (Stack) AddStack

func (s Stack) AddStack(s2 Stack) (a, b Stack)

AddStack adds another stack to the stack and returns both stacks. The first stack returned will have as many items in it as possible to fit in the stack, according to a max count of either 64 or otherwise as returned by Item.MaxCount(). The second stack will have the leftover items: It may be empty if the count of both stacks together don't exceed the max count. If the two stacks are not comparable, AddStack will return both the original stack and the stack passed.

func (Stack) AttackDamage

func (s Stack) AttackDamage() float64

AttackDamage returns the attack damage of the stack. By default, the value returned is 2.0. If the item held implements the item.Weapon interface, this damage may be different.

func (Stack) Comparable

func (s Stack) Comparable(s2 Stack) bool

Comparable checks if two stacks can be considered comparable. True is returned if the two stacks have an equal item type and have equal enchantments, lore and custom names, or if one of the stacks is empty.

func (Stack) Count

func (s Stack) Count() int

Count returns the amount of items that is present on the stack. The count is guaranteed never to be negative.

func (Stack) CustomName

func (s Stack) CustomName() string

CustomName returns the custom name set for the Stack. An empty string is returned if the Stack has no custom name set.

func (Stack) Damage

func (s Stack) Damage(d int) Stack

Damage returns a new stack that is damaged by the amount passed. (Meaning, its durability lowered by the amount passed.) If the item does not implement the Durable interface, the original stack is returned. The damage passed may be negative to add durability. If the final durability reaches 0 or below, the item returned is the resulting item of the breaking of the item. If the final durability reaches a number higher than the maximum durability, the stack returned will get the maximum durability.

func (Stack) Durability

func (s Stack) Durability() int

Durability returns the current durability of the item stack. If the item is not one that implements the Durable interface, BaseDurability will always return -1. The closer the durability returned is to 0, the closer the item is to breaking.

func (Stack) Empty

func (s Stack) Empty() bool

Empty checks if the stack is empty (has a count of 0).

func (Stack) Enchantment

func (s Stack) Enchantment(enchant Enchantment) (Enchantment, bool)

Enchantment attempts to return an enchantment set to the Stack using Stack.WithEnchantment(). If an enchantment is found, the enchantment and the bool true is returned.

func (Stack) Enchantments

func (s Stack) Enchantments() []Enchantment

Enchantments returns an array of all Enchantments on the item.

func (Stack) Equal

func (s Stack) Equal(s2 Stack) bool

Equal checks if the two stacks are equal. Equal is equivalent to a Stack.Comparable check while also checking the count.

func (Stack) Grow

func (s Stack) Grow(n int) Stack

Grow grows the Stack's count by n, returning the resulting Stack. If a positive number is passed, the stack is grown, whereas if a negative size is passed, the resulting Stack will have a lower count. The count of the returned Stack will never be negative.

func (Stack) Item

func (s Stack) Item() world.Item

Item returns the item that the stack holds. If the stack is considered empty (Stack.Empty()), Item will always return nil.

func (Stack) Lore

func (s Stack) Lore() []string

Lore returns the lore set for the Stack. If no lore is present, the slice returned has a len of 0.

func (Stack) MaxCount

func (s Stack) MaxCount() int

MaxCount returns the maximum count that the stack is able to hold when added to an inventory or when added to an item entity.

func (Stack) MaxDurability

func (s Stack) MaxDurability() int

MaxDurability returns the maximum durability that the item stack is able to have. If the item does not implement the Durable interface, MaxDurability will always return -1.

func (Stack) String

func (s Stack) String() string

String implements the fmt.Stringer interface.

func (Stack) Value

func (s Stack) Value(key string) (val interface{}, ok bool)

Value attempts to return a value set to the Stack using Stack.WithValue(). If a value is found by the key passed, it is returned and ok is true. If not found, the value returned is nil and ok is false.

func (Stack) Values

func (s Stack) Values() map[string]interface{}

Values returns all values associated with the stack by users. The map returned is a copy of the original: Modifying it will not modify the item stack.

func (Stack) WithCustomName

func (s Stack) WithCustomName(a ...interface{}) Stack

WithCustomName returns a copy of the Stack with the custom name passed. The custom name is formatted according to the rules of fmt.Sprintln.

func (Stack) WithDurability

func (s Stack) WithDurability(d int) Stack

WithDurability returns a new item stack with the durability passed. If the item does not implement the Durable interface, WithDurability returns the original stack. The closer the durability d is to 0, the closer the item is to breaking. If a durability of 0 is passed, a stack with the item type of the BrokenItem is returned. If a durability is passed that exceeds the maximum durability, the stack returned will have the maximum durability.

func (Stack) WithEnchantment

func (s Stack) WithEnchantment(ench Enchantment) Stack

WithEnchantment returns the current stack with the passed enchantment. If the enchantment is not compatible with the item stack, it will not be applied and will return the original stack.

func (Stack) WithLore

func (s Stack) WithLore(lines ...string) Stack

WithLore returns a copy of the Stack with the lore passed. Each string passed is put on a different line, where the first string is at the top and the last at the bottom. The lore may be cleared by passing no lines into the Stack.

func (Stack) WithValue

func (s Stack) WithValue(key string, val interface{}) Stack

WithValue returns the current Stack with a value set at a specific key. This method may be used to associate custom data with the item stack, which will persist through server restarts. The value stored may later be obtained by making a call to Stack.Value().

WithValue may be called with a nil value, in which case the value at the key will be cleared.

WithValue stores Values by encoding them using the encoding/gob package. Users of WithValue must ensure that their value is valid for encoding with this package.

func (Stack) WithoutEnchantment

func (s Stack) WithoutEnchantment(enchant Enchantment) Stack

WithoutEnchantment returns the current stack but with the passed enchantment removed.

type Stick

type Stick struct{}

Stick is one of the most abundant resources used for crafting many tools and items.

func (Stick) EncodeItem

func (s Stick) EncodeItem() (name string, meta int16)

EncodeItem ...

type Sugar

type Sugar struct{}

Sugar is a food ingredient and brewing ingredient made from sugar canes.

func (Sugar) EncodeItem

func (Sugar) EncodeItem() (name string, meta int16)

EncodeItem ...

type Sword

type Sword struct {
	// Tier is the tier of the sword.
	Tier tool.Tier
}

Sword is a tool generally used to attack enemies. In addition, it may be used to mine any block slightly faster than without tool and to break cobwebs rapidly.

func (Sword) AttackDamage

func (s Sword) AttackDamage() float64

AttackDamage returns the attack damage of the sword.

func (Sword) BaseMiningEfficiency

func (s Sword) BaseMiningEfficiency(world.Block) float64

BaseMiningEfficiency always returns 1.5, unless the block passed is cobweb, in which case 15 is returned.

func (Sword) DurabilityInfo

func (s Sword) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (Sword) EncodeItem

func (s Sword) EncodeItem() (name string, meta int16)

EncodeItem ...

func (Sword) HarvestLevel

func (s Sword) HarvestLevel() int

HarvestLevel returns the harvest level of the sword tier.

func (Sword) MaxCount

func (s Sword) MaxCount() int

MaxCount always returns 1.

func (Sword) ToolType

func (s Sword) ToolType() tool.Type

ToolType returns the tool type for swords.

type TropicalFish

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

TropicalFish is a food item that cannot be cooked.

func (TropicalFish) AlwaysConsumable

func (TropicalFish) AlwaysConsumable() bool

AlwaysConsumable ...

func (TropicalFish) Consume

func (TropicalFish) Consume(_ *world.World, c Consumer) Stack

Consume ...

func (TropicalFish) ConsumeDuration

func (d TropicalFish) ConsumeDuration() time.Duration

ConsumeDuration ...

func (TropicalFish) EncodeItem

func (TropicalFish) EncodeItem() (name string, meta int16)

EncodeItem ...

type TurtleShell

type TurtleShell struct{}

TurtleShell are items that are used for brewing or as a helmet to give the player the Water Breathing status effect.

func (TurtleShell) DefencePoints

func (t TurtleShell) DefencePoints() float64

DefencePoints ...

func (TurtleShell) DurabilityInfo

func (t TurtleShell) DurabilityInfo() DurabilityInfo

DurabilityInfo ...

func (TurtleShell) EncodeItem

func (t TurtleShell) EncodeItem() (name string, meta int16)

EncodeItem ...

func (TurtleShell) Helmet

func (t TurtleShell) Helmet() bool

Helmet ...

func (TurtleShell) KnockBackResistance

func (t TurtleShell) KnockBackResistance() float64

KnockBackResistance ...

func (TurtleShell) MaxCount

func (t TurtleShell) MaxCount() int

MaxCount always returns 1.

func (TurtleShell) Use

func (t TurtleShell) Use(_ *world.World, user User, _ *UseContext) bool

Use handles the using of a turtle shell to auto-equip it in an armour slot.

type Usable

type Usable interface {
	// Use is called when the item is used in the air. The user that used the item and the world that the item
	// was used in are passed to the method.
	// Use returns a bool indicating if the item was used successfully.
	Use(w *world.World, user User, ctx *UseContext) bool
}

Usable represents an item that may be used 'in the air'. If an item implements this interface, the Use method is called whenever the item is used while pointing at the air. (For example, when throwing an egg.)

type UsableOnBlock

type UsableOnBlock interface {
	// UseOnBlock is called when an item is used on a block. The world passed is the world that the item was
	// used in. The user passed is the entity that used the item. Usually this entity is a player.
	// The position of the block that was clicked, along with the clicked face and the position clicked
	// relative to the corner of the block are passed.
	// UseOnBlock returns a bool indicating if the item was used successfully.
	UseOnBlock(pos cube.Pos, face cube.Face, clickPos mgl64.Vec3, w *world.World, user User, ctx *UseContext) bool
}

UsableOnBlock represents an item that may be used on a block. If an item implements this interface, the UseOnBlock method is called whenever the item is used on a block.

type UsableOnEntity

type UsableOnEntity interface {
	// UseOnEntity is called when an item is used on an entity. The world passed is the world that the item is
	// used in, and the entity clicked and the user of the item are also passed.
	// UseOnEntity returns a bool indicating if the item was used successfully.
	UseOnEntity(e world.Entity, w *world.World, user User, ctx *UseContext) bool
}

UsableOnEntity represents an item that may be used on an entity. If an item implements this interface, the UseOnEntity method is called whenever the item is used on an entity.

type UseContext

type UseContext struct {
	Damage     int
	CountSub   int
	IgnoreAABB bool
	// NewItem is the item that is added after the item is used. If the player no longer has an item in the
	// hand, it'll be added there.
	NewItem Stack
	// NewItemSurvivalOnly will add any new items only in survival mode.
	NewItemSurvivalOnly bool
}

UseContext is passed to every item Use methods. It may be used to subtract items or to deal damage to them after the action is complete.

func (*UseContext) DamageItem

func (ctx *UseContext) DamageItem(d int)

DamageItem damages the item used by d points.

func (*UseContext) SubtractFromCount

func (ctx *UseContext) SubtractFromCount(d int)

SubtractFromCount subtracts d from the count of the item stack used.

type User

type User interface {
	Carrier
	// Facing returns the direction that the user is facing.
	Facing() cube.Direction
	SetHeldItems(mainHand, offHand Stack)
	Position() mgl64.Vec3
	Rotation() (yaw, pitch float64)
}

User represents an entity that is able to use an item in the world, typically entities such as players, which interact with the world using an item.

type WarpedFungusOnAStick

type WarpedFungusOnAStick struct{}

WarpedFungusOnAStick is an item that can be used to control saddled striders.

func (WarpedFungusOnAStick) EncodeItem

func (WarpedFungusOnAStick) EncodeItem() (name string, meta int16)

EncodeItem ...

func (WarpedFungusOnAStick) MaxCount

func (WarpedFungusOnAStick) MaxCount() int

MaxCount ...

type Weapon

type Weapon interface {
	// AttackDamage returns the custom attack damage of the weapon. The damage returned must not be negative.
	AttackDamage() float64
}

Weapon is an item that may be used as a weapon. It has an attack damage which may be different to the 2 damage that attacking with an empty hand deals.

type Wheat

type Wheat struct{}

Wheat is a crop used to craft bread, cake, & cookies.

func (Wheat) EncodeItem

func (w Wheat) EncodeItem() (name string, meta int16)

EncodeItem ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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